jokergoo / ComplexHeatmap

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

Multiple annotations #601

Closed santiiiiiii closed 3 years ago

santiiiiiii commented 3 years ago

Hi I am trying to make three sets of annotations on my heatmap: Diagnosis, Respiratory_Status and hsCRP. They all work individually but I can't get them to appear all together.

I have used the following code:

anno_df = data.frame(Diagnosis = factor(DGEList_0_24$targets$Group_facet,levels = c("Controls", "Screening: asymptomatic","Screening: symptomatic", "Mild (no oxygen)","Moderate (low flow oxygen)", "Severe (assisted ventilation)")), 
hsCRP=as.numeric(manifest_select$hsCRP_mg_l),
Respiratory_Status=factor(manifest_select$resp, levels =c("no O2","low flow O2","vent","ECMO")))

ha_24 = HeatmapAnnotation(df = anno_df,
col = list(Diagnosis = c("Mild (no oxygen)" = "blue", "Moderate (low flow oxygen)" = "orange",     "Severe (assisted ventilation)" = "red","Screening: symptomatic"="lightblue","Screening: asymptomatic"="cyan","Controls"="green"),
hsCRP=colorRamp2(c(0,400), c("white", "red")), 
Respiratory_Status= c("no O2"="blue","low flow O2"="orange","vent"="red","ECMO"="darkred")))

When I run:

Heatmap(data_subset_norm_24, 
name = "Z-normalised", 
        col = col_fun,
        top_annotation= ha_24,
        show_row_names=FALSE,show_column_names = FALSE,
        column_title = "Disease severity at 0-24 days post symptom onset", 
        column_title_gp = gpar(fontsize = 12,face="bold"),
        column_km  = 6,
        row_km  = 3,
        cluster_columns=TRUE,
        clustering_distance_rows = "euclidean",
        clustering_method_rows = "ward.D",
        row_dend_reorder = TRUE)

The following error appears: Error in opt$get(calling_ns, read.only = READ.ONLY, enforce_visible = TRUE) : attempt to apply non-function

Thank you

jokergoo commented 3 years ago

Can you also attach the objects of data_subset_norm_24 and ha_24 so that I can have a test? I haven't seen this type of error.

santiiiiiii commented 3 years ago

Thanks for replying. I can't seem to attach the robjects. I get the following error on github: "We don't support that file type". May I email them to you?

jokergoo commented 3 years ago

Can you zip it? I think github supports .zip files.

santiiiiiii commented 3 years ago

ha_24.rds.zip data_subset_norm_24.rds.zip

santiiiiiii commented 3 years ago

Thank you

jokergoo commented 3 years ago

Emmm. I don't have this error. Following is the plot that was successfully generated:

image

What is your sessionInfo()?

santiiiiiii commented 3 years ago

It still doesn't work for me. My session info is:

R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

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

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

other attached packages:
 [1] MOFAdata_1.3.1              MOFA_1.4.0                  MOFA2_1.1                   MultiAssayExperiment_1.14.0
 [5] mixOmics_6.12.2             MBESS_4.8.0                 lmeSplines_1.1-10           nlme_3.1-149               
 [9] lme4_1.1-23                 Matrix_1.2-18               corrplot_0.84               biomaRt_2.44.1             
[13] reticulate_1.16-9001        circlize_0.4.10             ComplexHeatmap_2.4.3        UpSetR_1.4.0               
[17] htmlTable_2.1.0             Rsubread_2.2.6              WGCNA_1.69                  fastcluster_1.1.25         
[21] dynamicTreeCut_1.63-1       forcats_0.5.0               stringr_1.4.0               purrr_0.3.4                
[25] readr_1.3.1                 tibble_3.0.3                tidyverse_1.3.0             DESeq2_1.28.1              
[29] ggfortify_0.4.11            ggpubr_0.4.0                lattice_0.20-41             MASS_7.3-53                
[33] gridExtra_2.3               ggplot2_3.3.2               tidyr_1.1.2                 dplyr_1.0.2                
[37] SummarizedExperiment_1.18.2 DelayedArray_0.14.1         matrixStats_0.57.0          Biobase_2.48.0             
[41] GenomicRanges_1.40.0        GenomeInfoDb_1.24.2         IRanges_2.22.2              S4Vectors_0.26.1           
[45] BiocGenerics_0.34.0         edgeR_3.30.3                limma_3.44.3               

