Finalizing Part A

This commit is contained in:
Noah L. Schrick 2022-09-15 16:31:47 -05:00
parent ba1cdbc2a2
commit e2495046f8
2 changed files with 26 additions and 5 deletions

View File

@ -19,10 +19,10 @@ a <- list()
# each merged pair in a row
a$merge <- rbind(c(-1, -2), # +1 (A-B)
c(1,-3) , # +2 (A-B)-C
_______ , # +3 (D-E)
_______ , # +4 ((A-B)-C)-(DE)
_______) # +5 (((A-B)-C)-(DE))-F
c( 1, -3), # +2 (A-B)-C
c(-4, -5), # +3 (D-E)
c( 2, 3), # +4 ((A-B)-C)-(DE)
c( 4, -6)) # +5 (((A-B)-C)-(DE))-F
a$height <- c(1, 2, 1.5, 3, 4) # merge heights
a$order <- 1:6 # order of leaves
@ -46,7 +46,7 @@ plot(hc1,hang=-1)
## 4 - install and run WGCNA
# Install
install.packages("BiocManager")
if (!require("BiocManager")) install.packages("BiocManager")
library(BiocManager)
BiocManager::install("WGCNA")
@ -83,6 +83,27 @@ plotDendroAndColors(hc1,
## 2 - no supporting code
## 3 - Plot the dendrogram
# initialize an empty list that will contain fields of our hclust object
a <- list()
# encoding rules:
# negative numbers are leaves (A,B,...,E) -> (-1,-2,...,-5)
# positive are merged clusters (defined by row number in $merge)
# each merged pair in a row
a$merge <- rbind(c(-1, -2), # +1 (A-B)
c(1,-3) , # +2 (A-B)-C
_______ , # +3 (D-E)
_______ , # +4 ((A-B)-C)-(DE)
_______) # +5 (((A-B)-C)-(DE))-F
a$height <- c(1, 2, 1.5, 3, 4) # merge heights
a$order <- 1:6 # order of leaves
a$labels <- LETTERS[1:6] # labels of leaves as Letters
class(a) <- "hclust" # force a to be hclust object
# plot the tree
# plot knows that a is an hclust object and plots accordingly
plot(a,hang=-1) # or use plot(as.dendrogram(a))
## 4 - Verify results
# create distance matrix

Binary file not shown.