-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Hello, cool method! I would like to know how to apply this method across multiple images. For example, if I have AnnData
object with a sample categorical column in obs
, how can I use this method across all of them to get similar clusters across multiple images correctly? Currently if I run the method across multiple images at once, each image gets essentially gets labeled with one cluster. I would like to see the same "subpopulations" appearing across multiple field of views.
My code for reference, maybe I did something wrong here?
nbl_adata: ad.AnnData
sc.pp.neighbors(
nbl_adata,
n_neighbors=15,
key_added="sc_neighbors",
transformer=AnnoyTransformer(n_neighbors=15, n_trees=100),
)
sq.gr.spatial_neighbors(
nbl_adata, spatial_key="spatial", library_key="region", coord_type="generic", key_added="sq_spatial", n_neighs=15
)
nbl_adata.obsm["X_msPCA"] = MultispatiPCA(n_components=2, connectivity=nbl_adata.obsp["sq_spatial_connectivities"]).fit_transform(nbl_adata.X)
sc.pp.neighbors(
nbl_adata,
n_neighbors=15,
key_added="msPCA_neighbors",
use_rep="X_msPCA",
transformer=AnnoyTransformer(n_neighbors=6, n_trees=100),
)
sl.spatialleiden(
nbl_adata, # All fields of view
layer_ratio=1.8,
directed=(True, False),
latent_distance_key="msPCA_neighbors_connectivities",
spatial_distance_key="sq_spatial_connectivities",
key_added="spatialleiden",
)
...
sl.spatialleiden(
nbl_fov, # subset the AnnData on a single Field of View
layer_ratio=3,
directed=(True, False),
latent_distance_key="sc_neighbors_connectivities",
spatial_distance_key="sq_spatial_connectivities",
key_added="spatialleiden",
)
For the following 2 figures I have subset on a cell type and ran the clustering algorithm on just those cells. I've plotted the FOV with the numerical spatialleiden clusters, and the other cell types present in the FOV.
One FOV after running SpatialLeiden
across all FOVs
One FOV after running SpatialLeiden
on just this FOV
Metadata
Metadata
Assignees
Labels
No labels