This markdown document contains an attempt to demonstrate no differences between control and HI piglets using a variety of unsupervised machine learning algorithms: hierachical clustering, principal components and kmeans.
The best visualisations will be used in talks an presentations.
For brevity the data wrangling has been hidden.
## Warning in graphics:::plotHclust(n1, merge, height, order(x$order), hang, :
## "horiz" is not a graphical parameter
## Warning in graphics:::plotHclust(n1, merge, height, order(x$order), hang, :
## "horiz" is not a graphical parameter
## Warning in axis(2, at = pretty(range(height)), ...): "horiz" is not a
## graphical parameter
## Warning in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...):
## "horiz" is not a graphical parameter
## Warning in graphics:::plotHclust(n1, merge, height, order(x$order), hang, :
## "horiz" is not a graphical parameter
## Warning in graphics:::plotHclust(n1, merge, height, order(x$order), hang, :
## "horiz" is not a graphical parameter
## Warning in axis(2, at = pretty(range(height)), ...): "horiz" is not a
## graphical parameter
## Warning in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...):
## "horiz" is not a graphical parameter
## Bootstrap (r = 0.5)... Done.
## Bootstrap (r = 0.56)... Done.
## Bootstrap (r = 0.69)... Done.
## Bootstrap (r = 0.75)... Done.
## Bootstrap (r = 0.88)... Done.
## Bootstrap (r = 1.0)... Done.
## Bootstrap (r = 1.06)... Done.
## Bootstrap (r = 1.19)... Done.
## Bootstrap (r = 1.25)... Done.
## Bootstrap (r = 1.38)... Done.
## Bootstrap (r = 0.5)... Done.
## Bootstrap (r = 0.56)... Done.
## Bootstrap (r = 0.69)... Done.
## Bootstrap (r = 0.75)... Done.
## Bootstrap (r = 0.88)... Done.
## Bootstrap (r = 1.0)... Done.
## Bootstrap (r = 1.06)... Done.
## Bootstrap (r = 1.19)... Done.
## Bootstrap (r = 1.25)... Done.
## Bootstrap (r = 1.38)... Done.
Pre_PC <- prcomp(Pre_clean)
Post_PC <- prcomp(Post_clean)
ggplot(Pre_PC, aes(PC1, PC2, color = Condition)) +
geom_point(aes(shape=Condition, color = Condition), size=2) + # draw points
labs(title="HI Clustering Pre HI",
subtitle="With principal components PC1 and PC2 as X and Y axis",
caption="Source: HI+SC Project")
ggplot(Post_PC, aes(PC1, PC2, color = Condition)) +
geom_point(aes(shape=Condition, color = Condition), size=2) + # draw points
labs(title="HI Clustering Post HI",
subtitle="With principal components PC1 and PC2 as X and Y axis",
caption="Source: HI+SC Project")
row.names(df_pre) <- Pig
## Warning: Setting row names on a tibble is deprecated.
row.names(df_post) <- Pig
## Warning: Setting row names on a tibble is deprecated.
fviz_nbclust(df_pre, FUNcluster = kmeans, method = "wss", k.max = 10)
Pre_kmeans <- kmeans(df_pre, centers = 2, iter.max = 10, nstart = 1)
fviz_cluster(Pre_kmeans, df_pre, geom = "text", main = "Cluster plot pre-HI", ellipse = TRUE, ellipse.type = "norm", show.clust.cent = FALSE, repel = FALSE, , xlab = "Principal Component 1 (48.0% )", ylab = "Principal Component 2 (24.6%)")
fviz_nbclust(df_post, FUNcluster = kmeans, method = "wss", k.max = 10)
Post_kmeans <-kmeans(df_post, centers = 2, iter.max = 10, nstart = 1)
fviz_cluster(Post_kmeans, df_post, geom = "text", main = "Cluster plot post-HI", ellipse = TRUE, ellipse.type = "norm", show.clust.cent = FALSE, repel = TRUE, xlab = "Principal Component 1 (68.1%)", ylab = "Principal Component 2 (14.5%)")
## Too few points to calculate an ellipse