在单细胞转录组分析过程中的质控不仅仅包含对于检测基因数(n_genes),counts数和percent.mt,进行双细胞的筛选会更加科学。
使用scrublet进行双细胞计算
代码语言:python
代码运行次数:0
复制import scrublet as scr
import scipy.io
import matplotlib.pyplot as plt
import numpy as np
import os
import pandas as pd
counts_matrix = adata.X
scrub = scr.Scrublet(counts_matrix, expected_doublet_rate=0.06)
doublet_scores, predicted_doublets = scrub.scrub_doublets(min_counts=2, min_cells=3, min_gene_variability_pctl=85, n_prin_comps=30)
scrub.call_doublets(threshold=0.25)
# 画doublet score直方图
scrub.plot_histogram()
print('Running UMAP...')
scrub.set_embedding('UMAP', scr.get_umap(scrub.manifold_obs_, 10, min_dist=0.3))
print('Done.')
scrub.plot_embedding('UMAP', order_points=True)
out_df = pd.DataFrame()
out_df['doublet_scores'] = doublet_scores
out_df['predicted_doublets'] = predicted_doublets
out_df.head()
adata.obs['doublet_scores'] = doublet_scores
adata.obs['predicted_doublets'] = predicted_doublets