How do I split a genomicrange on chromosome and strand?
1
1
Entering edit mode
5.6 years ago
endrebak ▴ 970
library(GenomicRanges)

gr <- GRanges(Rle(c("chr2", "chr2", "chr1", "chr3"), c(1, 3, 2, 4)),
                   IRanges(1:10, width=10:1, names=head(letters, 10)),
                   Rle(strand(c("-", "+", "*", "+", "-")), c(1, 2, 2, 3, 2)),
                   score=1:10, GC=seq(1, 0, length=10))
split(gr, seqnames(gr))

Gives me a list of chromosomes, but how do I get a list split on chromosome and strand?

genomicranges r bioconductor • 2.4k views
ADD COMMENT
3
Entering edit mode
5.6 years ago
zx8754 12k

Paste the chrom and strand then split as usual:

split(gr, paste(seqnames(gr), strand(gr)))
ADD COMMENT
0
Entering edit mode

I am trying to split just by chromosome but this does not work for me.

split(gr, seqnames(gr))

Will split everything by chromosome but the object for each chromosome will be the same length, which I assume is the number of sequences in chr1.

Please advise :/

ADD REPLY

Login before adding your answer.

Traffic: 1954 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6