Skip to main content

No project description provided

Project description

Skygrid

PyPI - Version PyPI - Python Version

Skygrid is a Snakemake-based workflow tool designed for performing demographic analyses using BEAST’s skygrid model. It streamlines the entire pipeline—from sequence alignment parsing and outlier detection through BEAST MCMC sampling to post-analysis visualizations—so that you can focus on interpreting your results rather than managing complex workflows.

Features

  • End-to-End Workflow:
    Automatically parses sequence alignments, performs root-to-tip regressions to detect outliers, executes BEAST analyses, and renders demographic plots and trees.

  • Customizable Configuration:
    Easily override workflow defaults by supplying a configuration file or specifying options on the command line. Customize clock models (strict/relaxed), chain lengths, sample sizes, and more.

  • Robust Resource Management:
    Leverages Snakemake’s advanced resource handling including multi-core execution, workflow locking, and DAG generation.

  • Seamless Integration:
    Integrates tools such as IQ-TREE, treetime, and R (via ggtree) to offer a comprehensive analysis suite.

Installation

Skygrid is available on PyPI. Install it using pip:

pip install beast-skygrid

Quick Start

1. Prepare Your Data

Ensure you have a FASTA alignment file. This file is used to extract taxon names and sampling dates for your analysis.

2. Run the Workflow

Invoke the skygrid workflow from the command line. For example:

skygrid run --alignment your_alignment.fasta --output-dir results

This command will:

  • Extract Taxa & Dates: Parse your alignment to determine the number of taxa and the sampling date range.
  • Root-to-Tip Regression & Outlier Detection: Use root-to-tip regression to estimate the skygrid length and transition points. Optionally, filter out outlier sequences.
  • BEAST Analysis: Generate a BEAST XML file from a Jinja2 template and run BEAST with the skygrid model.
  • Visualization: Create skygrid plots and render the Maximum Clade Credibility (MCC) tree in SVG format.

3. Explore the Results

After completion, check the specified output directory (here, results). You will find:

  • A skygrid plot (SVG, PNG, and PDF formats)
  • BEAST logs and tree files
  • Rendered MCC tree visualizations

Command Line Options

To display the complete list of options, run:

skygrid run -h

A summary of some key options:

  • Workflow Configuration Options:
    • --alignment (-a PATH) (required)
      Path to your sequence alignment file.
    • --output-dir (-o PATH)
      Directory to save the output (default: ./skygrid).
    • --constant-sites TEXT
      Provide constant site counts in the format 'A,C,G,T'.
    • --discard-outliers
      Use a root-to-tip regression to identify and discard outlier sequences.
    • --clock [strict|relaxed]
      Choose the clock model for the analysis (default: strict).
    • --relaxed-gamma-shape FLOAT and --relaxed-gamma-scale FLOAT
      Parameters for the relaxed clock’s gamma distribution (default: shape=0.3, scale=0.001).
    • --transition-points-per-year FLOAT
      Set the number of transition points per year for the skygrid (default: 2).
    • --cutoff INTEGER
      Specify the skygrid length in years (if not provided, it is estimated from the data).
    • --chain-length INTEGER
      Length of the MCMC chain (default: 10,000,000).
    • --samples INTEGER
      Number of samples to extract from the chain (default: 10,000).
    • --sample-from-prior
      Run the analysis by sampling from the prior distribution only.
    • --beast-params TEXT
      Additional parameters to pass to BEAST (default: -overwrite).

Workflow Overview

The skygrid workflow is divided into several key stages:

1. Taxa Extraction & Date Parsing

The workflow begins by parsing your FASTA alignment to extract taxon information and sampling dates. Dates must be in the format >SampleName|YYYY-MM-DD or . Uncertain dates can be specified as >SampleName|YYYY-MM-DD/uncertainty where uncertainty is a number of years e.g. >SampleName|2020-01-01/1 includes 2020 to 2021.

2. Root-to-Tip Regression & Outlier Detection

The workflow uses root-to-tip regression (via treetime) to estimate the skygrid length (cutoff) and transition points (dimensions). Skygrid optionally uses a root-to-tip regression to identify and filter out outlier sequences.

3. BEAST Analysis

The workflow automatically generates a BEAST XML configuration file from a Jinja2 template. This XML file is used to run the BEAST analysis with parameters such as clock model, chain length, and sampling frequency. The BEAST run is executed as follows:

rule beast:
    input:
        beast_XML_file = OUTDIR / "beast" / "skygrid.xml",
    output:
        log_file = OUTDIR / "beast" / "skygrid.log",
        trees_file = OUTDIR / "beast" / "skygrid.trees",
    shell:
        """
        beast {params.beast} -working {input.beast_XML_file} > {log} 2>&1
        """

4. Post-Processing & Visualization

After BEAST completes, the workflow:

  • Computes the Maximum Clade Credibility (MCC) tree using treeannotator.
  • Renders the MCC tree in SVG format with R (using scripts that leverage the ggtree package).
  • Generates skygrid plots (SVG, PNG, PDF) to visualize changes in population size over time.

Contributing

Contributions to skygrid are welcome! If you would like to propose improvements or bug fixes, please:

  1. Fork the repository.
  2. Create a feature branch for your changes.
  3. Submit a pull request with a detailed description of your changes.

For major changes, please open an issue first to discuss what you would like to change.

License

Skygrid is distributed under the terms of the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

beast_skygrid-0.3.3.tar.gz (379.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

beast_skygrid-0.3.3-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file beast_skygrid-0.3.3.tar.gz.

File metadata

  • Download URL: beast_skygrid-0.3.3.tar.gz
  • Upload date:
  • Size: 379.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for beast_skygrid-0.3.3.tar.gz
Algorithm Hash digest
SHA256 31d563329b0ab8056fb9be10dda71221e09c58a91c75d7bb6cddfb8c62c1bc7a
MD5 376f9dfefb8d0eb559014b83dc32548f
BLAKE2b-256 ba445aa9e1341b113a6328482e66639d1d8158bb32a12ed31e977c7743388a8e

See more details on using hashes here.

File details

Details for the file beast_skygrid-0.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for beast_skygrid-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3a5c8a63fe79331332ffd4c6bb81ddc1a4a95768b8d38a3e37c6807095bf7fa8
MD5 0af713f8529028de64acd2937adbcfed
BLAKE2b-256 21bcd59da089e1e3841786dff05d79e620208fd477f7b37b4fbd32f0b65485fc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page