Closed boyiguo1 closed 3 months ago
Hi @boyiguo1,
This has been now resolved in https://github.com/LieberInstitute/spatialLIBD/commit/08c2b2d80a29b1decee578d01f7230b595a9bf5a which also resolved #80.
Best, Leo
Here's the output of your example with version 1.17.6:
suppressPackageStartupMessages(library("spatialLIBD"))
spe <- fetch_data("spatialDLPFC_Visium_example_subset")
#> 2024-07-12 13:23:57.969 loading file /Users/leocollado/Library/Caches/org.R-project.R/R/BiocFileCache/6f563a40ecf7_spatialDLPFC_spe_subset_example.rds%3Fdl%3D1
spe$spd <- sprintf("SpD_%02d", spe$BayesSpace_harmony_10)
vis_grid_clus(
spe,
"spd",
return_plots = TRUE,
sort_clust = TRUE
)
#> $Br6432_ant
#>
#> $Br6522_ant
#>
#> $Br8667_mid
k <- unique(spe$spd) |> length()
vis_grid_clus(
spe,
"spd",
return_plots = TRUE,
sort_clust = FALSE,
colors = setNames(
Polychrome::palette36.colors(k),
unique(spe$spd) |> sort()
)
)
#> $Br6432_ant
#>
#> $Br6522_ant
#>
#> $Br8667_mid
packageVersion("spatialLIBD")
#> [1] '1.17.6'
Created on 2024-07-12 with reprex v2.1.0
Thanks for the nice package!
I've been using
vis_grid_clus
to plot multiple samples together. I noticed the legends representing levels ofclustervar
are always turning to numbers instead of showing their original labels even when I manually set up withcolors
. With some debugging, I realize the functionsort_clusters
might be the culprit for it.As an end results for
vis_grid_clus
plots, I'm getting plots with no color filled spots and warning messages1: No shared levels found between
names(values)of the manual scale and the data's fill values.
when running the following line.This is because
sort_clusters
is employed with the default option ofsort_clust = TRUE
. https://github.com/LieberInstitute/spatialLIBD/blob/77a5303f91edb7b9ffb1ce00b4193dae5d16a8a1/R/vis_grid_clus.R#L69-L72The problem is metigated by making
sort_clust = FALSE
as well as providing colors option.R Session Information