Error for "gpar" while using pheatmap!
1
3
Entering edit mode
8.8 years ago
Parham ★ 1.6k

Hi,

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 
metadata(0):
assays(1): ''
rownames(6696): SPAC212.11 SPAC212.10 ...
  SPMITTRNAGLU.01 SPMIT.11
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 <- as.data.frame(colData(dds)[,"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!

DESeq2 pheatmap gpar • 16k views
ADD COMMENT
4
Entering edit mode

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 REPLY
0
Entering edit mode

I had the same error and this worked for me.

ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
1
Entering edit mode
8.8 years ago

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 COMMENT
0
Entering edit mode

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 REPLY
1
Entering edit mode

Hey Parham, you are getting this error, because gpar is not a package, but grid is. https://stat.ethz.ch/R-manual/R-devel/library/grid/html/gpar.html

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

ADD REPLY
1
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1226 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6