SGDDNB / ShinyCell

Shiny Interactive Web Apps for Single-Cell Data
GNU General Public License v3.0
148 stars 57 forks source link

Factor with many levels fails to be visualized #48

Closed koenvandenberge closed 2 years ago

koenvandenberge commented 2 years ago

Hi All,

Thank you for developing this useful tool.

Whenever one of the cell-level variables in the Seurat object has many levels, it seems it is being dropped as a visualization option when using the Shiny app. For example, using the quick-start guide and adding a factor with 56 levels, this variable manyLevels is not an option for the visualization. This becomes troublesome for larger single-cell datasets with many cell types. Is there a convenient fix for this?

Below is a reproducible example using your quick-start guide:

library(Seurat)
library(ShinyCell)

getExampleData()                       # Download example dataset (~200 MB)
seu = readRDS("readySeu_rset.rds")
seu$manyLevels <- factor(sample(56, ncol(seu), replace=TRUE)) # cannot visualize this variable on e.g. UMAP
scConf = createConfig(seu)
makeShinyApp(seu, scConf, gene.mapping = TRUE,
             shiny.title = "ShinyCell Quick Start") 
jfouyang commented 2 years ago

Hi @koenvandenberge,

In the createConfig function, there is an argument maxLevels = 50, which ignores any factor with > 50 levels. You can set this to a higher number e.g. 60 so that your 56-levels factor can be included. We deliberately added a limit of 50 levels as the legend usually occupies too much space and makes the main plot very small as a result.

Hope this helps.

koenvandenberge commented 2 years ago

Great, thanks so much! I had overlooked this.

siegelna commented 2 months ago

Life saver, thank you!