how to cut the gz. file by chromosome
2
0
Entering edit mode
7.7 years ago
chengyi31000 ▴ 10

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 • 3.9k views
ADD COMMENT
1
Entering edit mode

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
ADD REPLY
3
Entering edit mode
7.7 years ago
Medhat 9.8k

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
ADD COMMENT
0
Entering edit mode

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
ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

OK thank you! It's work!

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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
ADD REPLY
1
Entering edit mode

ok instead of using gzip use bgzip like:

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

ADD REPLY
0
Entering edit mode

Thank you very much!!!!!!!

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

I am not sure but you are missing the header?

Broken VCF header

ADD REPLY
0
Entering edit mode
7.7 years ago
chengyi31000 ▴ 10

I know but it's much easy to merge.

ADD COMMENT
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 2091 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6