MERFISH
[1]:
import os
import pandas as pd
import numpy as np
import scanpy as sc
import anndata as ad
import matplotlib.pyplot as plt
import seaborn as sns
[2]:
import pysodb
[3]:
sc.set_figure_params(vector_friendly=False,format='pdf',transparent=True,dpi=50)
plt.rcParams["figure.figsize"] = (8, 8)
sns.set_style('white')
load a data using pysodb
[4]:
sodb = pysodb.SODB() # Initialization
/home/yzy/anaconda3/envs/SODB/lib/python3.9/site-packages/urllib3-1.26.12-py3.9.egg/urllib3/connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host 'gene.ai.tencent.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
warnings.warn(
[ ]:
[ ]:
# this dataset is from publication "Decoding molecular and cellular heterogeneity of mouse nucleus accumbens"
[ ]:
# link in SODB: https://gene.ai.tencent.com/SpatialOmics/dataset?datasetID=32
[7]:
adata = sodb.load_experiment('chen2021decoding','mouse2_slice14')
# the first parameter is the name of the dataset
# the second parameter is the name of one experiment in the dataset
load experiment[mouse2_slice14] in dataset[chen2021decoding] from /home/yzy/anaconda3/envs/SODB/lib/python3.9/site-packages/pysodb-1.0.0-py3.9.egg/pysodb/cache/chen2021decoding/mouse2_slice14.h5ad
identify clusters
[8]:
sc.pp.pca(adata)
sc.pp.neighbors(adata)
sc.tl.umap(adata)
sc.tl.leiden(adata, key_added="clusters")
/home/yzy/anaconda3/envs/SODB/lib/python3.9/site-packages/tqdm-4.64.1-py3.9.egg/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
from .autonotebook import tqdm as notebook_tqdm
[9]:
sc.pl.umap(adata, color=[ "clusters"], wspace=0.4,
add_outline=True,legend_fontsize=10, legend_fontoutline=2,
legend_loc='on data',
s=50
)
[10]:
# plt.rcParams["figure.figsize"] = (8, 8)
sc.pl.embedding(adata, basis='spatial', color=['clusters'],show=False,size=5,add_outline=False)
plt.gca().set_aspect('equal', adjustable='box')
marker gene detection
[ ]:
sc.tl.rank_genes_groups(adata, "clusters", method="t-test")
[16]:
sc.pl.rank_genes_groups_tracksplot(adata, n_genes=3, groupby="clusters")
/home/yzy/anaconda3/envs/SODB/lib/python3.9/site-packages/scanpy-1.9.1-py3.9.egg/scanpy/plotting/_anndata.py:2414: FutureWarning: iteritems is deprecated and will be removed in a future version. Use .items instead.
obs_tidy.index.value_counts(sort=False).iteritems()
[12]:
marker_genes = adata.uns['rank_genes_groups']['names'][0]
[13]:
sc.pl.umap(adata, color=marker_genes, wspace=0.4,
add_outline=True,legend_fontsize=10, legend_fontoutline=2,
legend_loc='on data',
s=50
)
[15]:
# plt.rcParams["figure.figsize"] = (8, 8)
sc.pl.embedding(adata, basis='spatial', color=marker_genes,size=20,add_outline=False)
[ ]: