bashvcftools

Bash script for pairwise comparisons


I would like to write a bash script to do a pairwise calculation with my files.

I have a fixed file in a directory and a series of files that I want to use them for pairwise comparisons.

For example:

The name of the fixed file is: Genome.vcf The name of the files for the pairwise calculations that are all in one directory: ind_GER, ind_ENG, ind_MRO

I have come up with the following script:

#!/bin/bash

for pop1 in $(find ind_*)
do
for pop2 in $(find ind_*)
do

 vcftools --gzvcf PATH/Genome.vcf --weir-fst-pop $pop1 --weir-fst-pop $pop2 --out $pop1_$pop2_fst

done
done

The error that I get is:

Error: Requested Missing Argument

Obviously, I am getting something wrong, I'd be very grateful if you could help with this, thanks.


Solution

  • Change this:

    --out $pop1_$pop2_fst
    

    for:

    --out ${pop1}_${pop2}_fst
    

    _ is a valid character in a variable name.