【AUCell】单细胞基因集打分

本文介绍了如何使用R包AUCell进行单细胞基因集打分,包括建立排名、计算AUC和设定分配阈值。该方法适用于亚群注释,并通过AUC评估基因集在每个细胞中的富集程度。需要注意的是,细胞亚群比例会影响结果,基因集大小应适中,通常在100-2000个基因之间。AUCell提供的阈值和可视化工具帮助分析和设定活跃基因集的标准。

单细胞层次给基因集打分除了和GSVA等分析一样可以做富集以外,还可以通过cell marker gene set做亚群注释(需要注意细胞比例的问题,数量少的群体不行,可作辅助)。前面写过的scMetabolism包是给代谢通路打分,思路一样。

AUCell 是ranking-based,所以具体哪种标准化方法不重要,只要不影响每个细胞内基因表达量的排序就好。总的来讲,分为三步:

1,build the rankings

2,calculate the AUC

3,set the assignment threshold

安装R包

if (!requireNamespace("BiocManager", quietly=TRUE))
    install.packages("BiocManager")

Biocmanager::install("AUCell")

# To support paralell execution:
BiocManager::install(c("doMC", "doRNG","doSNOW"))
# For the main example:
BiocManager::install(c("mixtools", "GEOquery", "SummarizedExperiment"))
# For the examples in the follow-up section of the tutorial:
BiocManager::install(c("DT", "plotly", "NMF", "d3heatmap", "shiny", "rbokeh",
                       "dynamicTreeCut","R2HTML","Rtsne", "zoo"))

  • load the scRNA expression matrix and gene set
# i.e. Reading from a text file
#exprMatrix <- read.table("myCountsMatrix.tsv")
#exprMatrix <- as.matrix(exprMatrix)

# or using an expression set
#exprMatrix <- exprs(myExpressionSet)




# (This may take a few minutes)
library(GEOquery)
attemptsLeft <- 20
while(attemptsLeft>0)
{
  geoFile <- tryCatch(getGEOSuppFiles("GSE60361", makeDirectory=FALSE), error=identity) 
  if(methods::is(geoFile,"error")) 
  {
    attemptsLeft <- attemptsLeft-1
    Sys.sleep(5)
  }
  else
    attemptsLeft <- 0
}

gzFile <- grep(".txt.gz", basename(rownames(geoFile)), fixed=TRUE, value=TRUE)
message(gzFile)
txtFile <- gsub(".gz", "", gzFile, fixed=TRUE)
message(txtFile)
gunzip(filename=gzFile, destname=txtFile, remove=TRUE)

library(data.table)
geoData <- fread(txtFile, sep="\t")
geneNames <- unname(unlist(geoData[,1, with=FALSE]))
exprMatrix <- as.ma
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值