This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to get the total number of reads overlapping RNA regions in R

I have found the overlapping regions of a file of TSS and of RNA. The intersecting reads look like this:

   chr1 X108113121 X108113122  chr1.108113121.108113122.. X3 X.
1  chr1  108113470  108113471  chr1:108113470-108113471,-  1  -
2  chr1  237766677  237766678  chr1:237766677-237766678,+  1  +
3  chr1   91853110   91853111    chr1:91853110-91853111,-  1  -
4  chr1   91853104   91853105    chr1:91853104-91853105,+  1  +
5 chr10   70770177   70770178   chr10:70770177-70770178,+  1  +

How can I get the total number of reads overlapping the RNA regions in R? Also, how can I get the percentage of reads contaminated by the RNA?

overlapping-regions r tss rna genome

1 answer

In the GenomicRanges package, there is a findOverlaps() function. You can use that along with a bed file with chr/start/end of all RNA regions you are interested in.

You could also do this outside of R by using the intersect function in bedtools

This data is already with intersect applied from galaxy... If I just do nrow in R, would that be the number of intersected reads?

Log in to answer this question.