Bioconductor / GenomicRanges

Representation and manipulation of genomic intervals
https://bioconductor.org/packages/GenomicRanges
41 stars 17 forks source link

Feature request: make mcols on a GRangesList return a SplitDataFrameList #23

Closed FelixErnst closed 4 years ago

FelixErnst commented 5 years ago

I currently cannot access the metadata columns of GRangesList without some form of custom "witchcraft"

library(TxDb.Scerevisiae.UCSC.sacCer3.sgdGene)
txdb <- TxDb.Scerevisiae.UCSC.sacCer3.sgdGene
grl<- GenomicFeatures::cdsBy(txdb, by = "gene")
mcols(grl)
#> DataFrame with 6534 rows and 0 columns
mcols(grl[[1]])
#> DataFrame with 2 rows and 2 columns
#>      cds_id    cds_name
#>   <integer> <character>
#> 1      6992          NA
#> 2      6993          NA
mcols(grl[,"cds_id"])
#> DataFrame with 6534 rows and 0 columns

For accessing columns my function looks like this

.get_column_GRangesList <- function(grl,column){
    relist(mcols(grl@unlistData)[,column],grl@partitioning)
}

Is there a specific reason, this feature exists as it is right now? Did I miss some specific way of accessing the metadata?

Thanks for any help and advice

lawremi commented 5 years ago

I think you are looking for mcols(grl, level="within").

FelixErnst commented 5 years ago

Yes, indeed. Thanks for the advice. Would it be possible to add this to the man pages? Neither ?GRangesList nor ?mcols provides a hint about this argument.

FelixErnst commented 4 years ago

So I guess, an addition to the man pages regarding the level argument is not an option?