Hi maho4822,
The "cannot find path" error in PopGenome's readData is almost certainly due to the space in your folder name ("VCF copies"). Rename the folder to something without spaces, e.g. "VCF_files", and ensure your VCF files are uncompressed and inside it. If you have a GFF folder, match the filenames exactly (e.g. "file1.vcf" pairs with "file1.gff").
PopGenome works fine with R 4.0.3 (and later versions), so you should be able to proceed there. Install it via BiocManager::install("PopGenome") if needed. Here's simple code to read your data and calculate pi (nucleotide diversity) for the whole genome—assuming all three VCFs are in the folder and represent one population for now (adjust set.populations if splitting samples into groups):
library(PopGenome)
# Read data (omit gffpath if no GFF files)
GENOME.class <- readData("VCF_files", format = "VCF", gffpath = "GFF")
# Set population(s)—replace with your sample names from get.individuals(GENOME.class)
GENOME.class <- set.populations(GENOME.class, list(c("sample1", "sample2")), diploid = TRUE)
# Calculate diversity stats
GENOME.class <- diversity.stats(GENOME.class)
# View pi
get.diversity(GENOME.class)
# Or directly: GENOME.class@nuc.diversity.within
For windowed pi (e.g. 10kb non-overlapping), add this before diversity.stats:
GENOME.class <- sliding.window.transform(GENOME.class, width = 10000, jump = 10000, type = 2)
GENOME.class <- diversity.stats(GENOME.class)
pi_values <- GENOME.class@nuc.diversity.within / 5000 # Normalise by approx. window size in bp
head(pi_values)
Regarding phi: if you mean a differentiation statistic like PhiST (haplotype-based FST), PopGenome doesn't compute it directly—try the hierfstat or pegas packages for FST alternatives, or use command-line VCFtools (vcftools --vcf yourfile.vcf --weir-fst-pop pop1.txt --weir-fst-pop pop2.txt --out out) if your VCFs are per population. If it's something else, could you clarify?
VCFtools and DnaSP aren't R packages (VCFtools is Perl-based CLI; DnaSP is standalone software), so compatibility isn't an issue there—update to R 4.4+ anyway for better support.
Kevin
Have you found a solution to this yet? I am having the same issue!
"cannot find path
A bit late here, but for anyone reading this, this error likely comes from having a space in your filename.