Error when using multiple heatmaps in ComplexHeatmaps
2
0
Entering edit mode
brt381 • 0
@brt381-9339
Last seen 6.6 years ago
Canada

 

I am having difficulty with creating multiple heatmaps with the ComplexHeatmap package. When I run a script that contains code exactly lifted from the documentation (https://bioconductor.org/packages/release/bioc/vignettes/ComplexHeatmap/inst/doc/s3.a_list_of_heatmaps.html)...

library(ComplexHeatmap)

mat1 = matrix(rnorm(80, 2), 8, 10)
mat1 = rbind(mat1, matrix(rnorm(40, -2), 4, 10))
rownames(mat1) = paste0("R", 1:12)
colnames(mat1) = paste0("C", 1:10)

mat2 = matrix(rnorm(60, 2), 6, 10)
mat2 = rbind(mat2, matrix(rnorm(60, -2), 6, 10))
rownames(mat2) = paste0("R", 1:12)
colnames(mat2) = paste0("C", 1:10)

ht1 = Heatmap(mat1, name = "ht1")
ht2 = Heatmap(mat2, name = "ht2")
class(ht1)

class(ht2)
sessionInfo()
ht1 + ht2

... I get the error message:

Error in ht1 + ht2 : non-numeric argument to binary operator
Execution halted

Here is the output of sessionInfo():

R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.2

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  base     

other attached packages:
[1] ComplexHeatmap_1.12.0

loaded via a namespace (and not attached):
 [1] flexmix_2.3-13       Rcpp_0.12.9          cluster_2.0.5       
 [4] whisker_0.3-2        magrittr_1.5         fpc_2.1-10          
 [7] MASS_7.3-45          munsell_0.4.3        mclust_5.2.1        
[10] colorspace_1.3-2     lattice_0.20-34      rjson_0.2.15        
[13] plyr_1.8.4           prabclus_2.2-6       tools_3.3.2         
[16] nnet_7.3-12          gtable_0.2.0         circlize_0.3.9      
[19] class_7.3-14         modeltools_0.2-21    lazyeval_0.2.0      
[22] assertthat_0.1       tibble_1.2           kernlab_0.9-25      
[25] trimcluster_0.1-2    RColorBrewer_1.1-2   ggplot2_2.2.1       
[28] GlobalOptions_0.0.10 dendextend_1.3.0     robustbase_0.92-7   
[31] shape_1.4.2          DEoptimR_1.0-8       methods_3.3.2       
[34] scales_0.4.1         diptest_0.75-7       stats4_3.3.2        
[37] mvtnorm_1.0-5        GetoptLong_0.1.5    
ComplexHeatmap bug • 2.1k views
ADD COMMENT
1
Entering edit mode
brt381 • 0
@brt381-9339
Last seen 6.6 years ago
Canada

OK, this seems very strange. I was previously running the code I posted using Rscript, and it gives the indicated error. But when I run R interactively and copy-and-paste those lines in, it does work (with or without --vanilla). It does NOT work via Rscript whether with or without --vanilla.

EDIT: I did some Googling and it was suggested to say library(methods) at the top of the script (apparently R attaches this by default, but not Rscript). This made it work in Rscript!

ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 2 days ago
United States

I can't reproduce. You might try restarting R and re-running your code, particularly with R --vanilla to get a clean workspace on startup. If you still get an error, please show the results from

traceback()
ADD COMMENT

Login before adding your answer.

Traffic: 592 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