jokergoo / EnrichedHeatmap

make enriched heatmap which visualizes the enrichment of genomic signals to specific target regions.
http://jokergoo.github.io/EnrichedHeatmap/
Other
186 stars 25 forks source link

extend and w not working for categorical data #29

Closed crazyhottommy closed 6 years ago

crazyhottommy commented 6 years ago

Hi Zuguang,

library(EnrichedHeatmap)
library(GenomicFeatures)

load(system.file("extdata", "chr21_chromatin_states.RData", package = "EnrichedHeatmap"))
load(system.file("extdata", "chr21_test_data.RData", package = "EnrichedHeatmap"))

state_col = c("TssActive" = "#FF0000", "Transcript" = "#008000", "Enhancer" = "#C2E105",
        "Heterochromatin" = "#8A91D0", "TssBiv" = "#CD5C5C",
        "Repressive" = "#808080", "Quies" = "#000000")

tss = promoters(genes, upstream = 0, downstream = 1)
mat = normalizeToMatrix(states, tss, value_column = "states_simplified", extend = 10000, w = 200)

# it should be 100 columns. 2* extend/w = 2* 50 = 100
> dim(mat)
[1] 720  50

> devtools::session_info()
Session info -----------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.2 (2017-09-28)
 system   x86_64, darwin15.6.0        
 ui       RStudio (1.0.153)           
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/Chicago             
 date     2018-03-26                  

Packages ---------------------------------------------------------------------------------------------------------
 package              * version    date       source                                   
 AnnotationDbi        * 1.38.2     2017-07-27 cran (@1.38.2)                           
 base                 * 3.4.2      2017-10-04 local                                    
 Biobase              * 2.36.2     2017-05-04 cran (@2.36.2)                           
 BiocGenerics         * 0.22.1     2017-10-07 cran (@0.22.1)                           
 BiocParallel           1.10.1     2017-05-03 cran (@1.10.1)                           
 biomaRt                2.32.1     2017-06-09 cran (@2.32.1)                           
 Biostrings             2.44.2     2017-07-21 cran (@2.44.2)                           
 bit                    1.1-12     2014-04-09 cran (@1.1-12)                           
 bit64                  0.9-7      2017-05-08 cran (@0.9-7)                            
 bitops                 1.0-6      2013-08-17 cran (@1.0-6)                            
 blob                   1.1.0      2017-06-17 cran (@1.1.0)                            
 circlize               0.4.3      2017-12-20 cran (@0.4.3)                            
 colorspace             1.3-2      2016-12-14 cran (@1.3-2)                            
 compiler               3.4.2      2017-10-04 local                                    
 ComplexHeatmap       * 1.17.1     2017-10-25 Github (jokergoo/ComplexHeatmap@acc87df) 
 datasets             * 3.4.2      2017-10-04 local                                    
 DBI                    0.7        2017-06-18 cran (@0.7)                              
 DelayedArray           0.2.7      2017-06-03 cran (@0.2.7)                            
 devtools               1.13.3     2017-08-02 CRAN (R 3.4.1)                           
 digest                 0.6.15     2018-01-28 cran (@0.6.15)                           
 EnrichedHeatmap      * 1.9.2      2017-11-24 Github (jokergoo/EnrichedHeatmap@1ec8279)
 GenomeInfoDb         * 1.12.3     2017-10-05 cran (@1.12.3)                           
 GenomeInfoDbData       0.99.0     2017-10-09 Bioconductor                             
 GenomicAlignments      1.12.2     2017-08-19 cran (@1.12.2)                           
 GenomicFeatures      * 1.28.5     2017-09-20 cran (@1.28.5)                           
 GenomicRanges        * 1.28.6     2017-10-04 cran (@1.28.6)                           
 GetoptLong             0.1.6      2017-03-07 cran (@0.1.6)                            
 GlobalOptions          0.0.12     2017-05-21 cran (@0.0.12)                           
 graphics             * 3.4.2      2017-10-04 local                                    
 grDevices            * 3.4.2      2017-10-04 local                                    
 grid                 * 3.4.2      2017-10-04 local                                    
 IRanges              * 2.10.5     2017-10-08 cran (@2.10.5)                           
 lattice                0.20-35    2017-03-25 CRAN (R 3.4.2)                           
 locfit               * 1.5-9.1    2013-04-20 CRAN (R 3.4.0)                           
 Matrix                 1.2-11     2017-08-21 CRAN (R 3.4.2)                           
 matrixStats            0.53.1     2018-02-11 cran (@0.53.1)                           
 memoise                1.1.0      2017-04-21 CRAN (R 3.4.0)                           
 methods              * 3.4.2      2017-10-04 local                                    
 parallel             * 3.4.2      2017-10-04 local                                    
 pillar                 1.2.1      2018-02-27 cran (@1.2.1)                            
 RColorBrewer           1.1-2      2014-12-07 cran (@1.1-2)                            
 Rcpp                   0.12.15    2018-01-20 cran (@0.12.15)                          
 RCurl                  1.95-4.8   2016-03-01 cran (@1.95-4.)                          
 rjson                  0.2.15     2014-11-03 cran (@0.2.15)                           
 rlang                  0.2.0      2018-02-20 CRAN (R 3.4.3)                           
 Rsamtools              1.28.0     2017-04-25 cran (@1.28.0)                           
 RSQLite                2.0        2017-06-19 cran (@2.0)                              
 rtracklayer            1.36.5     2017-10-04 cran (@1.36.5)                           
 S4Vectors            * 0.14.7     2017-10-08 cran (@0.14.7)                           
 shape                  1.4.4      2018-02-07 cran (@1.4.4)                            
 stats                * 3.4.2      2017-10-04 local                                    
 stats4               * 3.4.2      2017-10-04 local                                    
 SummarizedExperiment   1.6.5      2017-09-29 cran (@1.6.5)                            
 tibble                 1.4.2      2018-01-22 cran (@1.4.2)                            
 tools                  3.4.2      2017-10-04 local                                    
 utils                * 3.4.2      2017-10-04 local                                    
 withr                  2.1.1.9000 2018-03-05 Github (jimhester/withr@5d05571)         
 XML                    3.98-1.9   2017-06-19 cran (@3.98-1.)                          
 XVector                0.16.0     2017-04-25 cran (@0.16.0)                           
 zlibbioc               1.22.0     2017-04-25 cran (@1.22.0)   

