diff --git a/1-clustering.R b/1-clustering.R index ab8a03002b3fe98b9bdad14e6bdf9ff029c42745..7c1ec76fbf7c2691de7474404a7ced94a7e540e0 100644 --- a/1-clustering.R +++ b/1-clustering.R @@ -70,16 +70,16 @@ pr.out <- prcomp(x = (t(trait.matrix)), center = T, scale. = F) pc.df <- data.frame(pc1 = pr.out$x[, 1], pc2 = pr.out$x[, 2], - stage = sample.stage, - population = c(rep('parent', 16), rep('RIL', 164))) + stage = as.character(sample.stage), + population = substring(colnames(trait.matrix), 1, 3)) pc.sum <- summary(pr.out) pc1.var <- round(pc.sum$importance[2, 'PC1'] * 100, 2) pc2.var <- round(pc.sum$importance[2, 'PC2'] * 100, 2) - pca.all <- ggplot(pc.df, aes(x = pc1, y = pc2, color = factor(stage, level = c('pd', 'ar', 'im', 'rp')))) + + pca.all <- ggplot(pc.df, aes(x = pc1, y = pc2, color = factor(stage, level = c('parent', 'pd', 'ar', 'im', 'rp')))) + geom_point(aes(shape = population)) + scale_colour_manual(values = c('#ccbb44', '#228833', '#4477aa', '#cc3311')) + - scale_shape_manual(values = c(17, 19)) + + scale_shape_manual(values = c(2, 19, 6)) + labs(x = paste0("PC1 (", pc1.var, "%)"), y = paste0("PC2 (", pc2.var, "%)")) + labs(colour = 'stage') + theme(text = element_text(size = 10), @@ -101,7 +101,7 @@ units = 'px', res = 300, compression = 'lzw') - pca.all + print(pca.all) dev.off() # PCA per stage ####