Hi All,
I'm trying to create a GRangesList from a GRanges object. I basically have a Granges object called miRNA. It has 302 ranges. I also have a function that requires me to feed it with a GrangesList, so I am trying to alter the Granges object to a list format with each element of the list containing a single range I am sure there is an easy way to do this, but I can't wrap my head around it.
Thanks for any help.
> miRNA
GRanges object with 304 ranges and 3 metadata columns:
seqnames ranges strand | tx_name gene_id tx_type
<Rle> <IRanges> <Rle> | <character> <CharacterList> <character>
[1] 2L [ 857596, 857617] + | FBtr0304183 FBgn0262177 miRNA
[2] 2L [2737568, 2737589] + | FBtr0309710 FBgn0263564 miRNA
[3] 2L [3767667, 3767688] + | FBtr0304276 FBgn0262392 miRNA
[4] 2L [4343736, 4343756] + | FBtr0304206 FBgn0262375 miRNA
[5] 2L [5068596, 5068617] + | FBtr0304262 FBgn0262213 miRNA
... ... ... ... ... ... ... ...
[300] X [16191270, 16191291] - | FBtr0304409 FBgn0262283 miRNA
[301] X [19169201, 19169222] - | FBtr0309726 FBgn0263571 miRNA
[302] X [21296386, 21296407] - | FBtr0304484 FBgn0262454 miRNA
[303] X [21298279, 21298300] - | FBtr0309696 FBgn0263559 miRNA
[304] X [22833545, 22833566] - | FBtr0304314 FBgn0262237 miRNA
-------
seqinfo: 1870 sequences from an unspecified genome
Great, that's exactly what I was looking for.
Is there an easy way to use the mirna_id as names for the list elements? and do this in one go?
Two other solutions
and for the first a sanity check
But please be aware that using
split()
doesn't give you the same result:This is because the
mirna_id
metadata column contains some duplicates, which causessplit()
to generate some list elements with more than 1 range in them:This might or might not be what you want.
H.