|
a |
|
b/Functions/variableFeatureSelection.R |
|
|
1 |
#' @description get variable genes and evalute the cell cycle effect |
|
|
2 |
#' @param seurat.lists: multi seurat object list |
|
|
3 |
#' @parma method: seurat process method |
|
|
4 |
#' @param: return.only.var.gene, vars.to.regress: parameter for SCTranform |
|
|
5 |
#' @param: nfeatures: the number of variable features |
|
|
6 |
|
|
|
7 |
variableFeatureSelection <- function(seurat.lists, method = c("Standard", "SCT"), return.only.var.genes = T, nfeatures = 3000, vars.to.regress = c("nCount_RNA", "percent.mt")){ |
|
|
8 |
|
|
|
9 |
for (i in 1:length(seurat.lists)) { |
|
|
10 |
DefaultAssay(seurat.lists[[i]]) <- "RNA" |
|
|
11 |
if(method == "SCT"){ |
|
|
12 |
seurat.lists[[i]] <- SCTransform(seurat.lists[[i]], variable.features.n = nfeatures, vars.to.regress = vars.to.regress, verbose = FALSE, return.only.var.genes = return.only.var.genes) |
|
|
13 |
}else{ |
|
|
14 |
seurat.lists[[i]] <- NormalizeData(seurat.lists[[i]], verbose = FALSE) |
|
|
15 |
seurat.lists[[i]] <- FindVariableFeatures(seurat.lists[[i]], selection.method = "vst", nfeatures = nfeatures, verbose = FALSE) |
|
|
16 |
} |
|
|
17 |
} |
|
|
18 |
return(seurat.lists) |
|
|
19 |
} |