library(labdsv) library(vegan) library(stats) library(ade4) library(grid) library(factoextra) library(ggplot2) # function multiplot multiplot <- function(..., plotlist=NULL, file, cols=1, layout=NULL) { require(grid) # Make a list from the ... arguments and plotlist plots <- c(list(...), plotlist) numPlots = length(plots) # If layout is NULL, then use 'cols' to determine layout if (is.null(layout)) { # Make the panel # ncol: Number of columns of plots # nrow: Number of rows needed, calculated from # of cols layout <- matrix(seq(1, cols * ceiling(numPlots/cols)), ncol = cols, nrow = ceiling(numPlots/cols)) } if (numPlots==1) { print(plots[[1]]) } else { # Set up the page grid.newpage() pushViewport(viewport(layout = grid.layout(nrow(layout), ncol(layout)))) # Make each plot, in the correct location for (i in 1:numPlots) { # Get the i,j matrix positions of the regions that contain this subplot matchidx <- as.data.frame(which(layout == i, arr.ind = TRUE)) print(plots[[i]], vp = viewport(layout.pos.row = matchidx$row, layout.pos.col = matchidx$col)) } } } setwd("D:/Tulipa/Saratov") getwd() ISSRinfo<- read.delim2("all_tulips_matrix_info.txt", row.names = "Ind") attach(ISSRinfo) names(ISSRinfo) ISSR<- read.delim2("all_tulips_matrix.txt", row.names = "Ind") attach(ISSR) names(ISSR) issrpca<- dudi.pca(ISSR,center =FALSE, scale=FALSE, scannf =FALSE, nf=10) issrpca ggtable<- data.frame(issrpca$li, row.names =rownames(issrpca$li)) attach(ggtable) ggtableeig<- data.frame(issrpca$eig, row.names =rownames(issrpca$eig)) attach(ggtable) ggplot(ggtable, aes(Axis1, Axis2, label= rownames(ggtable)))+ geom_point(size=6)+geom_text(check_overlap = F, hjust=0, nudge_x = 0.05, size=12, aes(colour=factor(Pop)))+ ggtitle("ISSR Analysis" ,subtitle = "Components 1 and 2")+ labs(x="Component 1")+ labs(y="Component 2")+ theme(plot.title = element_text(size = 60))+ theme(plot.subtitle = element_text(size = 40)) ggplot(ggtable, aes(Axis1, Axis3, label= rownames(ggtable)))+ geom_point(size=6)+geom_text(check_overlap = F, hjust=0, nudge_x = 0.05, size=12, aes(colour=factor(Pop)))+ ggtitle("ISSR Analysis" ,subtitle = "Components 1 and 3")+ labs(x="Component 1")+ labs(y="Component 3")+ theme(plot.title = element_text(size = 60))+ theme(plot.subtitle = element_text(size = 40)) ggplot(ggtable, aes(Axis2, Axis3, label= rownames(ggtable)))+ geom_point(size=6)+geom_text(check_overlap = F, hjust=0, nudge_x = 0.05, size=12, aes(colour=factor(Pop)))+ ggtitle("ISSR Analysis" ,subtitle = "Components 2 and 3")+ labs(x="Component 2")+ labs(y="Component 3")+ theme(plot.title = element_text(size = 60))+ theme(plot.subtitle = element_text(size = 40)) tabeig<- data.frame(get_eig(issrpca)) fviz_eig(issrpca) library(xlsx) write.xlsx(tabeig, "D:/Tulipa/Saratov/Tulipa_Saratov_Leweke.xlsx")