Closed orrzor closed 2 years ago
Dear Orr,
Great running into you! Hope all is well!
Thanks for the well documented issue report.
As you know, getSpatiallyInformedClusters
integrates spatially informed weights in transcriptional graph-based community detection. The weight is defined as
weight <- 1/(alpha + as.vector(pweight)) + beta
where pweight
is the Voronoi-graph distance. Note that there is an alpha
and beta
parameter.
It looks when we made the simulation, we had previously set the default alpha
and beta
to 0
but have now updated it to 1 (primarily to avoid 0 pweight
s seen in real data from causing crashes). So if you change alpha
and beta
back to 0
you should get the results you see in the tutorial.
com2 <- getSpatiallyInformedClusters(pcs, W=W, k=50, alpha=0, beta=0)
table(com2)
plotEmbedding(pos, groups=com2, main='Spatially Aware Transcriptional Clusters', xlab='Spatial X', ylab='Spatial Y')
Hope this helps!
Stay healthy and safe, Jean
Hi Jean,
Thanks so much for your response! That completely fixes the issue, and it's helpful to know more about these weights. I'm looking forward to trying this on some Slide-Seq data. I hope you're doing great at Hopkins! Take care! -Orr
I explicitly added com2 <- getSpatiallyInformedClusters(pcs, W=W, k=50, alpha=0, beta=0)
to the spatial_clustering
tutorial to help with this confusion. Everything seems to be working now.
Brendan, do you have any heuristics for how you set alpha and beta? I might try a range of values now that I know it makes a difference. thanks for any thoughts!
Hi Orr,
Thanks for your question! It's actually an interesting one that deserves some deeper exploration. We haven't thoroughly tested how modulating alpha and beta affect the spatially informed weights and formation of clusters but ultimately it has to do with how these spatially informed edge weights are incorporated into the clustering algorithm. By default getSpatiallyInformedClusters
uses the igraph::cluster_louvain
method, which might give some insight into this.
As mentioned above, pweights
are Voronoi-graph distances between cells, in which two cells have a spatial distance of 1 if they are neighbors, 2 if they are neighbors of neighbors, etc. So given alpha = beta = 0
, and distances of 1 and 2, the edge weights would be 1/1 = 1
and 1/2 = 0.5
. Increasing alpha would make these smaller fractions and increasing beta would make these larger.
In the spatial_clustering
tutorial, it seems that the 3 spatial clusters are identified as long as beta = 0
but doesn't seem to matter if alpha
is 1, or 10, or 100 for that matter. To give you a sense of other values, for the spatially aware clustering of the ISH Drosophila melanogaster data, alpha = beta = 0.01
. For the spatially aware clustering of the MERFISH mouse hypothalamic preoptic region data, alpha = beta = 1
.
Hope this helps a little and please reach out if you have any other questions, Brendan
Hi Jean and team,
Thanks for making this cool work available! I am working through your spatially-informed clustering tutorial, and I am not getting the expected results when I run the clustering, but everything before this step matches your tutorial outputs.
I am just copying and pasting code exactly from your tutorial.
If I reduce the k from 50 to 14, I can get 3 clusters but they are not spatially distinct
Below is my session info. Thanks for any help!! Best- Orr