Skip to content

Commit

Permalink
LogNormal DFE for humans (#1698)
Browse files Browse the repository at this point in the history
  • Loading branch information
clararehmann authored Feb 26, 2025
1 parent 2ccbf88 commit d39b579
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
32 changes: 32 additions & 0 deletions stdpopsim/qc/HomSap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1827,3 +1827,35 @@ def genericDFE():


_species.get_dfe("Mixed_K23").register_qc(genericDFE())


def HuberLog():
"""
lognormal DFE from Huber et al. 2017 PNAS.
"""
id = "Huber2017_lognormal_dfe"
neutral = stdpopsim.MutationType()
# mu and sigma values from table s3
muvalD = -7.37
sigmaval = 4.58
expectedmean = math.exp(muvalD + (1 / 2) * (sigmaval**2))
# converting DaDi to SLiM selection coefficients -
targetmean = 2 * expectedmean
muvalS = math.log(targetmean) - (1 / 2) * (sigmaval**2)

negative = stdpopsim.MutationType(
dominance_coeff=0.5,
distribution_type="ln", # lognormal distribution
distribution_args=[muvalS, sigmaval],
)

return stdpopsim.DFE(
id=id,
description=id,
long_description=id,
mutation_types=[neutral, negative],
proportions=[0.3, 0.7],
)


_species.get_dfe("LogNormal_H17").register_qc(HuberLog())
5 changes: 4 additions & 1 deletion tests/test_dfes.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,10 @@ def test_mutation_types_match(self):
for i in range(len(mt1)):
assert mt1[i].dominance_coeff == mt2[i].dominance_coeff
assert mt1[i].distribution_type == mt2[i].distribution_type
assert np.allclose(mt1[i].distribution_args, mt2[i].distribution_args)
if all(isinstance(x, str) for x in mt1[i].distribution_args):
assert mt1[i].distribution_args == mt2[i].distribution_args
else:
assert np.allclose(mt1[i].distribution_args, mt2[i].distribution_args)
assert mt1[i].convert_to_substitution == mt2[i].convert_to_substitution

def test_proporitions_match(self):
Expand Down

0 comments on commit d39b579

Please sign in to comment.