API Reference

File: data.pyx

The data.pyx source file is written in Cython, a superset of the Python language that allows the use of C/C++ code to speed up computationally intensive tasks (and many other things). This file is automatically translated into a C++ source file and is compiled into a shared library that can be called from Python.

class phyde.HydeData(infile=None, mapfile=None, unicode outgroup=None, int nind=-1, int ntaxa=-1, int nsites=-1, bool quiet=False, bool ignore_amb_sites=False)

Class for storing (1) a matrix of DNA bases as unsigned, 8-bit integers and (2) mapping of individuals to taxa.

Parameters:
  • infile (str) – the name of the input DNA sequence data file.

  • mapfile (str) – the name of the individual mapping file.

  • outgroup (str) – the name of the outgroup.

  • nind (int) – the number of individuals.

  • ntaxa (int) – the number of populations/taxa.

  • nsites (int) – the number of sites.

  • quiet (bool) – suppress printing output.

  • ignore_amb_sites (bool) – ignore missing/ambiguous sites.

Example:

import phyde as hd
data = hd.HydeData("infile.txt", "mapfile.txt", "outgroup", 100, 6, 10000)
bootstrap_triple(self, unicode p1, unicode hyb, unicode p2, int reps=100) dict

Performs bootstrap resampling of individuals within the specified hybrid population.

Parameters:
  • p1 (str) – parent one.

  • hyb (str) – the putative hybrid.

  • p2 (str) – parent two.

  • reps (int) – number of boostrap replicates (default=100).

Return type:

dict

Example:

import phyde as hd
data = hd.HydeData("data.txt", "map.txt", "out", 16, 4, 50000)
res = data.bootstrap_triple("sp1", "sp2", "sp3")
list_triples(self) list

List all possible triples based on the populations in the given map file.

Return type:

list

Returns a list of 3-tuples: (p1, hyb, p2)

resetOutgroup(self, newOut)

Reset outgroup population.

Parameters:

newOut (str) – Name of the new outgroup.

test_individuals(self, unicode p1, unicode hyb, unicode p2) dict

Test all individuals in a given putative hybrid lineage (hyb).

Parameters:
  • p1 (str) – parent one.

  • hyb (str) – the putative hybrid.

  • p2 (str) – parent two.

Return type:

dict

Example:

import phyde as hd
data = hd.HydeData("data.txt", "map.txt", "out", 16, 4, 50000)
res = data.test_individuals("sp1", "sp2", "sp3")
test_triple(self, unicode p1, unicode hyb, unicode p2) dict

Main method for testing a hypothesis on a specified triple. ((P1,Hyb),P2):\(\gamma\) and (P1,(Hyb,P2)):\(1-\gamma\). It is a wrapper for the C++ based methods _test_triple_c(), which is not accessible from Python.

Parameters:
  • p1 (str) – parent one.

  • hyb (str) – the putative hybrid.

  • p2 (str) – parent two.

Return type:

dict

Returns a dictionary with the values for the Z-score, P-value, estimate of gamma, and all of the site pattern counts.

Example:

import phyde as hd
data = hd.HydeData("data.txt", "map.txt", "out", 16, 4, 50000)
res = data.test_triple("sp1", "sp2", "sp3")

File: result.py

class phyde.HydeResult(infile)[source]

A class for reading in and working with results from a HyDe analysis. It is mostly a simple container for storing triples as tuples and using them as keys in a dictionary with values that are also dictionaries containing the results from the HyDe analysis.

Parameters:

infile (str) – name of results file.

Example:

import phyde as hd
res = hd.HydeResult("hyde-out.txt")
__call__(attr, p1, hyb, p2)[source]

A callable method (the object can be called as a function) for accessing information in a phyde.HydeResult object.

Parameters:
  • attr (str) – name of hypothesis test attribute to plot (e.g., “Gamma”, “Zscore”, “Pvalue”, etc.)

  • p1 (str) – parent one.

  • hyb (str) – putative hybrid.

  • p2 (str) – parent two.

Example:

import phyde as hd
res = hd.HydeResult("hyde-out.txt")
res("Zscore", "sp1", "sp2", "sp3")
abba_baba(p1, hyb, p2)[source]

Calculate Patterson’s D-Statistic for the triple (p1, hyb, p2).

Parameters:
  • p1 (str) – parent 1.

  • hyb (str) – putative hybrid.

  • p2 (str) – parent 2.

Example:

import phyde as hd
res = hd.HydeResult("hyde-out.txt")
res.abba_baba("sp1", "sp2", "sp3")

File: bootstrap.py

class phyde.Bootstrap(bootfile)[source]

A class representing a dictionary of species triplets with info for each bootstrap replicate stored as a dictionary containing parameter values.

Parameters:

bootfile (str) – name of file with bootstrapping results.

Example:

import phyde as hd
boot = hd.Bootstrap("hyde-boot.txt")
__call__(attr, p1, hyb, p2)[source]

A callable method (the object can be called as a function) to access attributes from a bootstrapped HyDe analysis. Returned as a list.

Parameters:
  • attr (str) – name of hypothesis test attribute to plot (e.g., “Gamma”, “Zscore”, “Pvalue”, etc.)

  • p1 (str) – parent one.

  • hyb (str) – putative hybrid.

  • p2 (str) – parent two.

Return type:

list

Returns a list of the given attribute across all bootstrap replicates for the given triple (p1, hyb, p2).

Example:

import phyde as hd
boot = hd.Bootstrap("hyde-boot.txt")
boot("Gamma", "sp1", "sp2", "sp3")
abba_baba(p1, hyb, p2)[source]

Calculate Patterson’s D-Statistic for all bootstrap replicates for the triple (p1, hyb, p2). Uses vectorization with numpy arrays.

Parameters:
  • p1 (str) – parent 1.

  • hyb (str) – putative hybrid.

  • p2 (str)

Return type:

numpy.array

Example:

import phyde as hd
boot = hd.Bootstrap("hyde-boot.txt")
boot.abba_baba("sp1", "sp2", "sp3")
write_summary(summary_file)[source]

Write a summary of the bootstrap replicates for each tested triple. The summary written to file includes the mean and standard deviation of the Zscore, P-value, and estimate of \(\gamma\).

Parameters:

summary_file (str) – name of file.