BIMSBbioinfo / genomation

R package for genomic feature analysis and visualization
http://bioinformatics.mdc-berlin.de/genomation/
73 stars 22 forks source link

[Questions] is it possible to cbind ScoreMatrixBin results? #198

Closed alexyfyf closed 3 years ago

alexyfyf commented 3 years ago

Hi team, Thanks for developing these packages.

I want to visualize the coverage around non-equal length regions, so I assume I should use ScoreMatrixBin. It worked perfect, but when I want to incorporate the flank say 2kb up and down stream of the region, I cannot figure out how to do this. Instead, I have to plot 3 individual plots for each, (up, middle and down).

An example is here to visualize the methylation in CpG islands and their flanking regions. Any better idea how to achieve it? I would assume the matrix in ScoreMatrixBin can be somehow merged like cbind, resulting a larger matrix. But not sure how to do that. image

Thanks a lot.

katwre commented 3 years ago

Hi @alexyfyf , All operations on ScoreMatrix(bin) objects should behave similarly to operations on matrices (check out details on my blogpost on @al2na 's website http://zvfak.blogspot.com/2015/10/summary-of-new-features-of-genomation_15.html), e.g.

library(genomation)
data(cage)
data(cpgi)
data(promoters)
mat=ScoreMatrixBin(target=cage,
                   windows=head(cpgi),
                   bin.num=10,bin.op="mean",weight.col="tpm")
new.mat=cbind(mat, mat)
new.score.mat=as(new.mat, "ScoreMatrix")
new.score.mat

Hope this helps, Kasia