This is a test version of Biostars. For the public version, visit https://www.biostars.org.
extract specific population (vcf) from 1000 genomes - keep option

hi all,

how can I extract 1000 genome data in vcf format of a specific population using vcftools. Currently I am using tabix to download the data

tabix -fh ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/release/20110521/ALL.chr
echo ${REGION} | awk -F [\:] '{print $1}'`.phase1_release_v3.20101123.snps_indels_svs.genotypes.vcf.gz $REGION > temp.vcf

and then include only the individuals from european population (CEU,GBR,FIN,TSI); through (--keep) option by providing a txt file (pop_file) including their individualIDs,,,

vcftools --vcf temp.vcf --keep $POP_FILE --recode > temp.vcf

where am I going wrong - As I producing the initial Vcf file but not after the filtering for specific pop.

Any suggestions PLEASE

sequencing linux vcftools

1 answer

When using

vcftools --vcf temp.vcf --keep $POP_FILE --recode > temp.vcf

the file temp.vcf will be overwritten before vcftools is started.

You're working with an empty file

Use

vcftools --vcf temp.vcf --keep $POP_FILE --recode > temp2.vcf

Thanks... I tried to change the name of the VCF file (to temp2) generated after keep option,,,,

But it does not create the temp2 file (while the recode.vcf file is generated properly after filtering for specific population)

here is the code again

#select specific population
if [ "$POP_FILE" != "" ]; then
    vcftools --vcf temp.vcf --keep $POP_FILE --recode --out popfilter > temp2.vcf 2> /dev/null
else
    cp -f temp.vcf temp2.vcf
fi

You're redirecting stderr to /dev/null what was the content of the error message?

Log in to answer this question.