Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Bug fixes

Maintenance
-----------

* Update the alternative allele probability limits from [0.01, 0.99] to [0.001, 0.999]
(:issue:`185`, :issue:`276`, :pr:`227`, :user:`RosCraddock`, :user:`XingerTang`, :user:`gregorgorjanc`).
* Renaming of command line arguments, changing of input format, and corresponding documentation and test updates
(:issue:`221`, :pr:`219` ,:pr:`222`, :user:`RosCraddock`, :user:`gregorgorjanc`, :user:`XingerTang`).

Expand Down
9 changes: 5 additions & 4 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,6 @@ Alternative allele probabilities are estimated (using ``-est_alt_allele_prob``)
as half of the mean of estimated :ref:`allele dosage <dosage_file_format>`
in the base population(s) (metafounders).

..
The estimates are constrained to be between 0.01 and 0.99
to avoid TODO: discuss with Evie how to word this.

This estimation can be warm-started with a sample estimate from inputted genomic data
(using ``-est_start_alt_allele_prob``).
Note that this sample estimate is not taking the pedigree structure into account,
Expand All @@ -353,6 +349,11 @@ there are three options to obtain metafounder-specific alternative allele probab
In all three cases,
``-est_alt_allele_prob`` is optional.

The estimates (using ``-est_start_alt_allele_prob`` or ``-est_alt_allele_prob``) or
inputs (using ``-alt_allele_prob_file``) of the alternative allele probabilities
are constrained to be between 0.001 and 0.999 to ensure valid probabilities and
avoid getting trapped in boundary values, 0 or 1.

Error probabilities (using ``-est_geno_error_prob`` and ``-est_seq_error_prob``)
are estimated as the proportion of mismatches between observed and inferred states.

Expand Down
28 changes: 14 additions & 14 deletions src/tinypeel/Peeling/PeelingUpdates.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def updateMaf(pedigree, peelingInfo):

def newtonMafUpdates(peelingInfo, AAP, index):
"""Iterative approximation for the prior alternative allele frequency.
Currently limits all AAP to be between 0.01 and 0.99.
Currently limits all AAP to be between 0.001 and 0.999.

:param peelingInfo: Peeling information container.
:type peelingInfo: class:`PeelingInfo.jit_peelingInformation`
Expand All @@ -71,10 +71,10 @@ def newtonMafUpdates(peelingInfo, AAP, index):
:rtype: float
"""

if AAP[index] < 0.01:
maf = 0.01
elif AAP[index] > 0.99:
maf = 0.99
if AAP[index] < 0.001:
maf = 0.001
elif AAP[index] > 0.999:
maf = 0.999
else:
maf = AAP[index]

Expand All @@ -84,10 +84,10 @@ def newtonMafUpdates(peelingInfo, AAP, index):
maf_old = maf
delta = getNewtonUpdate(maf_old, peelingInfo, index)
maf = maf_old + delta
if maf < 0.01:
maf = 0.01
if maf > 0.99:
maf = 0.99
if maf < 0.001:
maf = 0.001
if maf > 0.999:
maf = 0.999
if abs(maf - maf_old) < 0.0001:
converged = True
iters -= 1
Expand Down Expand Up @@ -166,7 +166,7 @@ def addIndividualToUpdate(d, p, LLp, LLpp):

