作者,Evil Genius~~~
今天不想看文章了,我们来画一画图吧。
单细胞的我们来画一画下面的图
Transcription factor network in the pancreatic epithelial cell population
空间的部分我们来画一画邻域网络图
Neighborhood graph representing neighborhood enrichment of cell types. Edges represent average neighborhood enrichment scores (observed‑to‑expected ratio) between the cell types, and only the bidirectional enrichments were depicted in this graph as edges. Dot sizes are proportional to the estimated abundances (log scale), and the colors represent average cancer cell abundances in each cell type’s neighborhood
注意空间图的注释
Neighborhood graph representing neighborhood enrichment of cell types. Edges
represent average neighborhood enrichment scores (observed‑to‑expected ratio) between the cell types, and only the bidirectional enrichments were depicted in this graph as edges. Dot sizes are proportional to the estimated abundances (log scale), and the colors represent average cancer cell abundances in each cell type’s neighborhood.
当然了,有AI的部分在里面,我们需要绘制主图
我们先来画单细胞的,比较简单
import sceleto as scl
import sys
import scanpy as sc
import matplotlib.pyplot as plt
sys.path.append('/home/user1/python_package_jp')
import scjp
import scipy
import numpy as np
import pickle as pkl
def pklrd(filename):
with open(filename, "rb") as file:
data = pkl.load(file)
return data
csdict=pklrd('/home/srkim/02_PancCa/16_FIGURE/csdict.pkl')
def size2(a,b):
plt.rcParams['figure.figsize'] = (a,b)
def size(a,b):
plt.gcf().set_size_inches(a,b)
def pklrd(filename):
with open(filename, "rb") as file:
data = pkl.load(file)
return data
def pklwr(data, filename):
with open(filename, "wb") as file:
pkl.dump(data, file)
def save(name):
scjp.save_fig(version,'Fig_'+name,fig_folder='./Fig')
plt.rcParams['figure.dpi'] = 300
# printing version
## from GSE154778, Lin, 2020
nb_name = 'test'
version =02
Name = nb_name
print('Version: %s'%(version))
print('NB_name: %s'%(Name))
plt.rcParams['figure.dpi'] = 300
读取示例数据,anndata
adata = sc.read_h5ad('/home/srkim/02_PancCa/16_FIGURE/data/PCI01.v43.canrawt_final_02.h5ad')
adata
AnnData object with n_obs × n_vars = 11536 × 2536
obs: 'Sample', 'n_counts', 'n_genes', 'mito', 'doublet_scores', 'predicted_doublets', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'pct_counts_in_top_50_genes', 'pct_counts_in_top_100_genes', 'pct_counts_in_top_200_genes', 'pct_counts_in_top_500_genes', 'name', 'status', 'assignment', 'genotype', 'KRASg', 'pathol', 'leiden', 'leiden_0.50', 'anno', 'anno_fib', 'anno_final_temp', 'anno_can', 'anno_final', 'ID', 'cID', 'pID', 'copykat.pred', 'anno_predict', 'batch', 'leiden_2.00', 'Fb_COL9A1', 'Fb_ANXA8', 'Fb_Base', 'Fb_LRRC15', 'Fb_SFRP1', 'Fb_VIT', 'Stellate', 'confused'
var: 'means', 'dispersions', 'dispersions_norm', 'mean', 'std'
uns: 'anno_final_colors', 'genotype_colors', 'neighbors', 'pathol_colors', 'pca', 'umap'
obsm: 'X_pca', 'X_umap'
varm: 'PCs'
obsp: 'connectivities', 'distances'
画一个UMAP图
scjp.us(adata, 'anno_final')
数据处理
adata = adata[~adata.obs.anno_final.isin(['Ep_CDK1','Ep_Base'])].copy()
adata = adata.raw.to_adata()
scjp.sc_process(adata, 'fspku')
sc.external.pp.harmony_integrate(adata, 'ID', adjusted_basis='X_pca')
scjp.sc_process(adata, 'ku')
scjp.bbknn_umap(adata, 'ID', 50)
构建网络
N = scjp.network.network(adata, n_neighbor=8)
N.get_grid(select_per_grid=4)
N.impute()
N.idata
##AnnData object wit