This is a test version of Biostars. For the public version, visit https://www.biostars.org.
how to cut the gz. file by chromosome

I have gz. file of individual. But is too big to merge all individual, I want to cut the gz. file by chromosome then to merge. I have tried the following, but it product VCF file. I want it to product gz. file, so it merge much quick.

./vcftools --gzvcf /home/chung/seqdataQC/NGS2015011D_S1.genome.vcf.gz --chr chr1 --out /home/chung/seqdataQC/NGS2015011D/NGS2015011D_chr1 --recode

How can I do with vcftools ??

gz vcftools chr

gz file means that it is gunzipped, similar as zip file on windows. It is compressed to save diskspace, and has nothing to do with real bioinformatics.

use gzip command to make gz files of your vcf file.

gzip your.vcf

2 answers

first if it is not bgzip file

bgzip -c myvcf.vcf > myvcf.vcf.gz

tabix -p vcf myvcf.vcf.gz
for i in {1..20}
    do
       tabix myvcf.vcf.gz chr$i | bgzip >  chr$i.vcf.gz
    done

or


unziped
There is no header in this one

 gawk '/^[0-22]/{print >$1".vcf"}' myvcf.vcf  


 Java -jar snpSift splitChr myvcf.vcf

it' s there something wrong?? I already have gz.file & index.

[c

hung@1gIBMgX365073 NGS2015011B]$ for i in {1..20}
>     do
>        tabix NGS2015011B_S1.genome.vcf.gz chr$i | gzip  chr$i.vcf.gz
>     done
gzip: chr1.vcf.gz: No such file or directory
gzip: chr2.vcf.gz: No such file or directory
gzip: chr3.vcf.gz: No such file or directory
gzip: chr4.vcf.gz: No such file or directory
gzip: chr5.vcf.gz: No such file or directory
gzip: chr6.vcf.gz: No such file or directory
gzip: chr7.vcf.gz: No such file or directory
gzip: chr8.vcf.gz: No such file or directory
gzip: chr9.vcf.gz: No such file or directory
gzip: chr10.vcf.gz: No such file or directory
gzip: chr11.vcf.gz: No such file or directory
gzip: chr12.vcf.gz: No such file or directory
gzip: chr13.vcf.gz: No such file or directory
gzip: chr14.vcf.gz: No such file or directory
gzip: chr15.vcf.gz: No such file or directory
gzip: chr16.vcf.gz: No such file or directory
gzip: chr17.vcf.gz: No such file or directory
gzip: chr18.vcf.gz: No such file or directory
gzip: chr19.vcf.gz: No such file or directory
gzip: chr20.vcf.gz: No such file or directory

my bad It should be like:

tabix myvcf.vcf.gz chr$i | gzip > chr$i.vcf.gz

and if you want to be tar.gz use

tabix myvcf.vcf.gz chr$i | gzip -9 > chr$i.vcf.tar.gz

Now it shall work

If this answer solved your issue kindely accept it as an answer.

but when I try to create index, it has follwing error??

[chung@1gIBMgX365073 perl]$ tabix -p vcf /home/chung/seqdataQC/NGS2015011B/NGS2015011B_chr1.recode.vcf.gz
[tabix] was bgzip used to compress this file? /home/chung/seqdataQC/NGS2015011B/NGS2015011B_chr1.recode.vcf.gz

ok instead of using gzip use bgzip like:

tabix myvcf.vcf.gz chr$i | bgzip > chr$i.vcf.gz

When I merge the chr1 of individuals it would have the following error, what's the problem???

Could not parse the fileformat version string [chr1 1 . N . . LowGQX END=10120;BLOCKAVG_min30p3a GT:GQX:DP:DPF .:.:0:0], assuming VCFv4.2 Broken VCF header, no column names? at /usr/lib64/perl5/Vcf.pm line 172, <__ANONIO__> line 1. Vcf::throw('Vcf4_2=HASH(0x200b550)', 'Broken VCF header, no column names?') called at /usr/lib64/perl5/Vcf.pm line 866 VcfReader::_read_column_names('Vcf4_2=HASH(0x200b550)') called at /usr/lib64/perl5/Vcf.pm line 601 VcfReader::parse_header('Vcf4_2=HASH(0x200b550)') called at ./vcf-merge line 183 main::init_cols('HASH(0x23f7300)', 'Vcf4_2=HASH(0x200ace0)') called at ./vcf-merge line 279 main::merge_vcf_files('HASH(0x23f7300)') called at ./vcf-merge line 12

I am not sure but you are missing the header?

Broken VCF header

I know but it's much easy to merge.

Please use ADD COMMENT or ADD REPLY to reply to earlier answers, as such this thread remains logically structured and easy to follow.

Log in to answer this question.