Skip to content

[BUG] ComplexHeatmap panel scrambles annotation colors #549

Closed

Description

@csoneson

Describe the bug
Annotation colors are sometimes scrambled in ComplexHeatmap panels compared to other panels

To Reproduce

library(iSEE)
sce <- scRNAseq::ReprocessedAllenData(assays="tophat_counts")
sce <- scater::logNormCounts(sce, exprs_values="tophat_counts")
core_color_fun <- function(n){
    core_colors <- c("forestgreen", "firebrick1")
    names(core_colors) <- c("Core", "Intermediate")
    core_colors
}
ecm <- ExperimentColorMap(colData = list(Core.Type = core_color_fun))
iSEE(sce, colormap = ecm, initial = list(ComplexHeatmapPlot(PanelWidth = 6L, ColumnData = "Core.Type")))

-> Annotation colors are not mapped correctly to categories. The same issue arises when no color map is explicitly specified (although in this case it's not really 'incorrectly' mapped, just potentially differently from the other panels).

Expected behavior
Annotation colors should be those specified in the ECM, and consistent between panels.

Desktop (please complete the following information):

  • OS: macOS Catalina
  • Browser: RStudio browser

Additional context
I think the issue arises because of

'names(.col_colors) <- unique(.color_values)',

which I think is not needed - if the output from the step above is named we want to keep it like that, and otherwise it should follow the factor levels rather than the order of appearance in the vector. I wanted to check though whether I'm missing some subtleties here.

Session info
> sessionInfo()
R Under development (unstable) (2021-02-07 r79964)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

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.1/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] parallel  stats4    stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] shiny_1.6.0                  scRNAseq_2.5.7              
 [3] iSEE_2.3.9                   SingleCellExperiment_1.13.12
 [5] SummarizedExperiment_1.21.1  Biobase_2.51.0              
 [7] GenomicRanges_1.43.3         GenomeInfoDb_1.27.6         
 [9] IRanges_2.25.6               S4Vectors_0.29.7            
[11] BiocGenerics_0.37.1          MatrixGenerics_1.3.1        
[13] matrixStats_0.58.0          

loaded via a namespace (and not attached):
  [1] circlize_0.4.12               AnnotationHub_2.23.2         
  [3] BiocFileCache_1.15.1          igraph_1.2.6                 
  [5] lazyeval_0.2.2                shinydashboard_0.7.1         
  [7] splines_4.1.0                 BiocParallel_1.25.4          
  [9] scater_1.19.11                ggplot2_3.3.3                
 [11] digest_0.6.27                 foreach_1.5.1                
 [13] ensembldb_2.15.2              htmltools_0.5.1.1            
 [15] viridis_0.5.1                 fansi_0.4.2                  
 [17] magrittr_2.0.1                memoise_2.0.0                
 [19] ScaledMatrix_0.99.2           cluster_2.1.1                
 [21] doParallel_1.0.16             ComplexHeatmap_2.7.7         
 [23] Biostrings_2.59.2             askpass_1.1                  
 [25] prettyunits_1.1.1             colorspace_2.0-0             
 [27] blob_1.2.1                    rappdirs_0.3.3               
 [29] ggrepel_0.9.1                 dplyr_1.0.5                  
 [31] crayon_1.4.1                  RCurl_1.98-1.2               
 [33] jsonlite_1.7.2                iterators_1.0.13             
 [35] glue_1.4.2                    gtable_0.3.0                 
 [37] zlibbioc_1.37.0               XVector_0.31.1               
 [39] GetoptLong_1.0.5              DelayedArray_0.17.9          
 [41] BiocSingular_1.7.2            shape_1.4.5                  
 [43] scales_1.1.1                  DBI_1.1.1                    
 [45] miniUI_0.1.1.1                Rcpp_1.0.6                   
 [47] viridisLite_0.3.0             xtable_1.8-4                 
 [49] progress_1.2.2                clue_0.3-58                  
 [51] rsvd_1.0.3                    bit_4.0.4                    
 [53] DT_0.17                       htmlwidgets_1.5.3            
 [55] httr_1.4.2                    RColorBrewer_1.1-2           
 [57] shinyAce_0.4.1                ellipsis_0.3.1               
 [59] scuttle_1.1.18                pkgconfig_2.0.3              
 [61] XML_3.99-0.5                  sass_0.3.1                   
 [63] dbplyr_2.1.0                  utf8_1.1.4                   
 [65] tidyselect_1.1.0              rlang_0.4.10                 
 [67] later_1.1.0.1                 AnnotationDbi_1.53.1         
 [69] munsell_0.5.0                 BiocVersion_3.13.1           
 [71] tools_4.1.0                   cachem_1.0.4                 
 [73] generics_0.1.0                RSQLite_2.2.3                
 [75] ExperimentHub_1.17.1          rintrojs_0.2.2               
 [77] stringr_1.4.0                 fastmap_1.1.0                
 [79] yaml_2.2.1                    bit64_4.0.5                  
 [81] purrr_0.3.4                   KEGGREST_1.31.1              
 [83] AnnotationFilter_1.15.0       sparseMatrixStats_1.3.6      
 [85] nlme_3.1-152                  mime_0.10                    
 [87] xml2_1.3.2                    biomaRt_2.47.5               
 [89] compiler_4.1.0                rstudioapi_0.13              
 [91] beeswarm_0.3.1                filelock_1.0.2               
 [93] curl_4.3                      png_0.1-7                    
 [95] interactiveDisplayBase_1.29.0 tibble_3.1.0                 
 [97] bslib_0.2.4                   stringi_1.5.3                
 [99] GenomicFeatures_1.43.4        lattice_0.20-41              
[101] ProtGenerics_1.23.7           Matrix_1.3-2                 
[103] shinyjs_2.0.0                 vctrs_0.3.6                  
[105] pillar_1.5.1                  lifecycle_1.0.0              
[107] BiocManager_1.30.10           jquerylib_0.1.3              
[109] GlobalOptions_0.1.2           BiocNeighbors_1.9.4          
[111] irlba_2.3.3                   bitops_1.0-6                 
[113] httpuv_1.5.5                  rtracklayer_1.51.5           
[115] R6_2.5.0                      BiocIO_1.1.2                 
[117] promises_1.2.0.1              gridExtra_2.3                
[119] vipor_0.4.5                   codetools_0.2-18             
[121] colourpicker_1.1.0            assertthat_0.2.1             
[123] openssl_1.4.3                 rjson_0.2.20                 
[125] withr_2.4.1                   shinyWidgets_0.5.7           
[127] GenomicAlignments_1.27.2      Rsamtools_2.7.1              
[129] GenomeInfoDbData_1.2.4        mgcv_1.8-34                  
[131] hms_1.0.0                     beachmat_2.7.7               
[133] grid_4.1.0                    DelayedMatrixStats_1.13.5    
[135] Cairo_1.5-12.2                ggbeeswarm_0.6.0             
[137] restfulr_0.0.13   

Activity

  1. csoneson commented on Sep 2, 2024

    @csoneson
    MemberAuthor

    Closed as fixed by #556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions