7. Convert vcf to genind - DianaCarolinaVergara/SNPs_pipeline GitHub Wiki
Convert vcf file to genind and the distance matrix
(Pairwise distances between individuals present in the genind object)
- Convert VCF to
genind
object
load package
poppr
- Generate a UPGMA tree
We obtain an asymmetric distance matrix
genlight_Muricea <- vcfR2genlight(Muricea_filtered_no_clone_DP_Miss90_MAF_vcf_last)
library(poppr)
Muricea_tree_FINAL <- aboot(genlight_Muricea, tree = "upgma", distance = bitwise.dist, sample = 100, showtree = T, cutoff = 50, quiet = T)
genind_Muricea <- vcfR2genind(Muricea_filtered_no_clone_DP_Miss90_MAF_vcf_last)
genind_Muricea
Muricea_distances_FINAL.dist<-diss.dist(genind_Muricea, mat=TRUE, percent = TRUE)
Write distance dataframe as a table
Convert this dataframe to be able to read in another programs
Excel
write.table(Muricea_distances_FINAL.dist, file="Muricea_distances_FINAL.dist.txt", col.names = TRUE, row.names = TRUE, quote = FALSE)
write.csv(Muricea_distances_FINAL.dist, file="Muricea_distances.dist_FINAL.csv", col.names = TRUE, row.names = TRUE, quote = FALSE)