barcode-constrained-phylogeny

workflow License: Apache-2.0 DOI

Logo

Bactria: BarCode TRee Inference and Analysis

This repository contains code and data for building very large, topologically-constrained barcode phylogenies through a divide-and-conquer strategy. Such trees are useful as reference materials for curating barcode data by detecting rogue terminals (indicating incorrect taxonomic annotation) and in the comparable calculation of alpha and beta biodiversity metrics across metabarcoding assays.

The input data for the approach we develop here currently comes from BOLD data dumps. The international database BOLD Systems contains DNA barcodes for hundreds of thousands of species, with multiple barcodes per species. The data dumps we use here are TSV files whose columns conform to the nascent BCDM (barcode data model) vocabulary. As such, other data sources that conform to this vocabulary could in the future be used as well, such as UNITE.

Theoretically, such data could be filtered and aligned per DNA marker to make phylogenetic trees. However, there are two limiting factors: building very large phylogenies is computationally intensive, and barcodes are not considered ideal for building big trees because they are short (providing insufficient signal to resolve large trees) and because they tend to saturate across large patristic distances.

concept

Both problems can be mitigated by using the Open Tree of Life as a further source of phylogenetic signal. The BOLD data can be split into chunks that correspond to Open Tree of Life clades. These chunks can be made into alignments and subtrees. The OpenTOL can be used as a constraint in the algorithms to make these. The chunks are then combined in a large synthesis by grafting them on a backbone made from exemplar taxa from the subtrees. Here too, the OpenTOL is a source of phylogenetic constraint.

In this repository this concept is developed for the COI-5P marker, but the aim is to achieve equivalent functionality for plant barcoding markers (matK, rbcL) and for some part of the ITS region.

Installation

The pipeline and its dependencies are managed using conda. On a Linux-like system, you can follow these steps to set up the bactria Conda environment using the environment.yml file (for standalone executables that the pipeline needs) and a requirements.txt file (for Python packages that the pipeline scripts use):

  1. Clone the Repository:
    Clone the repository containing the environment files to your local machine:
    git clone https://github.com/naturalis/barcode-constrained-phylogeny.git
    cd barcode-constrained-phylogeny
    
  2. Create the Conda Environment: Create the bactria Conda/Mamba environment using the environment.yml file with the following command:
    mamba env create -f workflow/envs/environment.yml
    

    This command will create a new Conda environment named bactria with the packages specified in the environment.yml file. This step is largely a placeholder because most of the dependency management is handled at the level of individual pipeline steps, which each have their own environment specification.

  3. Activate the Environment: After creating the environment, activate it using the conda activate command:
    mamba activate bactria
    
  4. Verify the Environment: Verify that the bactria environment was set up correctly and that all packages were installed using the conda list command:
    mamba list
    

    This command will list all packages installed in the active conda environment. You should see all the packages specified in the environment.yml file and the requirements.txt file.

It is recommended that the mamba environment is configured to use strict channel priorities. This is crucial for having robust and correct environments (for details, see here). Consider configuring strict priorities by executing conda config --set channel_priority strict.

How to configure

The pipeline is configured using the config.yaml file. With the settings in this file you can affect, among other things:

How to run

The pipeline is implemented using snakemake, which is available within the conda environment that results from the installation.

How to run the entire pipeline:

snakemake -j {number of threads} --use-conda

Snakemake rules can be performed separately:

snakemake --until {Rule} -j {number of threads} --use-conda

Enter the same number at {number of threads} as you filled in previously in src/config.yaml. In {Rule} insert the rule to be performed.

Here is an overview of all the rules in the Snakefile:

graphviz (1) (zoomed view is available here)

More detailed documentation of the individual rules is provided here.

Repository layout

Below is the top-level layout of the repository. This layout is in line with community standards and must be adhered to. All of these subfolders contains further explanatory READMEs to explain their contents in more detail.

License

© 2023-2024 Naturalis Biodiversity Center

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.