Bioconductor / Organism.dplyr

https://bioconductor.org/packages/Organism.dplyr
3 stars 3 forks source link

`exonsBy()` and others don't return same columns as GRanges version #9

Closed mtmorgan closed 7 years ago

mtmorgan commented 7 years ago

E.g., in test-src_organims-class.R, "mouse" test

> names(mcols(exonsBy(src)[[1]]))
Joining, by = c("ensembl", "tx_id")
[1] "tx_id"     "exon_id"   "exon_name" "exon_rank"
> names(mcols(exonsBy(txdb)[[1]]))
[1] "exon_id"   "exon_name" "exon_rank"
yubocheng commented 7 years ago

"tx_id" is needed to convert GRanges to GRangesList using split, line 340 in extractors.R, trying to drop "tx_id" after GRangesList is generated, but haven't found a way yet.

mtmorgan commented 7 years ago

One way is to make a copy of the vector and update the GRanges before splitting, e.g., at https://github.com/Bioconductor/Organism.dplyr/blob/master/R/extractors.R#L342 (get the link by clicking on the line number in github)

grp <- mcols(table)[[f]]
mcols(table)[[f]] <- NULL
split(table, grp)

Or to drop after the fact

gr <- unlist(grl)
mcols(grl)[[f]] <- NULL
relist(gr, grl)