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

1

5

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?

Kinship answered 15/8, 2018 at 1:46 Comment(3)
Can you please make your example reproducible by including sample data for df and mat.Russ
Have you changed the column names of 'mat' with colnames(mat) <- str_sub(colnames(mat), 1, -3)Fibrosis
Yes, you are right, that was the issue: I did notKinship
K
15

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)
Kinship answered 15/8, 2018 at 1:57 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.