Extracting exonic and intronic regions from a bam file

 

Step 1: Making separate bed files for the intronic & exonic regions

screen-shot-2017-02-05-at-8-50-56-pm

  • Then a second page will appear where you  select “Introns plus” and leave as 0 to just get the introns
  • select “get BED”
  • then repeat, renaming the file to UCSC_exons_hg19.tsv and on the second page selecting “Exons plus”
  • you can use the UCSC genome browser to confirm the files have only introns (or only exons)

Step 2: Extracting the specific regions from your bam file

This samtools command will only output alignments overlapping the input BED file.

The -h option = output file will include the header. The -L option = output alignments overlapping the input BED file.

Only output alignments overlapping introns:

samtools view -h -L UCSC_Introns_hg19_.bed  sample.bam > sample_introns.bam

Only output alignments overlapping exons:

samtools view -h -L UCSC_exons_hg19_new.bed sample.bam > sample_exons.bam

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s