diff --git a/Schrick-Noah_CS-6643_Lab-2.R b/Schrick-Noah_CS-6643_Lab-2.R index 9942b46..bbac39c 100644 --- a/Schrick-Noah_CS-6643_Lab-2.R +++ b/Schrick-Noah_CS-6643_Lab-2.R @@ -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 diff --git a/Schrick-Noah_CS-6643_Lab-2.docx b/Schrick-Noah_CS-6643_Lab-2.docx index 14ed45c..f573acb 100644 Binary files a/Schrick-Noah_CS-6643_Lab-2.docx and b/Schrick-Noah_CS-6643_Lab-2.docx differ