Easy way to split VCF file by chromosome
2
1
Entering edit mode
4 months ago

Hi,

Im trying to submit a job on the TOPMED/Michigan imputation server, but it returns an error saying that I need to split my VCF by chromosome

Is there an easy way to do this? Will bcftools help?

sequence TOPMED chromosome Imputation SNP • 1.1k views
ADD COMMENT
3
Entering edit mode
4 months ago
bcftools index -s in.vcf.gz | cut -f 1 | while read C; do bcftools view -O z -o split.${C}.vcf.gz in.vcf.gz "${C}" ; done
ADD COMMENT
0
Entering edit mode

omg thanks!!

ADD REPLY
0
Entering edit mode

Hello, I tried to do this

bcftools index -s /scratch/Databases/GTEx/downloaded/dbGAP/GTEx_Analysis_2017-06-05_v8_WholeExomeSeq_979Indiv_VEP_annot.vcf.gz | cut -f 1 | while read C; do bcftools view -O z -o split.${C}.vcf.gz in.vcf.gz "${C}" ; done

but it throws an error:

[E::hts_open_format] Failed to open file in.vcf.gz Failed to open in.vcf.gz: No such file or directory

ADD REPLY
1
Entering edit mode

of course it doesn't work. You should have a look at my command line and _understand_ how it works.

ADD REPLY
0
Entering edit mode

!/bin/bash source ~/miniconda3/bin/activate conda activate train cd /scratch/downloaded/dbGAP/ for C in {1 .. 22} do bcftools index -s

in.vcf.gz | cut -f 1 | while read C; do bcftools view -O z -o /home/data_download/split.${C}.vcf.gz in.vcf.gz "${C}"; done

I tried to do this but its throwing error: line 9: syntax error: unexpected end of file

ADD REPLY

Login before adding your answer.

Traffic: 1946 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