Create a symbolic link to the variants file:
ln -s /data/PwaniGenomics/variants.vcf.gz
The variants file can also be downloaded from the Wildlife Genomics 4 Zenodo dataset .
Apply quality-based filters to retain high-confidence variants. Remove all variants with Q < 30, GQ < 30, remove all INDELs, and retain only variants that are flagged as "PASS".
Remove any variant that deviates from HWE with a chi-square P value of less than 0.01.
Extremely rare alleles can sometimes be sequencing artefacts. For example, an allele that appears only once or twice in the dataset could be caused by a sequencing error. Removing alleles that occur fewer than 3 times helps reduce the influence of extremely rare variants.
Remove individuals with more than 98% missing data.
Extract and save the number of variants remaining at each missingness threshold from 0.1 to 0.9.
Filter out variants that are not commonly genotyped across individuals.
variant_counts.txt Using ggplot2 in RThis retains variants that are present in at least 50% of individuals.
Use R or Python to compute the 0.025 and 0.975 quantiles and filter sites accordingly.
Calculate the mean depth per variant.
Convert the filtered VCF file to PLINK format and perform PCA.
The Wildlife Genomics 4 dataset contains the pre-generated variants file used for this exercise.
Variants file:
variants.vcf.gz
Zenodo dataset: https://zenodo.org/records/21871083