Entering edit mode
5.2 years ago
caro-ca
▴
20
Dear, I am trying to create a VennDiagram by using bcftools stats and consequently plot-vcfstats. For bcftools stats I followed:
bgzip -c file.vcf > file.vcf.gz
tabix -p vcf file.vcf.gz
But tabix raised this error:
[E::hts_idx_push] Unsorted positions on sequence #3: 84070 followed by 84069
Therefore, to sort I used this code:
(grep ^"#" file.vcf ; grep -v ^"#" file.vcf | sort -k1,1 -k2,2n) > file1_sorted.vcf
Compressing and indexing worked fine for my two VCF files. However, while running
bcftools stats file1_sorted.vcf.gz file2_sorted.vcf.gz
This is the stdout message:
Failed to open file2_sorted.vcf.gz: unknown file type
I hope you could help me out. Thank you in advance
Can you try using
bcftools sort? It is best to stay with tools designed for specific file formats in some cases (VCF being one).Yeah, I tried and this is the error:
Can you give us the output of
grep "^##" samples_all_merged_STROPE.vcfThis file is really short compared to the non-sorted file, is there a way to upload files?
It tells me enough to diagnose what went wrong. There is no need to upload large files.
You should not have used the
grep->sortthing you used - that command sequence is flawed and it corrupted the file. Please usebcftools sorton thefile.vcfthat you used grep/sort on.I used this code, but it did not work.
Am I using it correctly?
No,
-Ovmeans you're expected uncompressed VCF as output, which you're saving in avcf.gzfile. Use either-Ozor save it as a.vcffile.Can you give us the output to:
This is the output of bcftools
and
bcftools viewdoes not retrieve anything.To sum up:
bcftools sort, it did not work (stdout message above).bcftools view -h samples_all_merged_STROPE.vcf | grep -m50 "^##contig"having no output nor error messages.Lastly, I used
bcftools view samples_all_merged_STROPE.vcf -Oz -o samples_all_merged_STROPE_sorted.vcf.gzhaving an output, but while executingbcftools index samples_all_merged_STROPE_sorted.vcf.gzthis is the error message:Thank you in advance for your persistent help.
It looks like your contig lines are missing - which is a HUGE problem. The
grepoutput from a comment above shows me your header is already messed up. The conclusion is - the filesamples_all_merged_STROPE.vcfis not usable in its current form.How did you create the
samples_all_merged_STROPE.vcffile? You're going to have to re-create it after fixing any problems in the process that created it.