Commands to manipulate VCF files - SouthGreenPlatform/tutorials GitHub Wiki
Authors | Christine Tranchant-Dubreuil |
---|---|
Research Unit | UMR DIADE |
Institut |
Description
This page describes some tools to manipulate and to extract easily informations from vcf file. We need, in this tutorial:
- a vcf file
- a reference file used for the mapping step.
gatk
,bcftools
Keywords : Files format : vcf
Date : 10/03/2017
Summary
- Extracting list of samples from a vcf file with
grep
andcut
commands - Extracting a subset of samples from a multigenome vcf file with
GATK selectVariants
- Extracting a subset of samples from a multigenome vcf file with
bcftools
- Calculating the nucleotide diversity from a vcf file with
vcftools
grep
and cut
commands
Extracting list of samples from a vcf file with one line with all samples
grep "#CHROM" output | cut -f 10-
one line by sample
grep "#CHROM" output | cut -f 10- | xargs -n 1
GATK selectVariants
Extracting a subset of samples from a multigenome vcf file with Select two samples out of a vcf with many samples
java -Xmx12g -jar /usr/local/gatk-3.6/GenomeAnalysisTK.jar -T SelectVariants -R reference.fa -V inputFileName.vcf -o outputFilename.vcf -sn sample1 -sn sample2
https://www.broadinstitute.org/gatk/guide/article?id=1601 for help creating in.
Rk : if you get the following error message "Fasta dict file ... for reference ... does not exist", please seeSelect genotypes from a file containing a list of samples to include
java -Xmx12g -jar /usr/local/gatk-3.6/GenomeAnalysisTK.jar -T SelectVariants -R reference.fa -V inputFileName.vcf -o outputFileName.vcf --sample_file barthii.only.RG.list --ALLOW_NONOVERLAPPING_COMMAND_LINE_SAMPLES
Select genotypes from a file containing a list of samples to exclude
java -Xmx12g -jar /usr/local/gatk-3.6/GenomeAnalysisTK.jar -T SelectVariants -R reference.fa -V inputFileName.vcf -o outputFileName.vcf --exclude_sample_file barthii.only.RG.list --ALLOW_NONOVERLAPPING_COMMAND_LINE_SAMPLES
Rk : if you get the following error message : "Bad input: Samples entered on command line (through -sf or -sn)) that are not present in the VCF", run with --ALLOW_NONOVERLAPPING_COMMAND_LINE_SAMPLES
bcftools
Extracting a subset of samples from a multigenome vcf file with bcftools
Select genotypes from a file containing a list of samples to include with bcftools view -S barthii.only.RG.list inputFileName.vcf --force-samples -o outputFilename.vcf`
vcftools
Calculating the nucleotide diversity from a vcf file with vcftools --vcf inputFilename.vcf --out outputFilename.PI --window-pi 100000 --remove-filtered-all
grep "PI" OgOb-all-MSU7-CHR2.GATKSV.VCFTOOLS.stats-100000.windowed.pi -v | awk '{ sum+=$5; print $5,"; ",sum , "* ", NR ; } END { print "PI average :", sum / NR; }'