参考博客
https://scanpy.readthedocs.io/en/stable/tutorials/spatial/basic-analysis.html
example
import scanpy as sc
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
coordinates = pd.read_excel("./data/pnas.1912459116.sd15.xlsx", index_col=0)
counts = sc.read_csv("./data/pnas.1912459116.sd12.csv").transpose()
adata_merfish = counts[coordinates.index, :].copy()
adata_merfish.obsm["spatial"] = coordinates.to_numpy()
sc.pp.normalize_per_cell(adata_merfish, counts_per_cell_after=1e6)
sc.pp.log1p(adata_merfish)
sc.pp.pca(adata_merfish, n_comps=15)
sc.pp.neighbors(adata_merfish)
sc.tl.umap(adata_merfish)
sc.tl.leiden(adata_merfish,key_added="clusters",resolution=0.5,n_iterations=2,flavor="igraph",directed=False,
)
adata_merfish
sc.pl.umap(adata_merfish, color="clusters")
sc.pl.embedding(adata_merfish, basis="spatial", color="clusters")
注意,这里画merfish的空间图是和别的10X_Visium是不一样的,10X_Visium使用的是sc.pl.spatial()
, 而这里使用的是sc.pl.embedding()
,需要注意区别