Closed briglo closed 2 years ago
It's not immediately clear to me what went wrong here. Your code seems fine. I ran the code using your parameters on our data and did not notice anything strange. So I'm not sure what's going on, but the right hand side should not turn out that way. The only time I've seen something similar is in #58 but that shouldn't happen here since you are using BayesSpace functions to read data (not converting from Seurat).
A couple ideas to try:
verbose = TRUE
flags in both clustering and enhancement to make sure neighbors are being detectedgamma
to 3 in the enhancementclusterPlot(tmp.enhanced, mcmcChain(tmp.enhanced, "z")[1,]) #this should look exactly like your spot-level spatial clusters
clusterPlot(tmp.enhanced, mcmcChain(tmp.enhanced, "z")[2,]) #does it break down here?
clusterPlot(tmp.enhanced, mcmcChain(tmp.enhanced, "z")[3,])
Hi Thanks a tonne for getting back so quickly. I was baffled to because it worked so well out of the box on the other sections
I tried your suggestions plus remaking the object with fewer clusters and 10k reps on the clustering. And for all i got variants of
and
Your surmise is correct, it collapses on the clusterPlot(tmp.enhanced, mcmcChain(tmp.enhanced, "z")[2,])
Thank you for your help, if you have other ideas, ill give them a go. Regards B
Would you be able to send me a .RDS file of your indat
data object? For confidentiality and file size, can set counts(indat) = NULL
and logcounts(indat)=NULL
. I just need PCs and coordinates really. My email is ezhao(at)fredhutch[dot]org.
Not sure whether the problem is in the data our our code, but I can try to figure it out.
Done, thanks again ; very much appreciated B
Thanks for sending. I think I've figured out the problem. For some reason, the row/col and imagerow/imagecol are mismatched.
library(BayesSpace)
sce = readRDS("indat_for_edward.RDS")
sce.enhanced = spatialEnhance(sce, q = length(unique(sce$spatial.cluster)),
verbose = T, burn.in = 100, nrep = 200)
clusterPlot(sce.enhanced)
plot(sce$imagecol~sce$col)
plot(sce$imagerow~sce$row)
plot(sce$imagecol~sce$row)
plot(sce$imagerow~sce$col)
We expect row and imagerow to be linearly associated (rather than row and imagecol). So this will definitely mess up the spatialEnhance
neighbor finding algorithm (which is different from that of spatialCluster
, which I think is what happened to get those really scrambled looking results. This fixed it for me:
#fix coordinates
sce2 = sce
sce2$imagecol.new = sce2$imagerow
sce2$imagerow = sce2$imagecol
sce2$imagecol = sce2$imagecol.new
sce.enhanced.fix = spatialEnhance(sce2, q = length(unique(sce$spatial.cluster)),
verbose = T, burn.in = 100, nrep = 200)
clusterPlot(sce.enhanced.fix)
I'm not sure if there's some updates with SpaceRanger that caused the column switching issue. Any chance there was an issue with how SpaceRanger was run? (I don't have experience using it)
Thats awesome thanks so much!
So this was run on spaceranger 1.3 and i'm willing to bet its because the flag --reorient-images
was used (there was some sort of issue with fiducials lining up), those image flip coords things look suspiciously familiar
Awesome to have a fix! Thanks for everything
Hi, thanks for an awesome tool! I was making my way through some sections using the tutorial as a guide (optimising number o clusters and jitter scales) but on two of our 4 samples, cluster coherence was lost on spatial enhancement. For the other two the following approach worked a treat- but spatially enhanced clusters at least nominally resembled the low-res ones.
code is
gives the attached
I was wondering if you have seen this before. Is there a way around it/am i missing something/ or is there not enough structure in the data itself to support the clustering?- this is possible ; the section itself was more homogeneous
Thanks again and do feel free to redirect me (i did notice a similar looking thing can happen if coordinates are explicitly declared, but i didnt do that here). Regards