pwwang / vcfstats

Powerful statistics for VCF files
https://pwwang.github.io/vcfstats/
MIT License
65 stars 15 forks source link

Order #34

Closed kkmll closed 1 year ago

kkmll commented 1 year ago

How can I keep chr order as I like while using the command below;

vcfstats --vcf examples/sample.vcf \
    --outdir examples/ \
    --formula 'COUNT(1) ~ CONTIG[1,2,3,4,5]' \
    --title 'Number of variants on each chromosome (first 5)' \
    --config examples/config.toml

Assume I set CONTIG as [1-22] I don't want it to plot chr10 after chr1.

I see the this command as well;

vcfstats --vcf examples/sample.vcf \
    --outdir examples/ \
    --formula 'COUNT(1) ~ CONTIG' \
    --title 'Number of variants on each chromosome (modified)' \
    --config examples/config.toml \
    --ggs 'scale_x_discrete(name ="Chromosome", \
        limits=["1","2","3","4","5","6","7","8","9","10","X"]); \
        ylab("# Variants")'

but while using this command if I don't want to see all chromosomes in the plot and kick some available ones out, the code evaluates the as na and throws and error if I am not doing something wrong.

Thanks for the nice tool.

pwwang commented 1 year ago

You can combine both the --formula and the --ggs arguments:

❯ vcfstats --vcf examples/sample.vcf \                              
      --outdir examples/ \
      --formula 'COUNT(1) ~ CONTIG[1,2,10,X]' \
      --title 'Number of variants on each chromosome (modified)' \
      --config examples/config.toml \
      --ggs 'scale_x_discrete(name ="Chromosome", \
  limits=["1","2","10","X"]); \
  ylab("# Variants")'

image

kkmll commented 1 year ago

Thanks..