Thanks for looking into it.

Tommy

jokergoo commented 6 years ago

I fixed this bug one week ago. Please update the package.

> mat = normalizeToMatrix(states, tss, value_column = "states_simplified", extend = 10000, w = 200)
> mat
Normalize states to tss:
  Upstream 10000 bp (50 windows)
  Downstream 10000 bp (50 windows)
  Include target regions (width = 1)
  720 target regions
  signal is categorical (7 levels)
> dim(mat)
[1] 720 100
crazyhottommy commented 6 years ago

Thanks! this is working. but somehow the top_annotation is added automatically even if I did not specify it and the legend is showing the numbers 1,2,...15 rather than the names:e.g. Active TSS.

map = c(
    "E1"  = "Active TSS",
    "E2"  = "Flanking Active TSS",
    "E3"  = "Transcr. at gene 5\' and 3\'",
    "E4"  = "Strong transcription",
    "E5"  = "Weak transcription",
    "E6"  =  "Genic enhancers",
    "E7"  = "Active enhancers",
    "E8"  = "Trivalent/poised TSS",
    "E9"  = "Bivalent/poised TSS",
    "E10" = "Repressed TSS/Enh",
    "E11" = "Repressed Polycomb",
    "E12" = "Low",
    "E13" = "Artifacts"
)

> devtools::session_info()
Session info -----------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.2 (2017-09-28)
 system   x86_64, darwin15.6.0        
 ui       RStudio (1.0.153)           
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/Chicago             
 date     2018-05-07                  

