VCF to Chromosomal‐Level PLINK2 Binary File Format Conversion - jvtalwar/GRIEVOUS GitHub Wiki

To convert a composite (i.e., full-dataset) VCF to the grievous expected PLINK2 binary file format, you may find the following script helpful:

#! /bin/bash
# ADD JOB SCHEDULER (e.g., Slurm, SGE) PARAMS HERE IF NEEDED

vcfPath=YOUR_PATH_TO_VCF #<-- replace this with the path to your VCF
newPath=YOUR_PATH_TO_WRITE_CHR_LEVEL_PLINK2_BINARIES #<-- replace this with the directory where you would like to write CHR level plink2 binaries
plink2=YOUR_PATH_TO_PLINK2 #<-- replace this with the corresponding pointer to your installation of PLINK2

for chr in {1..22};
do
$plink2 --vcf $vcfPath --chr $chr --make-pgen --out $newPath/chr$chr;
done

$plink2 --vcf $vcfPath --chr x --make-pgen --out $newPath/chrX

For other file-formats (i.e., non-VCFs), you will likely need to update plink2 --vcf flag with your desired file format flag, but the conversion should more or less follow the above format.

  • Specifically, employing the --make-pgen flag will convert your file-type to the grievous expected PLINK2 binary file format, and the --chr flag will ensure your output files are partitioned at the chromosome-level resolution.