dadi API documentation
Description: For examples of dadi's usage, see the examples directory in the source distribution …

# Package `dadi`

For examples of dadi's usage, see the examples directory in the source distribution.

Documentation of all methods can be found in doc/api/index.html of the source distribution.

Expand source code

    """
    For examples of dadi's usage, see the examples directory in the source
    distribution.

    Documentation of all methods can be found in doc/api/index.html of the source
    distribution.
    """
    import logging
    logging.basicConfig()

    from . import Demographics1D, Demographics2D, Inference, Integration
    from . import Misc, Numerics, PhiManip, Spectrum_mod, tridiag, Godambe

    # We do it this way so it's easier to reload.
    Spectrum = Spectrum_mod.Spectrum

    # Protect import of Plotting in case matplotlib not installed.
    try:
        from . import Plotting
    except ImportError:
        pass

    # When doing arithmetic with Spectrum objects (which are masked arrays), we
    # often have masked values which generate annoying arithmetic warnings. Here
    # we tell numpy to ignore such warnings. This puts greater onus on the user to
    # check results, but for our use case I think it's the better default.
    import numpy
    numpy.seterr(all='ignore')

    def cuda_enabled(toggle=None):
        """
        Enable or disable cuda execution
        """
        if toggle is None:
            return Integration.cuda_enabled
        elif toggle == True:
            try:
                from . import cuda
                Integration.cuda_enabled = True
                return True
            except:
                print("Failed to import dadi.cuda")
                return False
        elif toggle == False:
            Integration.cuda_enabled = False
            return False
        else:
            raise ValueError("toggle must be True, False, or None")

    __pdoc__ = {'cuda':False}

    def pts_to_RAM(pts, P):
        """
        Approximate RAM usage for a given grid points and number of populations

        pts: Grid points setting
        P: Number of populations
        """
        return 8*4*pts**P / 1024**3

    def RAM_to_pts(RAM, P):
        """
        Approximate maximum grid points given the number of populations and available RAM

        pts: Grid points setting
        P: Number of populations
        """
        return int((RAM*1024**3/(8*4))**(1./P))

    def citation():
        """
        Print citation information for dadi codebase.
        """
        print("""
    If you find dadi useful in your research, please cite:
    RN Gutenkunst, RD Hernandez, SH Williamson, CD Bustamante "Inferring the joint demographic history of multiple populations from multidimensional SNP data" PLoS Genetics 5:e1000695 (2009)

    If you find the Godambe Information Matrix methods useful, please cite:
    AJ Coffman, P Hsieh, S Gravel, RN Gutenkunst "Computationally efficient composite likelihood statistics for demographic inference" Molecular Biology and Evolution 33:591 (2016)

    If you find the DFE inference methods useful, please cite:
    BY Kim, CD Huber, KE Lohmueller "Inference of the Distribution of Selection Coefficients for New Nonsynonymous Mutations Using Large Samples" Genetics 206:345 (2017)

    If you find the triallelic methods useful, please cite:
    AP Ragsdale, AJ Coffman, P Hsieh, TJ Struck, RN Gutenkunst "Triallelic population genomics for inferring correlated fitness effects of same site nonsynonymous mutations" Genetics 203:513 (2016)

    If you find the two-locus methods useful, please cite:
    AP Ragsdale, RN Gutenkunst "Inferring demographic history using two-locus statistics" Genetics 206:1037 (2017)
    """)

## Sub-modules

`dadi.DFE`

  Fitting Distributions of Fitness Effects to population genomic data, both single-population and joint.

`dadi.Demographics1D`

  Single population demographic models.

`dadi.Demographics2D`

  Two population demographic models.

`dadi.Godambe`

  Parameter uncertainties and likelihood ratio tests using Godambe information.

`dadi.Inference`

  Comparison and optimization of model spectra to data.

`dadi.Integration`

  Functions for integrating population frequency spectra.

`dadi.Misc`

  Miscellaneous utility functions. Including ms simulation.

`dadi.NLopt_mod`
`dadi.Numerics`

  Numerically useful functions, including extrapolation and default grid.

`dadi.PhiManip`

  Manipulating population frequency spectra phi. e.g. population splittings and admixture

`dadi.Plotting`

  Routines for Plotting comparisons between model and data …

`dadi.Spectrum_mod`

  Contains Spectrum object, which represents frequency spectra.

`dadi.Triallele`

  Modeling triallelic data.

`dadi.TwoLocus`

  Fitting models to data summarized by pairs of loci, incorporating both allele frequencies and linkage disequilibrium

`dadi.integration_c`

  This module 'integration_c' is auto-generated with f2py (version:2).

  ## Functions

  phi = implicit_1Dx(phi,xx,nu,gamma,h,beta,dt,use_delj_trick) phi = …

`dadi.tridiag`

  This module 'tridiag' is auto-generated with f2py (version:2).

  ## Functions

  u = tridiag(a,b,c,r) u = tridiag_fl(a,b,c,r) .

## Functions

`def RAM_to_pts(RAM, P)`

  Approximate maximum grid points given the number of populations and available RAM

  pts: Grid points setting P: Number of populations

  Expand source code

      def RAM_to_pts(RAM, P):
          """
          Approximate maximum grid points given the number of populations and available RAM

          pts: Grid points setting
          P: Number of populations
          """
          return int((RAM*1024**3/(8*4))**(1./P))

`def citation()`

  Print citation information for dadi codebase.

  Expand source code

      def citation():
          """
          Print citation information for dadi codebase.
          """
          print("""
      If you find dadi useful in your research, please cite:
      RN Gutenkunst, RD Hernandez, SH Williamson, CD Bustamante "Inferring the joint demographic history of multiple populations from multidimensional SNP data" PLoS Genetics 5:e1000695 (2009)

      If you find the Godambe Information Matrix methods useful, please cite:
      AJ Coffman, P Hsieh, S Gravel, RN Gutenkunst "Computationally efficient composite likelihood statistics for demographic inference" Molecular Biology and Evolution 33:591 (2016)

      If you find the DFE inference methods useful, please cite:
      BY Kim, CD Huber, KE Lohmueller "Inference of the Distribution of Selection Coefficients for New Nonsynonymous Mutations Using Large Samples" Genetics 206:345 (2017)

      If you find the triallelic methods useful, please cite:
      AP Ragsdale, AJ Coffman, P Hsieh, TJ Struck, RN Gutenkunst "Triallelic population genomics for inferring correlated fitness effects of same site nonsynonymous mutations" Genetics 203:513 (2016)

      If you find the two-locus methods useful, please cite:
      AP Ragsdale, RN Gutenkunst "Inferring demographic history using two-locus statistics" Genetics 206:1037 (2017)
      """)

`def cuda_enabled(toggle=None)`

  Enable or disable cuda execution

  Expand source code

      def cuda_enabled(toggle=None):
          """
          Enable or disable cuda execution
          """
          if toggle is None:
              return Integration.cuda_enabled
          elif toggle == True:
              try:
                  from . import cuda
                  Integration.cuda_enabled = True
                  return True
              except:
                  print("Failed to import dadi.cuda")
                  return False
          elif toggle == False:
              Integration.cuda_enabled = False
              return False
          else:
              raise ValueError("toggle must be True, False, or None")

`def pts_to_RAM(pts, P)`

  Approximate RAM usage for a given grid points and number of populations

  pts: Grid points setting P: Number of populations

  Expand source code

      def pts_to_RAM(pts, P):
          """
          Approximate RAM usage for a given grid points and number of populations

          pts: Grid points setting
          P: Number of populations
          """
          return 8*4*pts**P / 1024**3