-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Heatmap crashes when we have a variable with 33 unique values #588
Comments
Quick thought: have you tried converting the character vector to a factor? This is what iSEE should be doing it automatically, but maybe giving it a nudge yourself might help. |
Yes, we’ve tried it with it as a factor. Not for this toy example but with
our real data. Same error.
On Thu, Jul 21, 2022 at 4:10 AM Kevin Rue-Albrecht ***@***.***> wrote:
Quick thought: have you tried converting the character vector to a factor?
This is what iSEE should be doing it automatically, but maybe giving it a
nudge yourself might help.
—
Reply to this email directly, view it on GitHub
<#588 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAROUVI72KS6TVYX2IWBBLLVVEAWNANCNFSM54AUK5DQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Leonardo Collado Torres, Ph. D.
Investigator
LIEBER INSTITUTE *for* BRAIN DEVELOPMENT
855 N. Wolfe St., Suite 300
Baltimore, MD 21205
lcolladotor.github.io
***@***.***
|
Ah I got it, sce <- registerAppOptions(sce, color.maxlevels = 33) It tells iSEE that discrete covariates (e.g., character, factor) are "colorable" up until 33 distinct levels (change as needed for other data sets). That said, instead of crashing, I remember iSEE was supposed to convert those "excessive" discrete covariate to numeric, but perhaps we dropped that, I need to check. Actually, here's the full script that I used to test. It also limits the app to only a heatmap panel, to speed up the rendering: library("iSEE")
library(scRNAseq)
# Example data ----
sce <- ReprocessedAllenData(assays="tophat_counts")
class(sce)
library(scater)
sce <- logNormCounts(sce, exprs_values="tophat_counts")
sce <- runPCA(sce, ncomponents=4)
sce <- runTSNE(sce)
rowData(sce)$ave_count <- rowMeans(assay(sce, "tophat_counts"))
rowData(sce)$n_cells <- rowSums(assay(sce, "tophat_counts") > 0)
sce
set.seed(20220719)
sce$cellType.final <- sample(paste0("cell_", seq_len(33)), ncol(sce), replace = TRUE)
stopifnot(length(unique(sce$cellType.final)) == 33)
# initial panels ----
initial <- list(
ComplexHeatmapPlot(PanelWidth = 6L)
)
# App options ---
sce <- registerAppOptions(sce, color.maxlevels = 33)
getAppOption("color.maxlevels", sce)
# launch the app itself ----
app <- iSEE(sce, initial = initial)
if (interactive()) {
shiny::runApp(app, port=1234, launch.browser = TRUE)
} Let me know how that goes! |
Thanks Kevin! It does work without the library("iSEE")
library(scRNAseq)
# Example data ----
sce <- ReprocessedAllenData(assays="tophat_counts")
class(sce)
library(scater)
sce <- logNormCounts(sce, exprs_values="tophat_counts")
sce <- runPCA(sce, ncomponents=4)
sce <- runTSNE(sce)
rowData(sce)$ave_count <- rowMeans(assay(sce, "tophat_counts"))
rowData(sce)$n_cells <- rowSums(assay(sce, "tophat_counts") > 0)
sce
set.seed(20220719)
sce$cellType.final <- factor(sample(paste0("cell_", seq_len(33)), ncol(sce), replace = TRUE))
stopifnot(length(unique(sce$cellType.final)) == 33)
# launch the app itself ----
sce <- registerAppOptions(sce, color.maxlevels = 33)
app <- iSEE(sce)
if (interactive()) {
shiny::runApp(app, port=1234)
} However, I get an error when trying it with the ## Try again with an ExperimentColorMap
iSEE(sce, colormap = ExperimentColorMap(colData = list(
driver_1_s = function(n) {
driver_colors <- c("red", "blue", "black")
names(driver_colors) <- unique(sce$driver_1_s)
return(driver_colors)
},
cellType.final = function(n) {
cols <- paletteer::paletteer_d(
palette = "Polychrome::palette36",
n = length(unique(sce$cellType.final))
)
names(cols) <- levels(sce$cellType.final)
return(cols)
}
))) Warning: Error in : either provide `levels` or provide named `colors`.
3: runApp
2: print.shiny.appobj
1: <Anonymous>
Warning: Error in : either provide `levels` or provide named `colors`.
185: stop
184: stop_wrap
183: ColorMapping
182: <Anonymous>
180: HeatmapAnnotation
179: ComplexHeatmap::columnAnnotation
178: eval [<text>#8]
177: eval
176: .textEval
175: .process_heatmap_column_annotations_colorscale
174: .local
173: .generateOutput
171: .retrieveOutput
170: renderPlot
168: func
128: drawPlot
114: <reactive:plotObj>
98: drawReactive
85: renderFunc
84: output$ComplexHeatmapPlot1
3: runApp
2: print.shiny.appobj
1: <Anonymous> > cols <- paletteer::paletteer_d(
+ palette = "Polychrome::palette36",
+ n = length(unique(sce$cellType.final))
+ )
> names(cols) <- levels(sce$cellType.final)
> cols
<colors>
#5A5156FF #E4E1E3FF #F6222EFF #FE00FAFF #16FF32FF #3283FEFF #FEAF16FF #B00068FF #1CFFCEFF #90AD1CFF #2ED9FFFF #DEA0FDFF #AA0DFEFF #F8A19FFF #325A9BFF #C4451CFF #1C8356FF #85660DFF #B10DA1FF #FBE426FF #1CBE4FFF #FA0087FF #FC1CBFFF #F7E1A0FF #C075A6FF #782AB6FF #AAF400FF #BDCDFFFF #822E1CFF #B5EFB5FF #7ED7D1FF #1C7F93FF #D85FF7FF
> names(cols)
[1] "cell_1" "cell_10" "cell_11" "cell_12" "cell_13" "cell_14" "cell_15" "cell_16" "cell_17" "cell_18" "cell_19"
[12] "cell_2" "cell_20" "cell_21" "cell_22" "cell_23" "cell_24" "cell_25" "cell_26" "cell_27" "cell_28" "cell_29"
[23] "cell_3" "cell_30" "cell_31" "cell_32" "cell_33" "cell_4" "cell_5" "cell_6" "cell_7" "cell_8" "cell_9"
> stopifnot(identical(names(cols), levels(sce$cellType.final))) Ahh, but casting it to a > cols <- as.vector(cols)
> names(cols) <- levels(sce$cellType.final)
> cols
cell_1 cell_10 cell_11 cell_12 cell_13 cell_14 cell_15 cell_16 cell_17 cell_18
"#5A5156FF" "#E4E1E3FF" "#F6222EFF" "#FE00FAFF" "#16FF32FF" "#3283FEFF" "#FEAF16FF" "#B00068FF" "#1CFFCEFF" "#90AD1CFF"
cell_19 cell_2 cell_20 cell_21 cell_22 cell_23 cell_24 cell_25 cell_26 cell_27
"#2ED9FFFF" "#DEA0FDFF" "#AA0DFEFF" "#F8A19FFF" "#325A9BFF" "#C4451CFF" "#1C8356FF" "#85660DFF" "#B10DA1FF" "#FBE426FF"
cell_28 cell_29 cell_3 cell_30 cell_31 cell_32 cell_33 cell_4 cell_5 cell_6
"#1CBE4FFF" "#FA0087FF" "#FC1CBFFF" "#F7E1A0FF" "#C075A6FF" "#782AB6FF" "#AAF400FF" "#BDCDFFFF" "#822E1CFF" "#B5EFB5FF"
cell_7 cell_8 cell_9
"#7ED7D1FF" "#1C7F93FF" "#D85FF7FF" ## Try again with an ExperimentColorMap
iSEE(sce, colormap = ExperimentColorMap(colData = list(
driver_1_s = function(n) {
driver_colors <- c("red", "blue", "black")
names(driver_colors) <- unique(sce$driver_1_s)
return(driver_colors)
},
cellType.final = function(n) {
cols <- paletteer::paletteer_d(
palette = "Polychrome::palette36",
n = length(unique(sce$cellType.final))
)
cols <- as.vector(cols)
names(cols) <- levels(sce$cellType.final)
return(cols)
}
))) Thanks again! > options(width = 120)
> sessioninfo::session_info()
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 4.2.1 (2022-06-23)
os macOS Monterey 12.4
system aarch64, darwin20
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/New_York
date 2022-07-25
rstudio 2022.07.0+548 Spotted Wakerobin (desktop)
pandoc 2.17.1.1 @ /opt/homebrew/bin/pandoc
─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
AnnotationDbi 1.58.0 2022-04-26 [1] Bioconductor
AnnotationFilter 1.20.0 2022-04-26 [1] Bioconductor
AnnotationHub 3.4.0 2022-04-26 [1] Bioconductor
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.2.0)
beachmat 2.12.0 2022-04-26 [1] Bioconductor
beeswarm 0.4.0 2021-06-01 [1] CRAN (R 4.2.0)
Biobase * 2.56.0 2022-04-26 [1] Bioconductor
BiocFileCache 2.4.0 2022-04-26 [1] Bioconductor
BiocGenerics * 0.42.0 2022-04-26 [1] Bioconductor
BiocIO 1.6.0 2022-04-26 [1] Bioconductor
BiocManager 1.30.18 2022-05-18 [1] CRAN (R 4.2.0)
BiocNeighbors 1.14.0 2022-04-26 [1] Bioconductor
BiocParallel 1.30.3 2022-06-05 [1] Bioconductor
BiocSingular 1.12.0 2022-04-26 [1] Bioconductor
BiocVersion 3.15.2 2022-03-29 [1] Bioconductor
biomaRt 2.52.0 2022-04-26 [1] Bioconductor
Biostrings 2.64.0 2022-04-26 [1] Bioconductor
bit 4.0.4 2020-08-04 [1] CRAN (R 4.2.0)
bit64 4.0.5 2020-08-30 [1] CRAN (R 4.2.0)
bitops 1.0-7 2021-04-24 [1] CRAN (R 4.2.0)
blob 1.2.3 2022-04-10 [1] CRAN (R 4.2.0)
brio 1.1.3 2021-11-30 [1] CRAN (R 4.2.0)
bslib 0.4.0 2022-07-16 [1] CRAN (R 4.2.0)
cachem 1.0.6 2021-08-19 [1] CRAN (R 4.2.0)
callr 3.7.1 2022-07-13 [1] CRAN (R 4.2.1)
circlize 0.4.15 2022-05-10 [1] CRAN (R 4.2.0)
cli 3.3.0 2022-04-25 [1] CRAN (R 4.2.0)
clue 0.3-61 2022-05-30 [1] CRAN (R 4.2.0)
cluster 2.1.3 2022-03-28 [1] CRAN (R 4.2.1)
codetools 0.2-18 2020-11-04 [1] CRAN (R 4.2.1)
colorout 1.2-2 2022-03-01 [1] Github (jalvesaq/colorout@79931fd)
colorspace 2.0-3 2022-02-21 [1] CRAN (R 4.2.0)
colourpicker 1.1.1 2021-10-04 [1] CRAN (R 4.2.0)
ComplexHeatmap 2.12.0 2022-04-26 [1] Bioconductor
crayon 1.5.1 2022-03-26 [1] CRAN (R 4.2.0)
crosstalk 1.2.0 2021-11-04 [1] CRAN (R 4.2.0)
curl 4.3.2 2021-06-23 [1] CRAN (R 4.2.0)
data.table 1.14.2 2021-09-27 [1] CRAN (R 4.2.0)
DBI 1.1.3 2022-06-18 [1] CRAN (R 4.2.0)
dbplyr 2.2.1 2022-06-27 [1] CRAN (R 4.2.0)
DelayedArray 0.22.0 2022-04-26 [1] Bioconductor
DelayedMatrixStats 1.18.0 2022-04-26 [1] Bioconductor
devtools * 2.4.4 2022-07-20 [1] CRAN (R 4.2.0)
digest 0.6.29 2021-12-01 [1] CRAN (R 4.2.0)
doParallel 1.0.17 2022-02-07 [1] CRAN (R 4.2.0)
dplyr 1.0.9 2022-04-28 [1] CRAN (R 4.2.0)
DT 0.23 2022-05-10 [1] CRAN (R 4.2.0)
ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.2.0)
ensembldb 2.20.2 2022-06-16 [1] Bioconductor
ExperimentHub 2.4.0 2022-04-26 [1] Bioconductor
fansi 1.0.3 2022-03-24 [1] CRAN (R 4.2.0)
farver 2.1.1 2022-07-06 [1] CRAN (R 4.2.1)
fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.2.0)
filelock 1.0.2 2018-10-05 [1] CRAN (R 4.2.0)
fontawesome 0.3.0 2022-07-20 [1] CRAN (R 4.2.0)
foreach 1.5.2 2022-02-02 [1] CRAN (R 4.2.0)
fs 1.5.2 2021-12-08 [1] CRAN (R 4.2.0)
generics 0.1.3 2022-07-05 [1] CRAN (R 4.2.0)
GenomeInfoDb * 1.32.2 2022-05-15 [1] Bioconductor
GenomeInfoDbData 1.2.8 2022-04-28 [1] Bioconductor
GenomicAlignments 1.32.0 2022-04-26 [1] Bioconductor
GenomicFeatures 1.48.3 2022-05-31 [1] Bioconductor
GenomicRanges * 1.48.0 2022-04-26 [1] Bioconductor
GetoptLong 1.0.5 2020-12-15 [1] CRAN (R 4.2.0)
ggbeeswarm 0.6.0 2017-08-07 [1] CRAN (R 4.2.0)
ggplot2 * 3.3.6 2022-05-03 [1] CRAN (R 4.2.0)
ggrepel 0.9.1 2021-01-15 [1] CRAN (R 4.2.0)
GlobalOptions 0.1.2 2020-06-10 [1] CRAN (R 4.2.0)
glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.0)
gridExtra 2.3 2017-09-09 [1] CRAN (R 4.2.0)
gtable 0.3.0 2019-03-25 [1] CRAN (R 4.2.0)
hms 1.1.1 2021-09-26 [1] CRAN (R 4.2.0)
htmltools 0.5.3 2022-07-18 [1] CRAN (R 4.2.0)
htmlwidgets 1.5.4 2021-09-08 [1] CRAN (R 4.2.0)
httpuv 1.6.5 2022-01-05 [1] CRAN (R 4.2.0)
httr 1.4.3 2022-05-04 [1] CRAN (R 4.2.0)
igraph 1.3.4 2022-07-19 [1] CRAN (R 4.2.0)
interactiveDisplayBase 1.34.0 2022-04-26 [1] Bioconductor
IRanges * 2.30.0 2022-04-26 [1] Bioconductor
irlba 2.3.5 2021-12-06 [1] CRAN (R 4.2.0)
iSEE * 2.8.0 2022-04-26 [1] Bioconductor
iterators 1.0.14 2022-02-05 [1] CRAN (R 4.2.0)
jquerylib 0.1.4 2021-04-26 [1] CRAN (R 4.2.0)
jsonlite 1.8.0 2022-02-22 [1] CRAN (R 4.2.0)
KEGGREST 1.36.3 2022-07-12 [1] Bioconductor
labeling 0.4.2 2020-10-20 [1] CRAN (R 4.2.0)
later 1.3.0 2021-08-18 [1] CRAN (R 4.2.0)
lattice 0.20-45 2021-09-22 [1] CRAN (R 4.2.1)
lazyeval 0.2.2 2019-03-15 [1] CRAN (R 4.2.0)
lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.2.0)
lubridate 1.8.0 2021-10-07 [1] CRAN (R 4.2.0)
magick 2.7.3 2021-08-18 [1] CRAN (R 4.2.0)
magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.0)
Matrix 1.4-1 2022-03-23 [1] CRAN (R 4.2.1)
MatrixGenerics * 1.8.1 2022-06-26 [1] Bioconductor
matrixStats * 0.62.0 2022-04-19 [1] CRAN (R 4.2.0)
memoise 2.0.1 2021-11-26 [1] CRAN (R 4.2.0)
mgcv 1.8-40 2022-03-29 [1] CRAN (R 4.2.1)
mime 0.12 2021-09-28 [1] CRAN (R 4.2.0)
miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.2.0)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.2.0)
nlme 3.1-158 2022-06-15 [1] CRAN (R 4.2.0)
paletteer 1.4.0 2021-07-20 [1] CRAN (R 4.2.0)
pillar 1.8.0 2022-07-18 [1] CRAN (R 4.2.0)
pkgbuild 1.3.1 2021-12-20 [1] CRAN (R 4.2.0)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.2.0)
pkgload 1.3.0 2022-06-27 [1] CRAN (R 4.2.0)
png 0.1-7 2013-12-03 [1] CRAN (R 4.2.0)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.2.0)
prismatic 1.1.0 2021-10-17 [1] CRAN (R 4.2.0)
processx 3.7.0 2022-07-07 [1] CRAN (R 4.2.1)
profvis 0.3.7 2020-11-02 [1] CRAN (R 4.2.0)
progress 1.2.2 2019-05-16 [1] CRAN (R 4.2.0)
promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.2.0)
prompt 1.0.1 2022-03-01 [1] Github (gaborcsardi/prompt@7ef0f2e)
ProtGenerics 1.28.0 2022-04-26 [1] Bioconductor
ps 1.7.1 2022-06-18 [1] CRAN (R 4.2.0)
purrr 0.3.4 2020-04-17 [1] CRAN (R 4.2.0)
R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.0)
ragg 1.2.2 2022-02-21 [1] CRAN (R 4.2.0)
rappdirs 0.3.3 2021-01-31 [1] CRAN (R 4.2.0)
RColorBrewer 1.1-3 2022-04-03 [1] CRAN (R 4.2.0)
Rcpp 1.0.9 2022-07-08 [1] CRAN (R 4.2.1)
RCurl 1.98-1.7 2022-06-09 [1] CRAN (R 4.2.0)
rematch2 2.1.2 2020-05-01 [1] CRAN (R 4.2.0)
remotes 2.4.2 2021-11-30 [1] CRAN (R 4.2.0)
restfulr 0.0.15 2022-06-16 [1] CRAN (R 4.2.0)
rintrojs 0.3.0 2021-06-06 [1] CRAN (R 4.2.0)
rjson 0.2.21 2022-01-09 [1] CRAN (R 4.2.0)
rlang 1.0.4 2022-07-12 [1] CRAN (R 4.2.1)
Rsamtools 2.12.0 2022-04-26 [1] Bioconductor
rsconnect 0.8.27 2022-07-12 [1] CRAN (R 4.2.1)
RSQLite 2.2.15 2022-07-17 [1] CRAN (R 4.2.0)
rsthemes 0.3.1 2022-03-01 [1] Github (gadenbuie/rsthemes@bbe73ca)
rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.2.0)
rsvd 1.0.5 2021-04-16 [1] CRAN (R 4.2.0)
rtracklayer 1.56.1 2022-06-23 [1] Bioconductor
Rtsne 0.16 2022-04-17 [1] CRAN (R 4.2.0)
S4Vectors * 0.34.0 2022-04-26 [1] Bioconductor
sass 0.4.2 2022-07-16 [1] CRAN (R 4.2.1)
ScaledMatrix 1.4.0 2022-04-26 [1] Bioconductor
scales 1.2.0 2022-04-13 [1] CRAN (R 4.2.0)
scater * 1.24.0 2022-04-26 [1] Bioconductor
scRNAseq * 2.10.0 2022-04-28 [1] Bioconductor
scuttle * 1.6.2 2022-05-15 [1] Bioconductor
sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.0)
shape 1.4.6 2021-05-19 [1] CRAN (R 4.2.0)
shiny * 1.7.2 2022-07-19 [1] CRAN (R 4.2.0)
shinyAce 0.4.2 2022-05-06 [1] CRAN (R 4.2.0)
shinydashboard 0.7.2 2021-09-30 [1] CRAN (R 4.2.0)
shinyjs 2.1.0 2021-12-23 [1] CRAN (R 4.2.0)
shinyWidgets 0.7.1 2022-07-13 [1] CRAN (R 4.2.1)
SingleCellExperiment * 1.18.0 2022-04-26 [1] Bioconductor
sparseMatrixStats 1.8.0 2022-04-26 [1] Bioconductor
stringi 1.7.8 2022-07-11 [1] CRAN (R 4.2.1)
stringr 1.4.0 2019-02-10 [1] CRAN (R 4.2.0)
SummarizedExperiment * 1.26.1 2022-04-29 [1] Bioconductor
suncalc 0.5.0 2019-04-03 [1] CRAN (R 4.2.0)
systemfonts 1.0.4 2022-02-11 [1] CRAN (R 4.2.0)
testthat * 3.1.4 2022-04-26 [1] CRAN (R 4.2.0)
textshaping 0.3.6 2021-10-13 [1] CRAN (R 4.2.0)
tibble 3.1.8 2022-07-22 [1] CRAN (R 4.2.1)
tidyselect 1.1.2 2022-02-21 [1] CRAN (R 4.2.0)
urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.2.0)
usethis * 2.1.6 2022-05-25 [1] CRAN (R 4.2.0)
utf8 1.2.2 2021-07-24 [1] CRAN (R 4.2.0)
vctrs 0.4.1 2022-04-13 [1] CRAN (R 4.2.0)
vipor 0.4.5 2017-03-22 [1] CRAN (R 4.2.0)
viridis 0.6.2 2021-10-13 [1] CRAN (R 4.2.0)
viridisLite 0.4.0 2021-04-13 [1] CRAN (R 4.2.0)
withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.0)
XML 3.99-0.10 2022-06-09 [1] CRAN (R 4.2.0)
xml2 1.3.3 2021-11-30 [1] CRAN (R 4.2.0)
xtable 1.8-4 2019-04-21 [1] CRAN (R 4.2.0)
XVector 0.36.0 2022-04-26 [1] Bioconductor
yaml 2.3.5 2022-02-21 [1] CRAN (R 4.2.0)
zlibbioc 1.42.0 2022-04-26 [1] Bioconductor
[1] /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── |
Describe the bug
The heatmap crashes when we use a character variable with 33 unique values. Here's the error output:
To Reproduce
We added the following to the
?iSEE
example:Then under the heatmap, we go to
visual parameters
, then undercolumn annotations
select our variable (in this casecellType.final
) that has the 33 unique values, and it crashes out.Here's the full code to reproduce this app:
In addition, we've tried using an
ExperimentColorMap
that supports the 33 unique values, but it still fails.It works on the panels for reduced dimensions and feature assay, as expected.
But it still crashes out on the heatmap.
Expected behavior
That it would show the same colors we see under other panels. For example:
Screenshots
See above.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
Session info (please complete the following information)
Co-authored-by: Heena Divecha @heenadivecha
The text was updated successfully, but these errors were encountered: