Created
May 14, 2020 14:38
-
-
Save kieranrcampbell/c1d8b4cd0200bf74bef2f6d9e431aa0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
seurat_cluster <- function(sce, | |
resolution = 0.8, | |
dims = 1:10, | |
reduction = "mnn", | |
algorithm = 1, | |
return_SCE = TRUE) { | |
seu <- as.Seurat(sce, counts = "counts", data = "logcounts") | |
seu <- FindNeighbors(seu, dims = dims, reduction = reduction) | |
seu <- FindClusters(seu, resolution = resolution, algorithm = algorithm) | |
sce2 <- as.SingleCellExperiment(seu) | |
sce$seurat_clusters <- sce2$seurat_clusters | |
if(return_SCE) { | |
return(sce) | |
} else { | |
return(sce$seurat_clusters) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment