This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extracting upstream and Downstream of a Gene based on different intervals

Hi All,

I want to extract the regions for the few genes in upstream and downstream based on certain intervals for example in the range of 0-50, 50-5000, 5000-50000 basepair. What could be the best way to do that? One way I could think off is to make a bed files for these intervals separately and then search it using tools. Is there any other smarter way to do this?

Thanks

intervals upstream

To do something like this in the past, I began by retrieving the TSS locations for all genes from Ensembl Biomart. I then wrote a simple AWK command like the one in the link provided by @genomax to get exactly what I want, using the TSS positions as the starting location.

EDIT: With sachas answer below you now have the 2 main ways to do this. Both begin with getting the coordinates of your gene and then selecting what you want from a reference file via an scripted command (e.g. AWK) or a bedtools function.

Thanks !!

How will I extract something like interval 50-5000 BPs region from a gene?

1 answer

  • Create a bed file with your gene. ( using refSeq.txt for instance ) : gene.bed
  • Use bedtools slop to make regions larger according how many basepair you want : gene_slop.bed
  • Use bedtools intersect between gene.bed and gene_slop.bed to keep only upstream & downstream region
  • Use bedtools gefasta to extract sequence

Log in to answer this question.