Open mhlinder opened 6 years ago
I am also having this problem.
I think something happened when the commits from April 16, 2018, or Aug 19, 2018 (bfbe67e2e8c5198ccf77892e381304f8bae96e10 29e165e31eb23c546c47db34e419fab500ad6970 b33a5ba5d1c4bbb00b07b9436a7fe8956dcc51e0 0791ac23c5f7d40af2769d396de4b7ed54e3e200) were applied to the master branch. I restarted a new R session, and installed an older version of NMF before those commits:
library(devtools)
install_github("renozao/NMF#61")
Then your code works correctly:
library(NMF)
set.seed(20181003)
x <- matrix(rnorm(400), 20)
range(x)
breaks <- seq(-4, 4, length.out=101)
cols <- colorRampPalette(c("white", "red"))(100)
pdf("heatmap.pdf", width = 12, height = 4, onefile = FALSE)
par(mfrow=c(1,3))
aheatmap(x, Rowv=NA, Colv=NA, color=cols)
aheatmap(x, Rowv=NA, Colv=NA, breaks=breaks)
aheatmap(x, Rowv=NA, Colv=NA, breaks=breaks, color=cols)
dev.off()
However, please note that if you install the GitHub version #61 (see my comment above), the ward clustering method is wrong, as described here: https://github.com/renozao/NMF/issues/117
The color breaks problem appears to be solved. I'm not sure when this got resolved.
# Install the latest version from GitHub
# remotes::install_github("renozao/NMF@d02eba9")
library(NMF)
set.seed(20181003)
x <- matrix(rnorm(400), 20)
range(x)
breaks <- seq(-4, 4, length.out=101)
cols <- colorRampPalette(c("white", "red"))(100)
pdf("heatmap.pdf", width = 12, height = 4, onefile = FALSE)
par(mfrow=c(1,3))
aheatmap(x, Rowv=NA, Colv=NA, color=cols)
aheatmap(x, Rowv=NA, Colv=NA, breaks=breaks)
aheatmap(x, Rowv=NA, Colv=NA, breaks=breaks, color=cols)
dev.off()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)
Matrix products: default
BLAS/LAPACK: /panfs/roc/groups/0/lmnp/knut0297/software/modules/openblas/0.3.13/build/lib/libopenblas_zenp-r0.3.13.dev.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] RColorBrewer_1.1-2 NMF_0.30.1 Biobase_2.50.0
[4] BiocGenerics_0.36.0 cluster_2.1.0 rngtools_1.5
[7] pkgmaker_0.32.2 registry_0.5-1
loaded via a namespace (and not attached):
[1] tidyselect_1.1.0 remotes_2.2.0 purrr_0.3.4 reshape2_1.4.4
[5] colorspace_2.0-0 vctrs_0.3.6 generics_0.1.0 viridisLite_0.3.0
[9] rlang_0.4.10 pkgbuild_1.2.0 pillar_1.4.7 glue_1.4.2
[13] withr_2.3.0 DBI_1.1.0 foreach_1.5.1 lifecycle_0.2.0
[17] plyr_1.8.6 stringr_1.4.0 munsell_0.5.0 gtable_0.3.0
[21] codetools_0.2-16 callr_3.5.1 doParallel_1.0.16 ps_1.5.0
[25] curl_4.3 fansi_0.4.2 Rcpp_1.0.6 xtable_1.8-4
[29] scales_1.1.1 gridExtra_2.3 ggplot2_3.3.3 digest_0.6.27
[33] stringi_1.5.3 processx_3.4.5 dplyr_1.0.3 rprojroot_2.0.2
[37] grid_4.0.3 cli_2.2.0 tools_4.0.3 magrittr_2.0.1
[41] tibble_3.0.5 crayon_1.3.4 pkgconfig_2.0.3 dendextend_1.14.0
[45] ellipsis_0.3.1 gridBase_0.4-7 prettyunits_1.1.1 assertthat_0.2.1
[49] viridis_0.5.1 iterators_1.0.13 R6_2.5.0 compiler_4.0.3
Often, I calculate a set of breaks, and a custom color palette.
Just as often, it works to use only the breaks, or only the color palette.
But, when I use both together,
aheatmap
seems to run out of colors, and recycles them—definitely not working!Code below and image attached.