Model parameters

adap is the only variable exported from Analytical module. It is a Mutable structure contaning the variables required to solve the analytical approach. Any value can be easly changed. Remember adap should be change before the execution, in other case, $\alpha_{(x)}$ will be solve with the default values. To change all the values at once, you can use Analytical.parameters in order to set specific models in a new variable.

Analytical.parametersType

Mutable structure containing the variables required to solve the analytical approach. All the functions are solve using the internal values of the structure. You should declare a mutable structure to the perform the analytical estimations.

Parameters

  • gamNeg::Int64: Selection coefficient for deleterious alleles
  • gL::Int64: Selection coefficient for weakly benefical alleles
  • gH::Int64: Selection coefficient for strongly benefical alleles
  • alLow::Float64: Proportion of α due to weak selection
  • alTot::Float64: α
  • thetaF::Float64: Mutation rate defining BGS strength
  • thetaMidNeutral::Float64: Mutation rate on coding region
  • al::Float64: DFE shape parameter
  • be::Float64: DFE scale parameter
  • B::Float64: BGS strength
  • B_bins::Array{Float64,1}: BGS values to simulate
  • pposL::Float64: Fixation probabily of weakly beneficial alleles
  • pposH::Float64: Fixation probabily of strongly beneficial alleles
  • N::Int64: Population size
  • n::Int64: Sample size
  • Lf::Int64: Flanking region length
  • rho::Float64: Recombination rate
  • TE::Float64
source
Analytical.binomial_dictType

Mutable structure containing the downsampled SFS.

Returns

  • bn::Dict: SparseMatrixCSC containing the binomial convolution
source
Analytical.BrFunction
Br(Lmax,theta)

Expected reduction in nucleotide diversity. Explored at Charlesworth B., 1994:

\[\frac{\pi}{\pi_{0}} = e^{\frac{4\muL}{2rL+t}}\]

Arguments

  • param::parameters
  • theta::Float64

Returns

  • Float64: expected reduction in diversity given a non-coding length, mutation rate and defined recombination.
source
Analytical.setThetaF!Function
setThetaF!(param)

Find the optimum mutation given the expected reduction in nucleotide diversity (B value) in a locus.

Returns

  • adap.thetaF::Float64: changes adap.thetaF value.
source
Analytical.setPpos!Function
setPpos!(param)

Find the probabilty of positive selected alleles given the model. It solves a equation system taking into account fixations probabilities of weakly and strong beneficial alleles.

Returns

  • Tuple{Float64,Float64}: weakly and strong beneficial alleles probabilites.
source
Analytical.binomOp!Function
binomOp(param)

Binomial convolution to sample the allele frequencies probabilites depending on background selection values and sample size.

Arguments

  • param::parameters
  • convolutedSamples::binomial_dict

Returns

  • Array{Float64,2}: convoluted SFS for each B value defined in the model (param.B_bins). The estimations are saved at convolutedBn.bn.
source
Analytical.phiReductionFunction
phiReduction(param,gamma,ppos)

Reduction in fixation probabilty due to background selection and linkage. The formulas used have been subjected to several theoretical works (Charlesworth B., 1994, Hudson et al., 1995, Nordborg et al. 1995, Barton NH., 1995).

The fixation probabilty of selected alleles are reduce by a factor $\phi$:

\[\phi(t,s) = e^{[\frac{-2\mu}{t(1+\frac{rL}{t}+\frac{2s}{t})}]}\]

Multiplying across all deleterious linkes sites, we find:

\[\Phi = \prod_{1}^{L} = \phi(t,s) = e^{\frac{-2t\mu(\psi[1,\frac{r+2s+L}{r}] - \psi[1,\frac{r(L+1)+2s+t}{r}])}{r^2}}\]
\[\phi(t,s) = e^{\frac{-2t\mu(\psi[1,\frac{r+2s+L}{r}] - \psi[1,\frac{r(L+1)+2s+t}{r}])}{r^2}}\]

Arguments

  • gamma::Int64: selection coefficient.

Returns

  • Float64: expected rate of positive fixations under background selection.
source
Analytical.analyticalAlphaFunction
analyticalAlpha(param, convolutedSamples)

Analytical α(x) estimation. Solve α(x) generally. We used the expected rates of divergence and polymorphism to approach the asympotic value accouting for background selection, weakly and strong positive selection. α(x) can be estimated taking into account the role of positive selected alleles or not. In this way we explore the role of linkage to deleterious alleles in the coding region.

\[\mathbb{E}[\alpha_{x}] = 1 - \left(\frac{\mathbb{E}[D_{s}]}{\mathbb{E}[D_{N}]}\frac{\mathbb{E}[P_{N}]}{\mathbb{E}[P_{S}]}\right)\]

Arguments

  • param::parameters
  • convolutedSamples::binomial_dict

Returns

  • Array{Float64,1} α(x).
source

Analytical estimation

Fixations

Analytical.fixNeutFunction
  • fixNeut()

Expected neutral fixations rate reduce by B value.

