Skip to main content

Build Status Coverage Status

afplot

This is a tool to plot allele frequencies in VCF files.

The two main subcommands that are available are: * regions: Plot single regions or regions from a bed file, optionally with a margin. * whole-genome: Create a single image for every chromosome on the genome.

Both subcommands have three modes:

  • histogram: This will create a histogram with kernel density plot of allele frequencies.

  • scatter: Create a scatter plot of allele frequencies, along the region or chromosome.

  • distance: Create a scatter plot of distances to theoretical allele frequencies, along the region or chromosome. This only makes sense for autosomes of diploid organisms.

By default, colors correspond to call type (hom_alt/ref/hom_ref).

Multiple VCF files can be supplied simultaneously for the whole-genome subcommand, in which case they can be grouped by label. When multiple VCF files are supplied, plots will be colored on label per VCF file.

Only one sample per VCF file can be plotted.

We currently assume the presence of an AD column in the FORMAT field. This column should contain the depth per allele, with the reference allele being first.

All VCFs should be indexed with tabix, and should contain contigs in the header.

Installation

afplot is available through pypi with: pip install afplot

Requirements

  • Python 3.4+

  • click

  • numpy

  • matplotlib

  • pandas

  • seaborn

  • progressbar2

  • pysam

  • pyvcf

Usage

Usage: afplot [OPTIONS] COMMAND [ARGS]...

  Plot allele frequencies in VCF files.

  Two basic modes exist:
    - regions: Plot histogram, scatter or distance plots per
      user-specified region.
    - whole-genome: Plot histogram, scatter or distance plots over the
      entire genome.

Options:
  --help  Show this message and exit.

Commands:
  regions       Region plots
  whole-genome  Whole-genome plots

Examples

Single VCF on a single region

  • afplot regions histogram -v my.vcf.gz -o output_dir -R chr1:100-200

Single VCF on a bed file

  • afplot regions histogram -v my.vcf.gz -o output_dir -L regions.bed

Single VCF whole genome

  • afplot whole-genome histogram -v my.vcf.gz -l my_label -s my_sample -o mysample.histogram.png

Multiple VCFs whole genome

  • afplot whole-genome histogram -v my1.vcf.gz -l my_label1 -s my_sample1 -v my2.vcf.gz -l my_label2 -s my_sample2 -o both_samples.histogram.png

Grouping samples can be achieved by supplying identical labels to samples. E.g.

  • afplot whole-genome histogram -v 1.vcf.gz -v 2.vcf.gz -v 3.vcf.gz -v 4.vcf.gz -l group1 -l group1 -l group2 -l group2 [...]

Excluding contigs on whole genome

In certain cases, you may not want to plot all contigs. For instance, when your vcf header contains many small unplaced contigs. This can be achieved by supplying a regex pattern to the -e flag. For instance, all contigs containing “gl” can be filtered out by doing:

  • afplot whole-genome [...] -e '.*gl.*'

Changelog

0.2

The entire command line interface was changed to use click, instead of regular argparse. This allows a more complex CLI. In stead of having flags for plot mode, afplot now uses subcommands.

While the CLI has changed, and the internals of afplot have been refactored, the old-style (version 0.1) API remains in place for now. This may be deprecated in the future.

Support for plotting regions was added. Region plotting outputs on a directory, rather than on a single file.

License

MIT

Metadata

Release files for afplot 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for afplot 0.2.1
File Size Uploaded
afplot-0.2.1.tar.gz 12.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for afplot 0.2.1
File Interpreter ABI Platform
afplot-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.6 kB

Release files / afplot-0.2.1.tar.gz

Download URL afplot-0.2.1.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e345777e40a3822c4a098933336861d99707dc88fe479453f40cb470f37b196b
BLAKE2b-256 checksum
How to use checksums
b72d2052f6bc95f69826c3c82dcc1020f89ad1f6c61ea469944b2389dc67ccdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / afplot-0.2.1-py3-none-any.whl

Download URL afplot-0.2.1-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54c1d8de87eb9eb84130aa4d9741f5b1cf3fc3966de554726da63c9499a5f146
BLAKE2b-256 checksum
How to use checksums
d3f6c0615986be54594dace49a0e621528a552b54c26b8b5c1de1da057890edb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page