Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

pheatmap

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?

like image 849
Nikita Vlasenko Avatar asked Dec 24 '22 05:12

Nikita Vlasenko


1 Answers

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)
like image 116
Nikita Vlasenko Avatar answered May 19 '23 21:05

Nikita Vlasenko