This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Which tool to calculate per site stats on vcf file?

Hello, Does anyone know a tool to calculate per site stats ( nb Homozygous Ref, nb Homozygous Alt , nb Heterozygous , nb NA ) on SNPs data in vcf formats?

snp vcf

2 answers

bcftools with the fill-tags plugin will add this info to the vcf file.

using bioalcidaejdk : http://lindenb.github.io/jvarkit/BioAlcidaeJdk.html

 java -jar dist/bioalcidaejdk.jar -e 'out.print("POS\t");for(GenotypeType GT : GenotypeType.values()) out.print("\t"+GT); out.println(); stream().forEach(V->{out.print(V.getContig()+":"+V.getStart()+":"+V.getReference().getDisplayString());for(GenotypeType GT : GenotypeType.values()) out.print("\t"+V.getGenotypes().stream().filter(G->G.getType()==GT).count()); out.println();});' in.vcf | column -t

POS               NO_CALL  HOM_REF  HET  HOM_VAR  UNAVAILABLE  MIXED
rotavirus:51:A    0        3        0    1        0            0
rotavirus:91:A    0        3        1    0        0            0
rotavirus:130:T   0        3        1    0        0            0
rotavirus:232:T   0        3        1    0        0            0
rotavirus:267:C   0        3        1    0        0            0
rotavirus:424:A   0        3        1    0        0            0
rotavirus:520:T   0        3        1    0        0            0
rotavirus:536:A   0        3        0    1        0            0
rotavirus:562:A   0        3        1    0        0            0
rotavirus:583:G   0        3        1    0        0            0
rotavirus:661:T   0        3        1    0        0            0
rotavirus:693:T   0        3        0    1        0            0
rotavirus:738:T   0        2        2    0        0            0
rotavirus:799:A   0        3        0    1        0            0
rotavirus:812:G   0        3        0    1        0            0
rotavirus:833:G   0        3        0    1        0            0
rotavirus:916:A   0        3        0    1        0            0
rotavirus:946:C   0        3        1    0        0            0
rotavirus:961:T   0        3        1    0        0            0
rotavirus:1044:A  0        3        0    1        0            0
rotavirus:1045:C  0        3        0    1        0            0
rotavirus:1054:C  0        3        0    1        0            0
rotavirus:1064:G  0        3        0    1        0            0
rotavirus:1064:G  0        3        0    1        0            0
rotavirus:1064:G  4        0        0    0        0            0

Log in to answer this question.