Hi all,
how can I counting SNPs and INDELs per each chromosome in a vcf file?


Using BEDOPS `vcf2bed` and standard Unix tools like `wc` to count lines:

    $ vcf2bed --snvs < variants.vcf | wc -l
    $ vcf2bed --insertions < variants.vcf | wc -l
    $ vcf2bed --deletions < variants.vcf | wc -l

Cf. http://bedops.readthedocs.io/en/latest/content/reference/file-management/conversion/vcf2bed.html

The above does counts over all chromosomes. You need to do an extra step to count per chromosome.

To perform this count exercise quickly per-chromosome, per-variant class:

    $ vcf2bed --snvs < variants.vcf > variants.snvs.bed
    $ for chr in `bedextract --list-chr variants.snvs.bed`; do echo $chr; bedextract $chr variants.snvs.bed | wc -l; done

The `bedextract` tool is part of BEDOPS. If you install BEDOPS to get `vcf2bed`, you get `bedextract`, as well.

Repeat this procedure for `--insertions` and `--deletions`, replacing `snvs` accordingly, to count those classes.