-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmk_focus_view.R
51 lines (34 loc) · 1.1 KB
/
mk_focus_view.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
library(Seurat)
wbm <- readRDS('data/wbm_clustered_filtered_named.rds')
wbm.list <- SplitObject(wbm, split.by = 'cluster_IDs')
mk <- wbm.list$MK
mk@meta.data
dim(mk@meta.data)
dim(mk)
summary(as.factor(mk@meta.data$state))
head(mk@meta.data)
mk<- FindVariableFeatures(mk, selection.method = 'vst', nfeatures = 1000)
top10 <- head(VariableFeatures(mk), 10)
top10
all.genes <- row.names(mk)
mk <- ScaleData(mk, features = all.genes)
mk <- RunPCA(mk, features = VariableFeatures(object = mk))
DimPlot(mk, reduction = 'pca', group.by = 'state')
ElbowPlot(mk)
mk <-FindNeighbors(mk, dims = 1:10)
lst_of_resolutions <- seq(0,1, by = .05)
resul = c()
cnt = 1
for (i in lst_of_resolutions){
#print(i)
x <- FindClusters(mk, resolution = i)
resul[cnt] <- length(levels(x$seurat_clusters))
cnt = cnt + 1
}
plot(resul)
lst_of_resolutions[12]
mk <- FindClusters(mk, resolution = 0.55)
mk <- RunUMAP(mk, dims = 1:10)
DimPlot(mk, reduction = 'umap', label = T) + NoLegend()
DimPlot(mk, reduction = 'umap', group.by = 'state')
DimPlot(mk, reduction = 'umap', label = T, split.by = 'state')