Skip to content

Instantly share code, notes, and snippets.

@vd4mmind
Forked from danielecook/vcf_downgrade.sh
Created May 3, 2016 16:54
Show Gist options
  • Save vd4mmind/999c4d663c8d73d671467f130283b5cf to your computer and use it in GitHub Desktop.
Save vd4mmind/999c4d663c8d73d671467f130283b5cf to your computer and use it in GitHub Desktop.
Downgrade VCF 4.2 to VCF 4.1 for viewing in IGV
# If you are trying to view VCF 4.2 files in IGV - you may run into issues. This function might help you.
# This script will:
# 1. Rename the file as version 4.1
# 2. Replace parentheses in the INFO lines (IGV doesn't like these!)
function vcf_downgrade() {
outfile=${1/.bcf/}
outfile=${outfile/.gz/}
outfile=${outfile/.vcf/}
bcftools view --max-alleles 2 -O v $1 | \
sed "s/##fileformat=VCFv4.2/##fileformat=VCFv4.1/" | \
sed "s/(//" | \
sed "s/)//" | \
sed "s/,Version=\"3\">/>/" | \
bcftools view -O z > ${outfile}.dg.vcf.gz
tabix ${outfile}.dg.vcf.gz
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment