第一步:导入所需R包
library(AUCell)
第二步:确定自己的基因集
①满足为list
②每个list中的项具有name
③每个项中的元素为基因集合
例:
第三步:构造AUCell可识别的geneSets
moduleGeneSets <- c() for(i in 1:length(modules)){ moduleGeneSets <- c(moduleGeneSets, GeneSet(modules[[i]], setName = names(modules)[i])) } geneSets <- GeneSetCollection(moduleGeneSets)
其中,参数setName必须指定,即为list中项的name
第四步:计算自定义基因集的AUCell活性
这里ranking排序和AUC活性计算写为了calAUCell方法;阈值查找写为filterAUCell方法,方便循环处理。若需要查看ranking的可视化结果,建议将方法中的代码一步一步执行!
calAUCell <- function(mode,x){ cells_rankings <- AUCell_buildRankings(x) #x为表达矩阵 cells_AUC <- AUCell_calcAUC(mode, cells_rankings) return(cells_AUC) } filterAUCell <- function(x){ cells_assignment <-AUCell_exploreThresholds(x, plotHist = TRUE, nCores = 1, assign = TRUE) #x为cells_AUC return(cells_assignment) }
总结:将list作为数据准备,然后通过函数GeneSet和GeneSetCollection转化为AUCell所需的geneSets,这里方法参数的mode对应geneSets。
更多的学习可以参考