-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2b_unsupervised.R
More file actions
38 lines (30 loc) · 1.11 KB
/
2b_unsupervised.R
File metadata and controls
38 lines (30 loc) · 1.11 KB
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
# Unsupervised Hierarchical Clustering
# Last Update: 01/20/2022
# Copyright (C) 2023-4 Y. David Chen
rm(list=ls())
library(matrixStats)
UTIL_DIR <- "*************PATH MASKED*************"
source(paste0(UTIL_DIR,"utils_gen.R"))
source(paste0(UTIL_DIR,"utils_hm.R"))
load(paste0(DIR,"230120_objects.RData"))
## Reusable sample annotations for heatmaps:
SAMP_ANNOT <- meta[ , c("HeartFailure","Subtype","Sex","AgeGroup","PrincipalGroup")]
rownames(SAMP_ANNOT) <- meta$GEO_accession
## Inter-dataset variance distribution:
sampSds <- rowSds(expr)
plot(sort(sampSds), main="Inter-sample SD")
summary(sampSds)
sum(sampSds >= 0.98998)
binaryHcTree <- wrapper_hm(expr[sampSds >= 0.98998,], 2, SAMP_ANNOT)
## Extract hierarchical clusters:
resClust <- getClusters(binaryHcTree, 2, "GEO_accession")
meta <- merge(meta, resClust, by="GEO_accession")
meta$Cluster <- paste0("Cluster", meta$Cluster)
## Test overlap of Expression Cluster 1 w/ PCGroup B:
cTabConcord <- table(
isClust1 = meta$Cluster=="Cluster1",
isGroupB = meta$PrincipalGroup=="B"
)
cTabConcord
round( 100*prop.table(cTabConcord, 2), 1 )
mcnemar.test(cTabConcord)