Hi all,
I have been struggling with the heatmap function for which I continuously receive the error: 'x' must be a numeric matrix. I have been trying to perform section 4 ("Identifying temporally expressed genes") of the following slingshot vignette: http://www.bioconductor.org/packages/devel/bioc/vignettes/slingshot/inst/doc/vignette.html
I have executed the following lines of code, where "thymus_sce" is my SCE object:
library(tradeSeq)
# fit negative binomial GAM
sim <- fitGAM(thymus_sce)
# test for dynamic expression
ATres <- associationTest(thymus_sce)
topgenes <- rownames(ATres[order(ATres$pvalue), ])[1:250]
pst.ord <- order(thymus_sce$slingPseudotime_1, na.last = NA)
heatdata <- assays(thymus_sce)$counts[topgenes, pst.ord]
heatclus <- thymus_sce$GMM[pst.ord]
All of the above I got to work, until I get to:
heatmap(log1p(heatdata), Colv = NA,
ColSideColors = brewer.pal(9,"Set1")[heatclus])
Here, I get:
Error in heatmap(log1p(heatdata), Colv = NA, ColSideColors = brewer.pal(9, : 'x' must be a numeric matrix
I checked the class of heatdata
:
class(heatdata)
which gives me
[1] "dgCMatrix"
attr(,"package")
[1] "Matrix"
So I suppose it is a matrix, right? At least, a sparse one... Is that the problem? What am I doing wrong and how could I get this to work?
Your help would be much appreciated, if any more information is needed, please let me know!
Kind regards, Florencia
some R variables are not a matrix, could be a list, dataset or object, try to enforce matrix format with:
Hi JC,
Many thanks for your rapid response! I tried your suggestion, it seems to fix my previous error but now I get another one stating:
To be honest, I just copy/pasted the lines of code from the vignette, so not entirely sure how to modify the ColSideColors argument... Any idea?
you can either remove the entire argument (remove
ColSideColors = ....
) or you can make sure thatheatclus
is the same value asncol(log1p(heatdata))
that part is defining the colors, so you need a vector with one value per column, you can change it as: