diff --git a/snp_pca_static.R b/snp_pca_static.R index 2d988eb..aab5e57 100755 --- a/snp_pca_static.R +++ b/snp_pca_static.R @@ -74,3 +74,38 @@ if (!is.na(pops_file)) { file.remove("temp.gds") dev.off() + +##create matrix with pairwise euclidean distance +mat <- dist(tab, method="euclidean", diag = F, upper =F, p=2) +distance_matrix <- as.matrix(dist(mat)) +write.table(distance_matrix, file = "pairwise_distance_matrix.txt", sep = "\t", row.names = TRUE, col.names = NA) + +#list first 6 eigen values +head_eigen <- as.data.frame(head(round(pc.percent, 2))) +head_eigen$index <- c("1","2","3","4","5","6") +colnames(head_eigen) <- c("varexp","pcindex") + +#combined plot - paiwise pca + eigen values plot +library(pryr) +library(grid) +png(paste("pca_combined_plot", ".png", sep="")) + #plot pairwise pca using the first four vectors +p1 %