单细胞测序分析-小测

2019-12-04  本文已影响0人  xmu_zhang_lab

https://osca.bioconductor.org/learning-r-and-more.html#getting-help-in-and-out-of-r

if(!require("scRNAseq")) BiocManager::install("scRNAseq")
if(!require("scater")) BiocManager::install("scater")
if(!require("scran")) BiocManager::install("scran")

## 从scRNA数据包中提取测试数据
library(scRNAseq)
sce <- MacoskoRetinaData()

library(scater)
is.mito <- grepl("^MT-", rownames(sce))
qcstats <- perCellQCMetrics(sce, subsets=list(Mito=is.mito))

filtered <- quickPerCellQC(qcstats, percent_subsets="subsets_Mito_percent")
sce <- sce[, !filtered$discard]

# 数据矫正:normalization
sce <- logNormCounts(sce)

# 特征选择: Feature selection.

if(!require("scran")) BiocManager::install("scran")
library(scran)
dec <- modelGeneVar(sce)
hvg <- getTopHVGs(dec, prop=0.1)

# 降维分析
set.seed(1234)
sce <- runPCA(sce, ncomponents=25, subset_row=hvg)
sce <- runUMAP(sce, dimred = 'PCA', external_neighbors=TRUE)

# 聚类分析
g <- buildSNNGraph(sce, use.dimred = 'PCA')
sce$clusters <- factor(igraph::cluster_louvain(g)$membership)

# 可视化
plotUMAP(sce, colour_by="clusters")
image.png
上一篇下一篇

猜你喜欢

热点阅读