单细胞测序scanpy

scRNAseq双细胞去除-2: Scrublet

2021-06-12  本文已影响0人  Hayley笔记

scRNAseq双细胞去除-1: DoubletFinder


1. 原理介绍
发表于19年3月

Scrublet是一个基于python的双细胞预测工具,原理与DoubletFinder类似,首先人工模拟出一些双细胞,将模拟出的双细胞加入矩阵,通过建立最近邻分类器来识别doublets。

2. 演示
%matplotlib inline
import scrublet as scr
import scipy.io
import matplotlib.pyplot as plt
import numpy as np
import os
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = 'Arial'
plt.rc('font', size=14)
plt.rcParams['pdf.fonttype'] = 42

下载示例数据集并解压

wget http://cf.10xgenomics.com/samples/cell-exp/2.1.0/pbmc8k/pbmc8k_filtered_gene_bc_matrices.tar.gz
tar xfz pbmc8k_filtered_gene_bc_matrices.tar.gz

准备矩阵和gene list

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.plot_histogram();
print('Running UMAP...')
scrub.set_embedding('UMAP', scr.get_umap(scrub.manifold_obs_, 10, min_dist=0.3))

# # Uncomment to run tSNE - slow
# print('Running tSNE...')
# scrub.set_embedding('tSNE', scr.get_tsne(scrub.manifold_obs_, angle=0.9))

# # Uncomment to run force layout - slow
# print('Running ForceAtlas2...')
# scrub.set_embedding('FA', scr.get_force_layout(scrub.manifold_obs_, n_neighbors=5. n_iter=1000))
    
print('Done.')
scrub.plot_embedding('UMAP', order_points=True);

# scrub.plot_embedding('tSNE', order_points=True);
# scrub.plot_embedding('FA', order_points=True);
上一篇下一篇

猜你喜欢

热点阅读