hansenlab / bsseq

Devel repository for bsseq
36 stars 26 forks source link

Is it possible to append metadata to the GRanges within BSseq objects? #112

Closed lukesarre closed 2 years ago

lukesarre commented 2 years ago

Hello,

Thank you very much for developing bsseq, it has been an incredibly useful tool in my research.

I would like to append metadata to the GRanges part of the BSseq object. For example I would like rows to contain their dinucleotide context ("CA", "CT", etc.)

I have tried methods such as: granges(bs)$metadata = c("CA", "CT") and values(granges(bs)) = DataFrame(metadata = c("CA", "CT"))

However, both methods give the error: could not find function "granges<-"

Is it that BSseq objects are restricted from containing metadata? Or perhaps I am missing something more obvious?

Many thanks for your help, and I appreciate the work you have put into this package. Luke

PeteHaitch commented 2 years ago

I think you want rowRanges(bs), e.g., if your BSseq object contains 2 loci and you wanted to add the context you could do rowRanges(bs)$context <- c("CA", "CT")

PeteHaitch commented 2 years ago

FYI Formally, a BSseq object is a SummarizedExperiment object, so the syntax is the same. If you're not familiar with interacting with SummarizedExperiment objects, then the vignette may help (https://bioconductor.org/packages/release/bioc/vignettes/SummarizedExperiment/inst/doc/SummarizedExperiment.html)

lukesarre commented 2 years ago

That did the trick, perfect. And the vignette was very helpful Thank you for your help, Luke