Dear all,
I have a set of elements with the following distribution of lengths:
summary(width(positivelincrnas)) Min. 1st Qu. Median Mean 3rd Qu. Max. 470 4164 9872 18940 20790 152600
and another dataset with the following distribution:
summary(width(positivegeneshg19)) Min. 1st Qu. Median Mean 3rd Qu. Max. 20 5558 20460 59880 58360 4829000
I would like to get elements from the second dataset (genes) such that they are of the same length distribution as the first set of elements (lincrnas). Both objects are GRanges objects.
Any suggestions?
Thanks a lot,
Dimitris
Thanks a lot for your reply Julian. That algorithm was also what I was thinking but still it doesn't work for me. A couple of questions:
1. When creating object idx, I have to remove NAs with na.omit for example, right?
2. In the sample command as argument you put gr - there is no object gr defined so probably you mean gr1 right?
width(gr2)
. Otherwise, values outside the bin range cannot be assigned a proper index, and this results in NAs. I would try this instead of removing NAs.gr2
because this is the data set we want to sample from. I have changed the code in the example.