Question: Error for "gpar" while using pheatmap!
gravatar for Parham
4.9 years ago by
Parham1.5k wrote:


I am drawing some heatmaps using pheatmap following DESeq2 manual section 2.2.1 . Below I have codes and my objects output and the error. 

> library("pheatmap")
> select <- order(rowMeans(counts(dds, normalized = T)),
                decreasing = T)[1:20]

> select
 [1] 6672 6341 6665 3898 1780 6696 4512   50 2080 4181 3832
[12] 2304 4024 6671 5684 6666 6668 6283 5170 6253

> nt <- normTransform(dds)

> nt
class: DESeqTransform 
dim: 6696 6 
assays(1): ''
rownames(6696): SPAC212.11 SPAC212.10 ...
rowRanges metadata column names(27): baseMean baseVar
  ... deviance maxCooks
colnames(6): Rep1.NoB1 Rep2.NoB1 ... Rep2.B1 Rep3.B1
colData names(2): grp sizeFactor

> log2.norm.counts <- assay(nt)[select,]

> head(log2.norm.counts)
             Rep1.NoB1 Rep2.NoB1 Rep3.NoB1  Rep1.B1  Rep2.B1  Rep3.B1
SPMIT.06      18.48061  18.59110  18.57181 18.43607 18.53939 18.42969
SPCC1223.02   17.77126  17.80633  17.65893 10.25980 10.23582 11.44853
SPMIT.01      16.16548  16.06370  16.48245 15.84968 16.30330 16.46175
SPBC19C2.07   16.21655  16.16215  16.34401 16.04626 16.18888 16.36363
SPAC6G10.11c  16.19471  16.38594  16.08141 16.27448 16.19867 15.87793
SPMIT.11      16.04221  16.27445  16.34882 15.62673 16.18040 16.05569

> df <-[,"grp"])

> df
  colData(dds)[, "grp"]
1               control
2               control
3               control
4             treatment
5             treatment
6             treatment

> pheatmap(log2.norm.counts, cluster_rows = F, show_rownames = F,
         cluster_cols = F, annotation_col = df)

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

Can someone give a hint on what is the source of this error? Thanks in advance!

gpar deseq2 pheatmap • 11k views
ADD COMMENTlink modified 4.9 years ago by Sukhi Singh10k • written 4.9 years ago by Parham1.5k

Can you try it again after renaming the rows in df to match the column names in log2.norm.counts? I had a similar probelm, and that fixed it for me. I think pheatmap wants to match the annotation by name not by order. It would be helpful to me to know if this is the case.

ADD REPLYlink written 4.7 years ago by ricardo.t.ramirez40

I had the same error and this worked for me.

ADD REPLYlink written 4.7 years ago by smithng12150

I also had the error message mentioned above. My issue was resolved when I updated the row.names of the df passed to annotation_col to match the colnames in the df being plotted. As mentioned above I guess pheatmap uses the row.names to lookup which columns this metadata relates to.

ADD REPLYlink written 4.5 years ago by graeme_c_smith0

I'm having the same issue and understand how it needs to be resolved, but how exactly did you update the rownames in the df (as in the example above) passed to annotation_col to match colnames?

ADD REPLYlink written 3.3 years ago by k_mer0
gravatar for Sukhi Singh
4.9 years ago by
Sukhi Singh10k
Sukhi Singh10k wrote:

The function already gave you a hint, 'fill' must not be length 0. Are there any NA's in your data?

Try feeding a parameter to gpar (inside the pheatmap function)

gp = gpar(fill = "green")
ADD COMMENTlink modified 12 months ago by _r_am32k • written 4.9 years ago by Sukhi Singh10k

Thanks for emphasizing that. I thought gpar is something inside pheatmap codes that I cannot reach and in pheatmap documentation there was no parameter for setting gpar!

However I checked it now and it turns out I don't have the package installed in my R. Trying to install that it drops an error:

> install.packages("gpar")
Installing package into 'C:/Users/papo0009/Documents/R/win-library/3.2'
(as 'lib' is unspecified)
Warning in install.packages :
  package 'gpar' is not available (for R version 3.2.2)

Its strange if the package is not for latest versions of R why they use it in DESeq2!

I guess I will draw this heatmap using other packages than pheatmap. Thanks for looking into it Sukhdeep!

ADD REPLYlink modified 12 months ago by _r_am32k • written 4.9 years ago by Parham1.5k

Hey Parham, you are getting this error, because gpar is not a package, but grid is.

Try installing grid, but I think it should already be installed.

ADD REPLYlink modified 12 months ago by _r_am32k • written 4.9 years ago by Sukhi Singh10k

Thanks for info! Yes I have grid. library(grid) didn't drop any errors.

ADD REPLYlink modified 12 months ago by _r_am32k • written 4.9 years ago by Parham1.5k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1277 users visited in the last hour