thanks, i did get overlaps using countoverlaps and converted it into percentage. what i want is it separated in quantile as i mentioned in original question, 0-25%, 25-50%, 50-75%, 75-100%, total 4 groups. I am unable to do this.
Hello everyone,
I have 2 granges object, x,y. I want to find overlap between them. Say in first row of x there are "n" of y overlapping, i want to get percentage of such overlap and then filter them on the basis of percentages, say 0-25%, 25-50%, 50-75%, 75-100%. Can you please help me doing it in R
2 answers
GRanges admit direct overlapping indexing. That is to say, you can use %over% to index them. For example, we have a the dataframe X that contains some information, including its associated coordinate ranges (stored as GRanges in X@coordinates). Given GRanges object coordinates (e.g. as("X:71223192-71525892:+", Class = "GRanges")) I can do the following:
coordinates <- as("X:71223192-71525892:+", Class = "GRanges")
X@coordinates[X@coordinates %over% coordinates]
This will retrieve the overlapping coordinates, which you can use to calculate the percentage of overlaping, or to index the metadata object X.
If you already have the raw percentage and only wish to bin it to quantiles, it doesn't have anything to do with GRanges as such - the operation you're looking for can be performed on any vector of numbers. Please search online (especially on StackOverflow) on how to bin a vector into quantiles.
I figured out how to do it. Thanks all
If you did it is a different way than what was suggested in answer by @maqquimeded21 then please post the correct solution by editing this answer to provide closure to this thread. If you used that answer then please accept that answer (green check) mark to provide closure to this thread.
Log in to answer this question.
What have you tried? Have you looked through GRanges posts here and on http://support.bioconductor.org/?
I used the GenomicRanges R package, using countoverlaps, to find overlaps between two sets of genomic ranges. I want to add a column to x indicating the percentage of overlap with y for each row of x. But I do not get what I want as output