loaded via a namespace (and not attached):
  [1] tidyselect_1.1.0       RSQLite_2.2.1          AnnotationDbi_1.50.3   htmlwidgets_1.5.1      BiocParallel_1.22.0   
  [6] munsell_0.5.0          codetools_0.2-16       preprocessCore_1.50.0  statmod_1.4.34         withr_2.3.0           
 [11] colorspace_1.4-1       knitr_1.30             rstudioapi_0.11        ggsignif_0.6.0         labeling_0.3          
 [16] GenomeInfoDbData_1.2.3 farver_2.0.3           bit64_4.0.5            pheatmap_1.0.12        rhdf5_2.32.3          
 [21] vctrs_0.3.4            generics_0.0.2         xfun_0.18              BiocFileCache_1.12.1   R6_2.4.1              
 [26] doParallel_1.0.15      ggbeeswarm_0.6.0       clue_0.3-57            locfit_1.5-9.4         bitops_1.0-6          
 [31] assertthat_0.2.1       scales_1.1.1           nnet_7.3-14            beeswarm_0.2.3         gtable_0.3.0          
 [36] rlang_0.4.7            genefilter_1.70.0      GlobalOptions_0.1.2    splines_4.0.2          rstatix_0.6.0         
 [41] impute_1.62.0          broom_0.7.1            checkmate_2.0.0        BiocManager_1.30.10    yaml_2.2.1            
 [46] reshape2_1.4.4         abind_1.4-5            modelr_0.1.8           backports_1.1.10       Hmisc_4.4-1           
 [51] tools_4.0.2            ellipsis_0.3.1         RColorBrewer_1.1-2     Rcpp_1.0.5             plyr_1.8.6            
 [56] base64enc_0.1-3        progress_1.2.2         zlibbioc_1.34.0        RCurl_1.98-1.2         prettyunits_1.1.1     
 [61] openssl_1.4.3          rpart_4.1-15           GetoptLong_1.0.3       cowplot_1.1.0          haven_2.3.1           
 [66] ggrepel_0.8.2          cluster_2.1.0          fs_1.5.0               magrittr_1.5           data.table_1.13.0     
 [71] RSpectra_0.16-0        openxlsx_4.2.2         reprex_0.3.0           hms_0.5.3              evaluate_0.14         
 [76] xtable_1.8-4           XML_3.99-0.5           rio_0.5.16             jpeg_0.1-8.1           readxl_1.3.1          
 [81] shape_1.4.5            compiler_4.0.2         ellipse_0.4.2          crayon_1.3.4           minqa_1.2.4           
 [86] htmltools_0.5.0        mgcv_1.8-33            corpcor_1.6.9          Formula_1.2-3          geneplotter_1.66.0    
 [91] lubridate_1.7.9        DBI_1.1.0              dbplyr_1.4.4           rappdirs_0.3.1         boot_1.3-25           
 [96] car_3.0-10             cli_2.0.2              igraph_1.2.5           pkgconfig_2.0.3        foreign_0.8-80        
[101] xml2_1.3.2             foreach_1.5.0          rARPACK_0.11-0         annotate_1.66.0        vipor_0.4.5           
[106] XVector_0.28.0         rvest_0.3.6            digest_0.6.25          rmarkdown_2.4          cellranger_1.1.0      
[111] curl_4.3               nloptr_1.2.2.2         rjson_0.2.20           lifecycle_0.2.0        jsonlite_1.7.1        
[116] Rhdf5lib_1.10.1        carData_3.0-4          askpass_1.1            fansi_0.4.1            pillar_1.4.6          
[121] httr_1.4.2             survival_3.2-7         GO.db_3.11.4           glue_1.4.2             zip_2.1.1             
[126] png_0.1-7              iterators_1.0.12       bit_4.0.4              stringi_1.5.3          HDF5Array_1.16.1      
[131] blob_1.2.1             latticeExtra_0.6-29    memoise_1.1.0         
jokergoo commented 3 years ago

Maybe try to install the newest versions of all my packages:

library(devtools)
install_github("jokergoo/ComplexHeatmap")
install_github("jokergoo/circlize")
install_github("jokergoo/GlobalOptions")

Probably some inconsistency between the different versions.

santiiiiiii commented 3 years ago

This error pops up when I tried the above.

Error: package or namespace load failed for ‘ComplexHeatmap’ in get(method, envir = home): lazy-load database '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/circlize/R/circlize.rdb' is corrupt

santiiiiiii commented 3 years ago

I think it is just my R. All working now, when I re-booted. Thank you

jokergoo commented 3 years ago

This kind of error is mainly because you installed a package that was under using in your R session. Yes, just restart your R session.