Creative Commons License
This blog by Tommy Tang is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

My github papge

Monday, November 14, 2016

define intronic, exonic and intergenic regions using GRanges

You might want to use the bedtools for solutions. see Dave Tang's post.

I am going to use GRanges to do exactly the same thing. However, do bear in mind that R uses 1 based coordinate system.  bed files in Granges are 1 based.  bedtools uses 0 based coordinate system for bed files. It could be very confusing and one can make 1 base-off mistake easily.

when you have a bed file in 0 based coordinate system, if you read it into R by using import function in rtracklayer package, it will convert to 1 based internally. However, if you read the 0 based bed file into R by read.table and want to convert the dataframe to GRanges, do not forget to add 1 to the start before converting to GRanges.


  1. I just used threeUTRByTranscripts today and you updated this too. :)

  2. replica audemars piguet watches uk, combining elegant style and cutting-edge technology, a variety of styles of replica jules audemars watches, the pointer walks between your exclusive taste style.