def updateMafAfterPeeling(pedigree, peelingInfo):
"""Updates the alternative allele frequency for each unknown parent group based on the mean genotype probabilities of the founders.
Currently limits all AAP to be between 0.01 and 0.99.
Currently limits all AAP to be between 0.001 and 0.999.

:param pedigree: pedigree information container
:type pedigree: class:`tinyhouse.Pedigree.Pedigree()`
Expand Down Expand Up @@ -194,10 +194,10 @@ def updateMafAfterPeeling(pedigree, peelingInfo):
for mfx in MF:
for i in range(peelingInfo.nLoci):
AAP[mfx][i] = AAP[mfx][i] / indMF[mfx]
if AAP[mfx][i] < 0.01:
AAP[mfx][i] = 0.01
elif AAP[mfx][i] > 0.99:
AAP[mfx][i] = 0.99
if AAP[mfx][i] < 0.001:
AAP[mfx][i] = 0.001
elif AAP[mfx][i] > 0.999:
AAP[mfx][i] = 0.999
pedigree.AAP[mfx] = AAP[mfx].astype(np.float32)

for ind in pedigree:
Expand Down
8 changes: 4 additions & 4 deletions src/tinypeel/tinypeel.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ def runPeelingCycles(pedigree, peelingInfo, args, singleLocusMode=False):
f"ERROR: Invalid value {pedigree.AAP[mfx][i]} for alternative allele probability for metafounder {mfx} at locus {i}. \nValues must be between 0 and 1. Set to 0.5 (default) if unknown. \nExiting..."
)
sys.exit(2)
elif pedigree.AAP[mfx][i] < 0.01:
pedigree.AAP[mfx][i] = 0.01
elif pedigree.AAP[mfx][i] > 0.99:
pedigree.AAP[mfx][i] = 0.99
elif pedigree.AAP[mfx][i] < 0.001:
pedigree.AAP[mfx][i] = 0.001
elif pedigree.AAP[mfx][i] > 0.999:
pedigree.AAP[mfx][i] = 0.999
AAP[mfx] = pedigree.AAP[mfx]
if len(ind.MetaFounder) == 2:
mafGeno = ProbMath.getGenotypesFromMultiMaf(AAP)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MF_1 MF_2
9.999999776482582092e-03 9.900000095367431641e-01
9.999999776482582092e-03 9.900000095367431641e-01
9.999999776482582092e-03 9.900000095367431641e-01
9.999999776482582092e-03 9.900000095367431641e-01
9.999999776482582092e-03 9.900000095367431641e-01
1.000000047497451305e-03 9.990000128746032715e-01
1.000000047497451305e-03 9.990000128746032715e-01
1.000000047497451305e-03 9.990000128746032715e-01
1.000000047497451305e-03 9.990000128746032715e-01
1.000000047497451305e-03 9.990000128746032715e-01
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MF_1 MF_2
9.999999776482582092e-03 9.900000095367431641e-01
9.999999776482582092e-03 9.900000095367431641e-01
1.000000047497451305e-03 9.990000128746032715e-01
1.000000047497451305e-03 9.990000128746032715e-01
5.000083446502685547e-01 4.999749958515167236e-01
9.999999776482582092e-03 9.900000095367431641e-01
9.999999776482582092e-03 9.900000095367431641e-01
1.000000047497451305e-03 9.990000128746032715e-01
1.000000047497451305e-03 9.990000128746032715e-01

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MF_1
9.999999776482582092e-03
9.999999776482582092e-03
9.999999776482582092e-03
9.999999776482582092e-03
9.999999776482582092e-03
1.000000047497451305e-03
1.000000047497451305e-03
1.000000047497451305e-03
1.000000047497451305e-03
1.000000047497451305e-03
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MF_1 MF_2
9.999999776482582092e-03 9.900000095367431641e-01
9.999999776482582092e-03 9.900000095367431641e-01
9.999999776482582092e-03 9.900000095367431641e-01
9.999999776482582092e-03 9.900000095367431641e-01
9.999999776482582092e-03 9.900000095367431641e-01
1.000000047497451305e-03 9.990000128746032715e-01
1.000000047497451305e-03 9.990000128746032715e-01
1.000000047497451305e-03 9.990000128746032715e-01
1.000000047497451305e-03 9.990000128746032715e-01
1.000000047497451305e-03 9.990000128746032715e-01
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MF_1 MF_2
9.999999776482582092e-03 5.000000000000000000e-01
9.999999776482582092e-03 5.000000000000000000e-01
9.999999776482582092e-03 5.000000000000000000e-01
9.999999776482582092e-03 5.000000000000000000e-01
9.999999776482582092e-03 5.000000000000000000e-01
1.000000047497451305e-03 5.000000000000000000e-01
1.000000047497451305e-03 5.000000000000000000e-01
1.000000047497451305e-03 5.000000000000000000e-01
1.000000047497451305e-03 5.000000000000000000e-01
1.000000047497451305e-03 5.000000000000000000e-01
Loading