Does the VCF have to be sorted like SAM/BAM does?
Can anyone tell me how to generate vcf.gz file and its index file vcf.gz.tbi in 1000 Genomes Project?
ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/release/20110521/
4 answers
bgzip -c file.vcf > file.vcf.gz
tabix -p vcf file.vcf.gz
Yes, tabix requires sorted input files. I don't think the sorting order matters, but records must be grouped together by rows.
You mean numeric or alphanumeric by chromosome in ascending or descending order plus numeric by position ascending or descending order? I can't think how else sorting order could not matter.
Yes. To clarify, I think you just need your chromosomes grouped together, and then records for each chromosome need to be sorted in ascending coordinate order.
I have a script which does this using a VCF stream on stdin:
#!/bin/bash
file=$1
bgzip >$file
tabix -f -p vcf $file
I found I was always writing the same lines over and over when indexing VCF files. You can use it like this:
cat uncompressed.vcf | bgziptabix compressed.vcf.gz
bgzip file.vcf # or: bcftools view file.vcf -Oz -o file.vcf.gz
tabix file.vcf.gz # or: bcftools index file.vcf.gz
this is convenient where tabix and bgzip are not installed. saw this from: https://github.com/samtools/bcftools/issues/668
bgzip genotypes.vcf && tabix -p vcf genotypes.vcf.gz
see details if you need to:
Log in to answer this question.