\[\mathbb{E}[D_{s}] = (1 - p_{-} - p_{+}) B \frac{1}{2N}\]

Returns

  • Float64: expected rate of neutral fixations.
source
Analytical.fixNegBFunction
fixNegB(ppos)

Expected fixation rate from negative DFE.

\[\mathbb{E}[D_{n-}] = p_{-}\left(2^-\alpha\beta^\alpha\left(-\zeta[\alpha,\frac{2+\beta}{2}] + \zeta[\alpha,1/2(2-\frac{1}{N+\beta})]\right)\right)\]

Arguments

  • ppos::Float64: positive selected alleles probabilty.

Returns

  • Float64: expected rate of fixations from negative DFE.
source
Analytical.pFixFunction
pFix()

Expected positive fixation rate.

\[\mathbb{E}[D_{n+}] = p_{+} \cdot B \cdot (1 - e^{(-2s)})\]

Arguments

  • ppos::Float64: positive selected alleles probabilty.

Returns

  • Float64: expected rate of positive fixation.
source
Analytical.fixPosSimFunction
fixPosSim(gamma,ppos)

Expected positive fixations rate reduced due to the impact of background selection and linkage. The probabilty of fixation of positively selected alleles is reduced by a factor Φ across all deleterious linked sites Analytical.phiReduction.

\[\mathbb{E}[D_{n+}] = \Phi \cdot \mathbb{E}[D_{n+}]\]

Arguments

  • ppos::Float64: positive selected alleles probabilty.

Returns

  • Float64: expected rate of positive fixations under background selection
source

Polymorphism

Analytical.DiscSFSNeutDownFunction
DiscSFSNeutDown()

Expected rate of neutral allele frequency reduce by backgrou nd selection. The spectrum depends on the number of individual []

\[\mathbb{E}[Ps_{(x)}] = \sum{x^{*}=x}{x^{*}=1}f_{B}(x)\]

Return:

  • Array{Float64}: expected rate of neutral alleles frequencies.
source
Analytical.DiscSFSSelPosDownFunction
DiscSFSSelPosDown(gammaValue,ppos)

Expected rate of positive selected allele frequency reduce by background selection. The spectrum depends on the number of individuals.

Arguments

  • gammaValue::Int64: selection strength.
  • ppos::Float64: positive selected alleles probabilty.

Return:

  • Array{Float64}: expected positive selected alleles frequencies.
source
Analytical.DiscSFSSelNegDownFunction
DiscSFSSelNegDown(param,ppos)

Expected rate of positive selected allele frequency reduce by background selection. Spectrum drawn on a gamma DFE. It depends on the number of individuals.

Arguments

  • ppos::Float64: positive selected alleles probabilty.

Return:

  • Array{Float64}: expected negative selected alleles frequencies.
source
Missing docstring.

Missing docstring for Analytical.cumulativeSfs. Check Documenter's build log for details.

Summary statistics

Missing docstring.

Missing docstring for Analytical.poissonFixation. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Analytical.poissonPolymorphism. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Analytical.sampledAlpha. Check Documenter's build log for details.

Analytical.iterRatesFunction
iterRates(param::parameters,afac::Float64,bfac::Float64,alTot::Float64,alLow::Float64,divergence::Array,sfs::Array)

Estimating rates given a model for all B range.

Arguments

  • param::parameters
  • convoluted_samples::binomial_dict
  • alTot::Float64
  • alLow::Float64
  • gH::Int64
  • gL::Int64
  • gamNeg::Int64
  • afac::Float64
  • ρ::Float64
  • θ::Float64

Output

  • Array{Float64,2}
source
Analytical.gettingRatesFunction
gettingRates(gammaL,gammaH,pposL,pposH,observedData,nopos)

Estimating analytical rates of fixation and polymorphism to approach α value accouting for background selection, weakly and strong positive selection. Output values will be used to sample from a Poisson distribution the total counts of polymorphism and divergence using observed data.

Arguments

  • param::parameters
  • cnvBinom::SparseMatrixCSC{Float64,Int64}

Returns

  • Array{Float64,2} containing solved model, fixation and polymorphic rates
source
Missing docstring.

Missing docstring for Analytical.summaryStatsFromRates. Check Documenter's build log for details.

Inference tools

Missing docstring.

Missing docstring for Analytical.parseSfs. Check Documenter's build log for details.

Analytical.ABCregFunction
ABCreg(analysis_folder, replicas, S, tol, abcreg)

Performing ABC inference using ABCreg. Please, be sure your analysis_folder contain the files alphas.txt and summaries.txt produced by Analytical.summaryStatsFromRates()

Arguments

  • analysis_folder::String : Folder containing the observed data and summary estatistics. It will be used to output the posterior distributions
  • S::Int64 : Number of summary stastitics to perform the inference.
  • tol::Float64 : Tolerance value. It define the number of accepted value at ABC inference
  • abcreg::String : Path to ABCreg binary

Output

Files containing posterior distributions from ABCreg

source