Find exons introns and intergenic regions

Originally published on my old Blogger blog on May 17, 2013. Read the original post and its comments.

see post here:

http://davetang.org/muse/2013/01/18/exons-introns-and-intergenic-regions/

Exons, introns and intergenic regions

Posted on January 18, 2013 by Davo

I'm interested in defining the exons, introns and intergenic regions of the genome based on GENCODE. So I thought about a fuss free way to do this, and BEDTools would be perfect.
Download the latest GENCODE annotations (version 14):

1 wgetftp://ftp.sanger.ac.uk/pub/gencode/release_14/gencode.v14.annotation.gtf.gz

I will use mergeBed, subtractBed and complementBed. See here for usage examples.
The GTF file defines exons, so I will find all exons, output as a minimal bed file, sort the bed file and merge the overlapping exons:

1
2
3
4

zcat gencode.v14.annotation.gtf.gz |awk 'BEGIN{OFS="\t";} $3=="exon" {print $1,$4,$5}' > gencode_v14_exon.bed
sortBed -i gencode_v14_exon.bed > gencode_v14_exon_temp.bed
mv -f gencode_v14_exon_temp.bed gencode_v14_exon.bed
mergeBed -i gencode_v14_exon.bed > gencode_v14_exon_merged.bed

To define intronic regions, we need to define the gene i.e. obtain the gene coordinates, and subtract the exons from this.

1
2
3
4

zcat gencode.v14.annotation.gtf.gz |awk 'BEGIN{OFS="\t";} $3=="gene" {print $1,$4,$5}' > gencode_v14_gene.bed
sortBed -i gencode_v14_gene.bed > gencode_v14_gene_temp.bed
mv -f gencode_v14_gene_temp.bed gencode_v14_gene.bed
subtractBed -a gencode_v14_gene.bed -b gencode_v14_exon_merged.bed > gencode_v14_intron.bed

And finally to define intergenic regions, we use complementBed to find regions not covered by genes. To create a hg19_chrom_info.txt file, use the fetchChromSizes executable available at http://hgdownload.cse.ucsc.edu/admin/exe/ to create the hg19_chrom_info.txt file for hg19.

1
2

./fetchChromSizes hg19 > hg19_chrom_info.txt
complementBed -i gencode_v14_gene.bed -g hg19_chrom_info.txt > gencode_v14_intergenic.bed

And that's it.
bedtools
Figure 1. The genome is a black box.

Related

Next
Previous
comments powered by Disqus