Final edits
This commit is contained in:
parent
26e4e4fe97
commit
798191249d
@ -38,8 +38,10 @@ my.dist1 <- read.table("distance_matrix.txt",sep="\t", header=T)
|
|||||||
rownames(my.dist1) = colnames(my.dist1)
|
rownames(my.dist1) = colnames(my.dist1)
|
||||||
my.dist1[lower.tri(my.dist1)] = t(my.dist1)[lower.tri(my.dist1)]
|
my.dist1[lower.tri(my.dist1)] = t(my.dist1)[lower.tri(my.dist1)]
|
||||||
hc1 <- hclust(as.dist(my.dist1), method="average")
|
hc1 <- hclust(as.dist(my.dist1), method="average")
|
||||||
|
hc1
|
||||||
plot(hc1,hang=-1)
|
plot(hc1,hang=-1)
|
||||||
|
|
||||||
|
|
||||||
## 2 - Paste the distance matrix in the report. Use header=T
|
## 2 - Paste the distance matrix in the report. Use header=T
|
||||||
|
|
||||||
## 3 - no supporting code
|
## 3 - no supporting code
|
||||||
@ -48,6 +50,7 @@ plot(hc1,hang=-1)
|
|||||||
# Install
|
# Install
|
||||||
if (!require("BiocManager")) install.packages("BiocManager")
|
if (!require("BiocManager")) install.packages("BiocManager")
|
||||||
library(BiocManager)
|
library(BiocManager)
|
||||||
|
if (!require("WGCNA"))
|
||||||
BiocManager::install("WGCNA")
|
BiocManager::install("WGCNA")
|
||||||
|
|
||||||
# load WGCNA and run on the hc1 dendrogram
|
# load WGCNA and run on the hc1 dendrogram
|
||||||
@ -61,7 +64,9 @@ dynamicMods = cutreeDynamic(
|
|||||||
minClusterSize = 2)
|
minClusterSize = 2)
|
||||||
names(dynamicMods) <- colnames(my.dist1)
|
names(dynamicMods) <- colnames(my.dist1)
|
||||||
|
|
||||||
## 5 - no supporting code
|
## 5 - identify clusters
|
||||||
|
dynamicMods
|
||||||
|
|
||||||
|
|
||||||
## 6 - show clustered data
|
## 6 - show clustered data
|
||||||
dynamicColors = labels2colors(dynamicMods) # colors might not work
|
dynamicColors = labels2colors(dynamicMods) # colors might not work
|
||||||
@ -91,18 +96,17 @@ a <- list()
|
|||||||
|
|
||||||
# each merged pair in a row
|
# each merged pair in a row
|
||||||
a$merge <- rbind(c(-1, -2), # +1 (A-B)
|
a$merge <- rbind(c(-1, -2), # +1 (A-B)
|
||||||
c(1,-3) , # +2 (A-B)-C
|
c(1, -4), # +2 (A-B)-D
|
||||||
_______ , # +3 (D-E)
|
c(2, -3)) # +3 ((A-B)-D)-C
|
||||||
_______ , # +4 ((A-B)-C)-(DE)
|
|
||||||
_______) # +5 (((A-B)-C)-(DE))-F
|
|
||||||
|
|
||||||
a$height <- c(1, 2, 1.5, 3, 4) # merge heights
|
a$height <- c(0.14, 0.305, 0.51) # merge heights
|
||||||
a$order <- 1:6 # order of leaves
|
a$order <- 1:4 # order of leaves
|
||||||
a$labels <- LETTERS[1:6] # labels of leaves as Letters
|
a$labels <- LETTERS[1:4] # labels of leaves as Letters
|
||||||
class(a) <- "hclust" # force a to be hclust object
|
class(a) <- "hclust" # force a to be hclust object
|
||||||
# plot the tree
|
# plot the tree
|
||||||
# plot knows that a is an hclust object and plots accordingly
|
# plot knows that a is an hclust object and plots accordingly
|
||||||
plot(a,hang=-1) # or use plot(as.dendrogram(a))
|
plot(a) # or use plot(as.dendrogram(a))
|
||||||
|
|
||||||
|
|
||||||
## 4 - Verify results
|
## 4 - Verify results
|
||||||
@ -121,7 +125,7 @@ test$merge
|
|||||||
test$height
|
test$height
|
||||||
test$order
|
test$order
|
||||||
test$labels<-LETTERS[1:4]
|
test$labels<-LETTERS[1:4]
|
||||||
plot(test,hang=-1)
|
plot(test)
|
||||||
|
|
||||||
#### Part D - MDS
|
#### Part D - MDS
|
||||||
## 1 - Show the 2D MDS
|
## 1 - Show the 2D MDS
|
||||||
@ -134,4 +138,4 @@ plot(x,y,main="Multi-dimensional Scaling",
|
|||||||
xlab="MDS dimension-1", ylab="MDS dimension-2", pch=NA,asp=1)
|
xlab="MDS dimension-1", ylab="MDS dimension-2", pch=NA,asp=1)
|
||||||
# pch specifies plot symbol; we want null because we are using letter next
|
# pch specifies plot symbol; we want null because we are using letter next
|
||||||
# plot the text labels instead of symbols:
|
# plot the text labels instead of symbols:
|
||||||
text(x,y,test$labels,cex=1)
|
text(x,y,test$labels,cex=1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user