High-level description

This directory contains unit tests for various tools and algorithms implemented in the Cassiopeia library, focusing on phylogenetic analysis and lineage tracing. The tests cover a wide range of functionalities, including autocorrelation, branch length estimation, coupling, fitness estimation, parameter estimation, small parsimony, topology analysis, and tree metrics.

What does it do?

The tests in this directory serve to validate and ensure the correctness of the following key functionalities:

  1. Autocorrelation: Tests for spatial autocorrelation calculations using Moran’s I statistic.
  2. Branch length estimation: Validates Bayesian and Maximum Likelihood Estimation (MLE) methods for estimating branch lengths in phylogenetic trees.
  3. Coupling: Verifies the calculation of evolutionary coupling between different cell types or states.
  4. Fitness estimation: Tests the Local Branch Index (LBI) method for estimating fitness in phylogenetic trees.
  5. Parameter estimation: Validates functions that estimate mutation rates and missing data probabilities in lineage tracing data.
  6. Small parsimony: Tests algorithms for inferring ancestral states and calculating parsimony scores on phylogenetic trees.
  7. Topology analysis: Verifies functions related to tree topology, including cophenetic correlation calculations.
  8. Tree metrics: Tests various tree-based metrics, including parsimony scores, likelihood calculations, and parameter estimations for lineage tracing models.

These tests ensure that the core algorithms and functions in Cassiopeia perform correctly under various scenarios, including edge cases and simulated data.

Entry points

The main entry points for the tests are the individual test files, each focusing on a specific aspect of the Cassiopeia toolkit:

  1. autocorrelation_test.py: Tests for spatial autocorrelation calculations.
  2. branch_length_estimator_tests/: Directory containing tests for branch length estimation methods.
  3. coupling_test.py: Tests for evolutionary coupling calculations.
  4. fitness_estimator_tests/: Directory containing tests for fitness estimation methods.
  5. parameter_estimators_test.py: Tests for parameter estimation functions.
  6. small_parsimony_test.py: Tests for small parsimony algorithms.
  7. topology_test.py: Tests for topology-related functions.
  8. tree_metrics_test.py: Tests for various tree-based metrics and calculations.

Each of these files contains a set of unit tests that can be run independently or as part of a larger test suite.

Key Files

  1. autocorrelation_test.py: Tests the compute_morans_i function for calculating Moran’s I statistic.
  2. branch_length_estimator_tests/:
    • iid_exponential_bayesian_test.py: Tests the IIDExponentialBayesian estimator.
    • iid_exponential_mle_test.py: Tests the IIDExponentialMLE estimator.
  3. coupling_test.py: Tests the compute_evolutionary_coupling function.
  4. fitness_estimator_tests/lbi_jungle_test.py: Tests the Local Branch Index (LBI) fitness estimator.
  5. parameter_estimators_test.py: Tests functions for estimating mutation rates and missing data probabilities.
  6. small_parsimony_test.py: Tests Fitch-Hartigan algorithm and related parsimony functions.
  7. topology_test.py: Tests topology-related functions, including cophenetic correlation calculations.
  8. tree_metrics_test.py: Tests various tree-based metrics and likelihood calculations.

Dependencies

The tests rely on several external libraries and frameworks:

  1. unittest: The standard Python unit testing framework.
  2. parameterized: Used for creating parameterized tests.
  3. numpy: Used for numerical operations and array manipulations.
  4. scipy: Used for various scientific computing tasks, including numerical integration.
  5. networkx: Used for working with graph structures, particularly in creating and manipulating tree topologies.
  6. pandas: Used for data manipulation and analysis.
  7. cvxpy: Used in optimization problems, particularly in the MLE branch length estimator.

From the Cassiopeia library:

  • Various modules and classes, including CassiopeiaTree, IIDExponentialBayesian, IIDExponentialMLE, LBIJungle, and others.

Configuration

The tests do not rely on external configuration files or environment variables. Test parameters and configurations are set within the test methods themselves to create various scenarios and validate the behavior of the functions under different conditions.

In summary, this directory contains a comprehensive set of unit tests that ensure the correctness and reliability of the core algorithms and functions in the Cassiopeia library for phylogenetic analysis and lineage tracing.