This is a test version of Biostars. For the public version, visit https://www.biostars.org.
vcftools: the length of each row is not same

Hello! I have vcf.gz file, and I want to change it into 012 matrix. I use follow command

vcftools --gzvcf chr1.vcf.gz --out chr1 --012

Then, it outputs chr1.012, chr1.012.pos, and chr1.012.indv. But I found the length of each row of chr1.012 is not equal. And the length of rows of chr12.012 is not same as chr1.012.

vcftools

Just to cover all bases, what are the commands you used to find

  1. the length of each row in a file
  2. the number of rows in a file

This is just so we are sure there was no error in the counting logic.

Hello! I use bash scripting. To print the length of each row, I use

cat chr1.012 | awk '{print NF}'

To print the number of rows of chr1.012.pos, I use

wc -l chr1.012.pos

Did you account for anomalies in separation? Maybe a case of multiple separators at places where it's not supposed to happen? Given the 012 file has an empty value indicator (-1), maybe squeeze the separator using a tr -s before the awk?

I found the length of chr1.012.pos is always much larger than the length of row of chr1.012. So the case you mentioned would not happen.

Maybe they use different separators?

EDIT: Scratch that - doesn't look like it; they're all tab separated. It has something to do with the actual variants then.

The real name of my vcf.gz file is GAZ00001016581_1.ALSPAC.beagle.anno.csq.shapeit.20131101.vcf.gz (this is for chromsome 1). Also there is a file called _EGAZ00001016604_ALSPAC.beagle.anno.csq.shapeit.20131101.sites.vcf.gz. I do not know whether this file is useful or not.

Do you have alternative tools to convert vcf.gz file into 012 matrix?

Not really. Sorry, I cannot help you with this now - I would have asked for a bit of the file to examine, but I am busy with my day job this week.

Sure. But my file is so large. The smallest file for chromsome is chr22 (about 4.1G).

Thanks for your suggestion. I deleted cross-posted one in stackoverflow.

1 answer

Hi zwang10,

did you solve this?

the first column of chr1.012 is numeric sample id, not genotype. remove this and you have the same lengths.

Ciaran

Log in to answer this question.