-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscyttools_cluster_cells.R
57 lines (38 loc) · 1.7 KB
/
scyttools_cluster_cells.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env Rscript
require(docopt)
require(methods)
"
Usage:
scyttools_cluster_cells.R (-h | --help | --version)
scyttools_cluster_cells.R RDS OUT
Description: This script performs dimensionality reduction
Options:
--version Show the current version.
Arguments:
RDS Provide single cell experiment object Rdata file
OUT Provide output file
" -> doc
args <- docopt(doc)
source("scyttools_functions.R")
##########################################################################
############################ R code goes here ############################
##########################################################################
# load single cell data
load(args$RDS)
# perform graph based clustering
g <- buildSNNGraph(sce_glm_pca, k=10, use.dimred = 'GLM_PCA')
clust <- igraph::cluster_walktrap(g)$membership
cell_data_set <- new_cell_data_set(expression_data = counts(sce_glm_pca),
cell_metadata = colData(sce_glm_pca),
gene_metadata = rowData(sce_glm_pca))
reducedDim(cell_data_set, "UMAP") <- reducedDim(sce_glm_pca, "UMAP")
cell_data_set <- cluster_cells(cell_data_set, partition_qval = 0.05)
colData(sce_glm_pca)$clust <- factor(clust)
colData(sce_glm_pca)$supergroups <- factor(cell_data_set@clusters[["UMAP"]]$partitions)
colData(sce_glm_pca)$monocle_clusters <- factor(cell_data_set@clusters[["UMAP"]]$clusters)
## write out new SingleCellExperiment Object
save(sce_glm_pca,
file = args$OUT)
##########################################################################
############################ End code ############################
##########################################################################