Skip to Content

Split a GRanges object in R

I have created a GRanges object of 250 parsed BAM files. I want to split it into groups of 12, so I can perform a series of functions on each subgroup.

I've tried using the base split function, but it's not working for me on this. It works fine on character vectors.

How do I split an object? GRanges (Bioconductor) is from the GenomicRanges package. I created the object with the ExomeDepth (CRAN) package.

>my.counts   # RangedData with 689 rows and 4 value columns across 22 spaces
>split(my.counts,12)
 RangedDataList of length 1
 names(1): 2

A BAM file (.bam) is the binary version of a SAM file. A SAM file (.sam) is a tab-delimited text file that contains sequence alignment data. These formats are described on the SAM Tools web site: http://samtools.sourceforge.net.

So the object I create has 250 of these BAM files (one per patient sample). I want to split it into groups of 12 BAM Files. I will then compare them against each other as so:

subset A:

file 1 against set of 2:12
file 2 against set of (1,3:12)
file 3 against set of (1:2,4:12)
.... 
file 12 against set of 1:11

subset B:

file 1 against set of 2:12
file 2 against set of (1,3:12)
file 3 against set of (1:2,4:12)
.... 
file 12 against set of 1:11

and so on, for all permutations.