-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path1_umap_cluster_assign.R
83 lines (62 loc) · 2.66 KB
/
1_umap_cluster_assign.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
suppressPackageStartupMessages({library(monocle3)
library(dplyr)
library(viridis)
library(reshape2)
library(ggplot2)
library(data.table)})
DelayedArray:::set_verbose_block_processing(TRUE)
options(DelayedArray.block.size=1000e6)
# this notebook has been updated to do the analysis with the newest version of monocle 3 (v0.2.0)
# Load data ---------------------------------------------------------------
cds = readRDS("useful_files/yeast_del_strain_monocle3_cds.RDS")
# Preprocess and run UMAP dimensionality reduction ------------------------
cds = detect_genes(cds)
cds = preprocess_cds(cds, num_dim = 100, norm_method = "log")
cds = reduce_dimension(cds,
preprocess_method = "PCA",
reduction_method = "UMAP",
max_components = 2,
umap.min_dist = 0.05,
umap.n_neighbors = 10L,
umap.metric = "cosine")
cds = cluster_cells(cds, resolution = 1e-4, k = 3)
saveRDS(cds, "useful_files/yeast_del_strain_monocle3_cds.RDS")
# plot strain umap
plot_cells(cds, color_cells_by = "cluster_50",
cell_size = 0.75,
label_groups_by_cluster = F,
label_cell_groups = T,
group_label_size = 4)
# plot functional groups
plot_cells(cds, color_cells_by = "cluster",
label_cell_groups = F,
group_label_size = 4) +
theme(legend.position = "none") +
facet_wrap(~kemmeren_functional_group)
# plot expression of specific genes
plot_cells(cds, genes = "YCH1",
cell_size = 0.75, norm_method = "size_only") +
scale_color_viridis_c()
# Visualize sub-clusters ---------------------------------------------------------
# extract large main cluster (clusters 1 - 10) and re-analyze
cds_sub = cds[,colData(cds)$cluster_50 == 3,]
cds_sub = detect_genes(cds_sub)
cds_sub = preprocess_cds(cds_sub, num_dim = 20, norm_method = "log")
cds_sub = reduce_dimension(cds_sub,
preprocess_method = "PCA",
reduction_method = "UMAP",
max_components = 2,
umap.min_dist = 0.05,
umap.n_neighbors = 10L,
umap.metric = "cosine")
cds_sub = cluster_cells(cds_sub, resolution = 1e-4, k = 3)
# plot UMAP with sub-cluster designations from paper
plot_cells(cds_sub, color_cells_by = "sub_cluster",
cell_size = 1,
label_groups_by_cluster = F,
label_cell_groups = T,
group_label_size = 4)
# plot specific gene expression
plot_cells(cds_sub, genes = "ATP8",
cell_size = 1.25, norm_method = "size_only") +
scale_color_viridis_c()