I have a list of peaks as below, sample shown for 2 samples but have more than that
myPeaks
$`HindBrain_1`
GRanges object with 6906 ranges and 0 metadata columns:
seqnames ranges strand
<Rle> <IRanges> <Rle>
[1] chr1 180772-180997 *
[2] chr1 199827-199960 *
[3] chr1 629105-630021 *
[4] chr1 630263-630476 *
[5] chr1 630757-631369 *
... ... ... ...
[6902] chrY 56769777-56769888 *
[6903] chrY 56839405-56839501 *
[6904] chrY 56847748-56847872 *
[6905] chrY 56850422-56850536 *
[6906] chrY 56850787-56850976 *
seqinfo: 72 sequences from an unspecified genome; no seqlengths
$`HindBrain_2`
GRanges object with 13456 ranges and 0 metadata columns:
seqnames ranges strand
<Rle> <IRanges> <Rle>
[1] chr1 10371-10459 *
[2] chr1 29279-29387 *
[3] chr1 180747-180991 *
[4] chr1 199817-199972 *
[5] chr1 629105-629884 *
... ... ... ...
[13452] chrY 26640511-26640600 *
[13453] chrY 56838911-56839024 *
[13454] chrY 56839408-56839506 *
[13455] chrY 56850376-56850536 *
[13456] chrY 56850784-56850953 *
seqinfo: 72 sequences from an unspecified genome; no seqlengths
and would like to get a count of the non-redundant regions (based on presence or absence in that sample), with a consensus id, something like this
GRanges object with 89654 ranges and 2 metadata columns:
seqnames ranges strand | HindBrain_1 HindBrain_2
<Rle> <IRanges> <Rle> | <numeric> <numeric>
[1] chr1 [3130336, 3130413] * | 0 0
[2] chr1 [3400112, 3400250] * | 0 0
[3] chr1 [3433954, 3434095] * | 0 0
[4] chr1 [3515020, 3515102] * | 0 0
[5] chr1 [3575895, 3576078] * | 0 0
... ... ... ... . ... ...
[89650] chrY [90805058, 90805151] * | 0 0
[89651] chrY [90807391, 90807562] * | 0 0
[89652] chrY [90808761, 90808841] * | 0 1
[89653] chrY [90812961, 90813237] * | 1 1
[89654] chrY [90829708, 90829782] * | 0 0
consensusIDs
<factor>
[1] consensus_1
[2] consensus_2
[3] consensus_3
[4] consensus_4
[5] consensus_5
... ... ... ... ... ...
[89650] consensus_89765
[89651] consensus_89766
[89652] consensus_89767
[89653] consensus_89768
[89654] consensus_89769
seqinfo: 22 sequences from an unspecified genome; no seqlengths
I tried using soGGi:::runConsensusRegions but the function seems depreciated
Mainly because my input is a list of peaks, am not sure that findconsensusRegions uses a list of peaks, and did not find any examples for the input in the documentation
So, findconsensusRegions requires a named character vector as input whereas I have a list of Granges objects. Should I just convert them into named character vectors and store them as a list? Tried looking for more documentation but could not find any examples in the vignette
It looks like
findconsensusPeaks
does do extra things that maybe you don't want. But as you have already noted, the unexportedrunConsensusPeaks
function may do what you want, so maybe that's all you need.It's generally a bad idea to use unexported functions simply because as such they are not expected to remain the same, nor do the same thing, nor even exist in future iterations of the package. The code for
runConsensusPeaks
is pretty straightforward, so you might consider writing your own function that does exactly what you want, based on that function, in which case you would then have control over what it does and can adjust as you see fit.Thanks James. The solution was right there, and I did not notice it. Posting so that someone else might find it useful.
An excerpt from the function soGGi:::runConsensusRegions does the job.
Where the input is of the class "CompressedGRangesList".
Reference to the package http://bioconductor.org/packages/release/bioc/html/soGGi.html
Note that your function won't work, except in the case that you have an object
myGRangesList
that exists in your.GlobalEnv
.Put another way, the argument to your function isn't used at all.
Sorry about that, I already had a Grangeslist object in my environment, should have mentioned that.
My point is that you have to have a
GRangesList
called 'myGrangesList' in your.GlobalEnv
for your function to work, and that the argument (x) to your function is superfluous. This is not ideal! You normally want your arguments to actually be, you know, arguments, and not to require some exacting set up for the function to work.