Skip to content
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

plotUMAP_split() %>% ggarrange(common.legend=TRUE) produces inconsistent colors #74

Open
micahpf opened this issue Sep 13, 2023 · 0 comments

Comments

@micahpf
Copy link
Collaborator

micahpf commented Sep 13, 2023

When using the plotUMAP_split() %>% ggarrange(common.legend=TRUE) workflow to generate umaps across split object, if you group.by a metadata column labels which has different number of unique(labels), the colors will be inconsistent across umaps and the common legend will thus not correspond to the true colors.

I tried assigning the superset of levels to each sample (below), but that does not fix the problem.

common.levels <- obj.split %>%
  lapply(., function(x) x$labels %>% unique()) %>%
  Reduce(c, .) %>% unique()

obj.split <- obj.split %>%
  lapply(., function(x) {
    x$labels <- factor(x$labels, levels = common.levels)
    return(x)
  })

I think Seurat's DimPlot() is removing unused levels from the groups used to color cells, essentially ignoring the factor levels?

Maybe there's some way to revise the color scale of each DimPlot after calling Seurat::DimPlot() to include the full range of levels? Otherwise we may need to use our own version of DimPlot .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant