I faced a very weird error, possibly a bug in R 3.5.1
or pheatmap
The following code is working fine:
rownames(df) <- colnames(mat)
xx <- pheatmap(mat, annotation_col=df)
But the following is not working:
rownames(df) <- str_sub(colnames(mat), 1, -3)
xx <- pheatmap(mat, annotation_col=df)
Everything just looks perfect, but it is giving the error:
Error in check.length("fill") : 'gpar' element 'fill' must not be length 0
I reloaded Rstudio
but the problem persists. Any modifications of rownames
of df
makes it impossible to draw the chart. I tried also substr
function.
Does anybody know why this is happening?
The issue was that colnames(mat)
should be matched with rownames(df)
, and so I am not allowed to just modify one without the other. The following code worked:
colnames(mat) <- str_sub(colnames(mat), 1, -3)
rownames(df) <- colnames(mat)
xx <- pheatmap(mat, annotation_col=df)