Skip to content

Commit

Permalink
Added no_average option to CurveFits.fitParams
Browse files Browse the repository at this point in the history
  • Loading branch information
jbloom committed Dec 8, 2023
1 parent b9b4f27 commit 8cf2e9d
Show file tree
Hide file tree
Showing 3 changed files with 410 additions and 266 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ The format is based on `Keep a Changelog <https://keepachangelog.com>`_.
0.7.0
-----

Added
+++++
- Added ``no_average`` option to ``CurveFits.fitParams``.

Fixed
+++++
- Fixed problem in ``fitParams`` when only some concentrations have replicates.
Expand Down
11 changes: 10 additions & 1 deletion neutcurve/curvefits.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def fitParams(
self,
*,
average_only=True,
no_average=False,
ics=(50,),
ics_precision=0,
ic50_error=None,
Expand All @@ -272,6 +273,9 @@ def fitParams(
Args:
`average_only` (bool)
If `True`, only get parameters for average across replicates.
`no_average` (bool)
Do not include average across replicates. Mutually incompatible
with `average_only`.
`ics` (iterable)
Include ICXX for each number in this list, where the number
is the percent neutralized. So if `ics` only contains 50,
Expand Down Expand Up @@ -318,7 +322,10 @@ def fitParams(
"or you need to increase `ics_precision`."
)

key = (average_only, ics, ics_precision, ic50_error)
if average_only and no_average:
raise ValueError("both `average_only` and `no_average` are `True`")

key = (average_only, no_average, ics, ics_precision, ic50_error)

if key not in self._fitparams:
d = collections.defaultdict(list)
Expand All @@ -328,6 +335,8 @@ def fitParams(
replicates = self.replicates[(serum, virus)]
nreplicates = sum(r != "average" for r in replicates)
assert nreplicates == len(replicates) - 1
if no_average:
replicates = [r for r in replicates if r != "average"]
if average_only:
replicates = ["average"]
for replicate in replicates:
Expand Down
Loading

0 comments on commit 8cf2e9d

Please sign in to comment.