jokergoo / ComplexHeatmap

Make Complex Heatmaps
https://jokergoo.github.io/ComplexHeatmap-reference/book/
Other
1.25k stars 220 forks source link

Unable to create heatmap list to plot two heatmaps #1153

Open jvazquez3 opened 5 months ago

jvazquez3 commented 5 months ago

Hi, I'm trying to concatenate two heatmaps. I can render the heatmaps seperately but can not plot them together simply using '+'. I've updated R and reinstalled ComplexHeatmaps package. I have also tried other suggestions (i.e adding 'library(methods)' to script and using 'draw("+.AdditiveUnit"(ht1, ht2))'). Error received is Error in ht1 + ht2 : non-numeric argument to binary operator.

My code is clunky but here it is.

library(methods)
library(ComplexHeatmap)
library(circlize)

cyt.data <- read.csv('PlacentaTisseel.csv') ##Reading in raw data file. 
cyt.matrix <- data.matrix(cyt.data) ##Converting to numeric matrix
cyt.matrix2 <- cyt.matrix[, -c(1)] ##To delete the first column (samples) 
heatmap(cyt.matrix2) ##Raw data heatmap
cyt.matrix_scaled <- scale(cyt.matrix2)
heatmap(cyt.matrix_scaled) ##Scaled heatmap

ht1 = heatmap(cyt.matrix_scaled)

detailpath.data <- read.csv('LogPathDetails.csv') ##Reading in raw data file. 
detailpath.matrix <- data.matrix(detailpath.data) ##Converting to numeric matrix
detailpath.matrix2 <- detailpath.matrix[, -c(1)] ##To delete the first column (samples)
detailpath.matrix2 <- as.matrix(detailpath.matrix2[, -c(5)])
heatmap(detailpath.matrix2) ##Raw data heatmap

ht2 = heatmap(detailpath.matrix2)

ht1 + ht2
draw(ht1 + ht2)

This is my session info:

R version 4.2.0 (2022-04-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.6.6

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

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

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

other attached packages:
[1] circlize_0.4.15       ComplexHeatmap_2.15.4

loaded via a namespace (and not attached):
 [1] matrixStats_1.2.0   codetools_0.2-19    IRanges_2.32.0     
 [4] png_0.1-8           digest_0.6.33       foreach_1.5.2      
 [7] crayon_1.5.2        stats4_4.2.0        GlobalOptions_0.1.2
[10] doParallel_1.0.17   S4Vectors_0.36.2    GetoptLong_1.0.5   
[13] RColorBrewer_1.1-3  rjson_0.2.21        iterators_1.0.14   
[16] tools_4.2.0         parallel_4.2.0      compiler_4.2.0     
[19] clue_0.3-65         colorspace_2.1-0    BiocGenerics_0.44.0
[22] cluster_2.1.6       shape_1.4.6        

Would appreciate any input. Thank you!