This is a test version of Biostars. For the public version, visit https://www.biostars.org.
'gpar' element 'fill' must not be length 0

Hello everyone,

I'm trying to make a heatmap but I get the following error, can you help me?

topVarGenes <- head(order(rowVars(assay(rld)), decreasing = TRUE), 20)

mat <- assay(rld)[ topVarGenes, ]

mat <- mat - rowMeans(mat)

anno <- as.data.frame(colData(rld)[, c("Condition")])

pheatmap(mat, annotation_col = anno)

Error in check.length("fill") : 'gpar' element 'fill' must not be length 0

element pheatmap gpar

1 answer

It is a problem of annotation formatting, which should be a data.frame with the same rownames as your data colnames.

library(dplyr)
anno = colData(rld) %>% as.data.frame() %>% select(condition)
pheatmap(mat, annotation_col = anno)

Thanks so much, it worked for me.

Log in to answer this question.