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

Bug(s) in SpatialDimPlot #6179

Closed
mvhunter1 opened this issue Jul 12, 2022 · 6 comments
Closed

Bug(s) in SpatialDimPlot #6179

mvhunter1 opened this issue Jul 12, 2022 · 6 comments

Comments

@mvhunter1
Copy link

Hi Seurat team,
Thank you so much for your service to the community.
Similar to previous issue #5975 I am unable to use SpatialDimPlot or SpatialPlot with group.by after upgrading to Seurat 4.1.1. The plots appear as unlabeled points no matter which metadata column is used to group the data.
Screen Shot 2022-07-12 at 5 30 18 PM
These are critical functions for plotting any type of spatial data so a bug fix would really be appreciated :) Thank you!

@lengjing0519
Copy link

me too! If there is any solution, please let me know

@yoda-vid
Copy link

I've encountered this as well in v4.1.1, while it worked in v4.1.0. It appears to bisect to commit 4024b0c, where the addition of cols <- cols[names(x = cols) %in% data$ident] appears to filter out the colors when grouping by something other than ident.

The workaround for me was just to comment out this line. I also tried replacing data$ident with data[[col.by]], but col.by gets surrounded by backticks and doesn't appear to work here.

yoda-vid added a commit to yoda-vid/seurat that referenced this issue Aug 26, 2022
Fix satijalab#6179. If the `ident` column is not present in the data, all colors get filtered out. Only filter colors if this column is non-null.
@sciencepeak
Copy link

sciencepeak commented Feb 4, 2023

Hi, I have updated my Seurat to 4.3.0, however, the SpatialDimPlot(..., col = colors) still produce the error of Insufficient values in manual scale. 12 needed but only 0 provided, which is similar to the previous issue.

Luckily, I found a suggestion here. The suggestion fixes the error. My version of the solution is like this:

numCluster <- my_seurat_object@meta.data$seurat_clusters %>% unique %>% length
colors = Seurat::DiscretePalette(n = numCluster, palette = "polychrome")
Idents(my_seurat_object) # should be seurat clusters.
# The colors, which is a character vector of different color codes, need the names for the vector.
names(colors) <- Idents(my_seurat_object) %>% levels()

the_ggplot_list <- SpatialDimPlot(
    my_seurat_object, # the seurat object here contain only one sample, though it can contain more samples.
    images = "my_image_name",
    group.by = c("seurat_clusters"),
    pt.size.factor = 1.15,
    label = TRUE,
    label.size = 6,
    repel = TRUE,
    combine = FALSE,
    cols = colors
)
print(the_ggplot_list)

If the error could be further investigated by the devolopers, that would be terrific. Otherwise, it would be helpful if the document of SpatialDimPlot(..., col = colors) have more explanation, which should not be hard.

Thank you very much for your contribution to the science community.

@chengwenxuan1997
Copy link

I have an alternative trick here, it seems that the SpatialDimPlot still works on the Idents of the Seurat object.

Idents(ST.seu) <- ST.seu$group
SpatialDimPlot(ST.seu)

@sciencepeak
Copy link

It's glad to know that SpatialDimPlot works on the Idents of the Seurat object again.

@dcollins15
Copy link
Contributor

Thanks for using Seurat!

It appears that this issue has gone stale. In an effort to keep our Issues board from getting more unruly than it already is, we’re going to begin closing out issues that haven’t had any activity since the release of v4.4.0.

If this issue is still relevant we strongly encourage you to reopen or repost it, especially if you didn’t initially receive a response from us.

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

6 participants