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.
This blog by Tommy Tang is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
I just used threeUTRByTranscripts today and you updated this too. :)
ReplyDeletegood to know it :)
Delete