Packages ---------------------------------------------------------------------------------------------------------
 package              * version    date       source                                   
 assertthat             0.2.0      2017-04-11 cran (@0.2.0)                            
 base                 * 3.4.2      2017-10-04 local                                    
 bindr                  0.1        2016-11-13 cran (@0.1)                              
 bindrcpp               0.2        2017-06-17 cran (@0.2)                              
 Biobase                2.36.2     2017-05-04 cran (@2.36.2)                           
 BiocGenerics         * 0.22.1     2017-10-07 cran (@0.22.1)                           
 BiocParallel           1.10.1     2017-05-03 cran (@1.10.1)                           
 Biostrings             2.44.2     2017-07-21 cran (@2.44.2)                           
 bitops                 1.0-6      2013-08-17 cran (@1.0-6)                            
 circlize               0.4.3      2017-12-20 cran (@0.4.3)                            
 cli                    1.0.0      2017-11-05 CRAN (R 3.4.2)                           
 colorspace             1.3-2      2016-12-14 cran (@1.3-2)                            
 compiler               3.4.2      2017-10-04 local                                    
 ComplexHeatmap       * 1.17.1     2017-10-25 Github (jokergoo/ComplexHeatmap@de010e6) 
 crayon                 1.3.4      2017-09-16 CRAN (R 3.4.1)                           
 datasets             * 3.4.2      2017-10-04 local                                    
 DelayedArray           0.2.7      2017-06-03 cran (@0.2.7)                            
 devtools               1.13.3     2017-08-02 CRAN (R 3.4.1)                           
 digest                 0.6.15     2018-01-28 cran (@0.6.15)                           
 dplyr                  0.7.4      2017-09-28 cran (@0.7.4)                            
 EnrichedHeatmap      * 1.9.4      2018-04-06 Github (jokergoo/EnrichedHeatmap@0411ef1)
 GenomeInfoDb         * 1.12.3     2017-10-05 cran (@1.12.3)                           
 GenomeInfoDbData       0.99.0     2017-10-09 Bioconductor                             
 GenomicAlignments      1.12.2     2017-08-19 cran (@1.12.2)                           
 GenomicRanges        * 1.28.6     2017-10-04 cran (@1.28.6)                           
 GetoptLong             0.1.6      2017-03-07 cran (@0.1.6)                            
 GlobalOptions          0.0.13     2018-03-15 cran (@0.0.13)                           
 glue                   1.2.0      2017-10-29 cran (@1.2.0)                            
 graphics             * 3.4.2      2017-10-04 local                                    
 grDevices            * 3.4.2      2017-10-04 local                                    
 grid                 * 3.4.2      2017-10-04 local                                    
 hms                    0.3        2016-11-22 CRAN (R 3.4.0)                           
 IRanges              * 2.10.5     2017-10-08 cran (@2.10.5)                           
 lattice                0.20-35    2017-03-25 CRAN (R 3.4.2)                           
 locfit                 1.5-9.1    2013-04-20 CRAN (R 3.4.0)                           
 magrittr               1.5        2014-11-22 cran (@1.5)                              
 Matrix                 1.2-11     2017-08-21 CRAN (R 3.4.2)                           
 matrixStats            0.53.1     2018-02-11 cran (@0.53.1)                           
 memoise                1.1.0      2017-04-21 CRAN (R 3.4.0)                           
 methods              * 3.4.2      2017-10-04 local                                    
 parallel             * 3.4.2      2017-10-04 local                                    
 pillar                 1.2.1      2018-02-27 cran (@1.2.1)                            
 pkgconfig              2.0.1      2017-03-21 cran (@2.0.1)                            
 png                    0.1-7      2013-12-03 CRAN (R 3.4.0)                           
 R6                     2.2.2      2017-06-17 CRAN (R 3.4.0)                           
 RColorBrewer           1.1-2      2014-12-07 cran (@1.1-2)                            
 Rcpp                   0.12.16    2018-03-13 cran (@0.12.16)                          
 RCurl                  1.95-4.8   2016-03-01 cran (@1.95-4.)                          
 readr                * 1.1.1      2017-05-16 CRAN (R 3.4.0)                           
 rjson                  0.2.15     2014-11-03 cran (@0.2.15)                           
 rlang                  0.2.0      2018-02-20 CRAN (R 3.4.3)                           
 Rsamtools              1.28.0     2017-04-25 cran (@1.28.0)                           
 rstudioapi             0.7        2017-09-07 CRAN (R 3.4.1)                           
 rtracklayer          * 1.36.5     2017-10-04 cran (@1.36.5)                           
 S4Vectors            * 0.14.7     2017-10-08 cran (@0.14.7)                           
 shape                  1.4.4      2018-02-07 cran (@1.4.4)                            
 stats                * 3.4.2      2017-10-04 local                                    
 stats4               * 3.4.2      2017-10-04 local                                    
 SummarizedExperiment   1.6.5      2017-09-29 cran (@1.6.5)                            
 tibble                 1.4.2      2018-01-22 cran (@1.4.2)                            
 tools                  3.4.2      2017-10-04 local                                    
 utf8                   1.1.3      2018-01-03 cran (@1.1.3)                            
 utils                * 3.4.2      2017-10-04 local                                    
 withr                  2.1.1.9000 2018-03-05 Github (jimhester/withr@5d05571)         
 XML                    3.98-1.9   2017-06-19 cran (@3.98-1.)                          
 XVector                0.16.0     2017-04-25 cran (@0.16.0)                           
 zlibbioc               1.22.0     2017-04-25 cran (@1.22.0)                           
jokergoo commented 6 years ago

I am sorry for the late reply. I am on a long vocation.

That was a bug I recently made. Now I have updated the package and please update it.

From some version of the package (I cannot remember which), the top annotation is added by default. You can turn it off by setting top_annotation = NULL.

crazyhottommy commented 6 years ago

Thx!