Skip to content

Commit 4aca000

Browse files
committed
made necessary changes after looking through the codebase for roughly ~1 hour
1 parent bef737a commit 4aca000

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

malariagen_data/anoph/g123.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,17 @@ def g123_gwss(
173173
name = "g123_gwss_v1"
174174

175175
if sites == base_params.DEFAULT:
176-
assert self._default_phasing_analysis is not None
177-
sites = self._default_phasing_analysis
176+
#changed this part to fix the defaulting
177+
if self._default_phasing_analysis is not None:
178+
sites = self._default_phasing_analysis
179+
else:
180+
# Fall back to segregating sites for datasets that have no
181+
# phasing analysis (e.g., Adir1, Amin1). G123 operates on
182+
# unphased diplotype data and does not require phased haplotypes;
183+
# the phasing analysis is used only as a convenient set of
184+
# ascertained sites. Where no such analysis exists, segregating
185+
# sites within the analysed samples are an appropriate substitute.
186+
sites = "segregating"
178187
valid_sites = self.phasing_analysis_ids + ("all", "segregating")
179188
if sites not in valid_sites:
180189
raise ValueError(
@@ -279,6 +288,18 @@ def g123_calibration(
279288
# invalidate any previously cached data.
280289
name = "g123_calibration_v1"
281290

291+
# for calibration runs, if we want to use it on a dataset
292+
if sites == base_params.DEFAULT:
293+
if self._default_phasing_analysis is not None:
294+
sites = self._default_phasing_analysis
295+
else:
296+
sites = "segregating"
297+
valid_sites = self.phasing_analysis_ids + ("all", "segregating")
298+
if sites not in valid_sites:
299+
raise ValueError(
300+
f"Invalid value for `sites` parameter, must be one of {valid_sites}."
301+
)
302+
282303
params = dict(
283304
contig=contig,
284305
sites=sites,
@@ -642,4 +663,4 @@ def _garud_g123(gt):
642663
# g2 = g1 - f[0] ** 2 # type: ignore[index]
643664
# g2_g1 = g2 / g1
644665

645-
return g123
666+
return g123

0 commit comments

Comments
 (0)