TOM and Dynamic Tree Cut

This commit is contained in:
Noah L. Schrick 2022-03-21 23:29:20 -05:00
parent 1bd92a734d
commit fb9b7b8e5e

View File

@ -40,9 +40,9 @@ x2_clusters <- ifelse(x2>0,1,-1)
# Plotting # Plotting
V(g1)$color <- ifelse(x1_clusters>0,"green","yellow") V(g1)$color <- ifelse(x1_clusters>0,"green","yellow")
V(g1)$size <- 50*abs(x1) #V(g1)$size <- 80*abs(x1)
V(g2)$color <- ifelse(x2_clusters>0,"green","yellow") V(g2)$color <- ifelse(x2_clusters>0,"green","yellow")
V(g2)$size <- 50*abs(x2) V(g2)$size <- 10
plot(g1, main=paste(g1.netname, " Laplace Spectral Clustering")) plot(g1, main=paste(g1.netname, " Laplace Spectral Clustering"))
plot(g2, main=paste(g2.netname, " Laplace Spectral Clustering"), plot(g2, main=paste(g2.netname, " Laplace Spectral Clustering"),
vertex.label=NA) vertex.label=NA)
@ -77,6 +77,32 @@ plot(karate,vertex.size=10,
###################### Part 4: TOM and Dynamic Tree Cut ###################### ###################### Part 4: TOM and Dynamic Tree Cut ######################
# Next smallest eig
y1 <- eigen(g1.Lap)$vectors[,n1-2] # get n-2 column
names(y1) <- names(V(g1))
y1_val <- eigen(g1.Lap)$values[n1-2]
y2 <- eigen(g2.Lap)$vectors[,n2-2] # get n-2 column
names(y2) <- names(V(g2))
y2_val <- eigen(g2.Lap)$values[n2-2]
# Distance in the 2D Laplacian Eig-Space
lap_dist1 <- dist(cbind(x1,y1))
lap_dist2 <- dist(cbind(x2,y2))
# Use hierachical clustering of distance matrix
lap_tree1 <- hclust(lap_dist1)
lap_tree2 <- hclust(lap_dist2)
# Use WGCNA to dynamically decide how many clusters
cutreeDynamicTree(lap_tree1)
cutreeDynamicTree(lap_tree2)
# TOM
g1.TOM <- TOMsimilarity(as.matrix(g1.adj))
g2.TOM <- TOMsimilarity(as.matrix(g2.adj))
g1.TOM
g2.TOM
TOMplot(g1.TOM, lap_tree1, main=paste(g1.netname, " Heatmap Plot"))
TOMplot(g2.TOM, lap_tree2, main=paste(g2.netname, " Heatmap Plot"))
################################ Part 5: UMAP ################################ ################################ Part 5: UMAP ################################