Commit 69db59c
khushthecoder
Make the sex-linked contig configurable in CNV frequency analysis
Fix #1313.
gene_cnv_frequencies() and gene_cnv_frequencies_advanced() hardcoded
`region.contig == "X"` when computing expected copy number. That is
correct for every currently supported assembly, but bakes in a
gambiae-complex assumption: any future species whose sex-linked contig
uses a different name would silently fall through to the diploid branch
and report incorrect amplification / deletion frequencies for males.
Changes:
- Add a `sex_contig` constructor parameter to
`AnophelesGenomeSequenceData` (defaulting to "X") and expose it as a
public `sex_contig` property, matching the pattern already used for
`virtual_contigs`.
- Thread `sex_contig` through `AnophelesDataResource.__init__` so
species subclasses can override it when their assembly differs.
- Replace both hardcoded `"X"` comparisons in cnv_frq.py with a shared
`_expected_copy_number()` helper that consults `self._sex_contig`.
- Handle missing `sex_call` explicitly: if the sex-linked contig is
requested but `sex_call` is absent from the sample metadata, emit a
UserWarning and fall back to diploid for all samples rather than
raising KeyError or silently returning a misleading scalar.
The default of "X" keeps behaviour unchanged for Ag3, Af1, As1, and
every other existing resource. New species (e.g. An. farauti) can opt
in by passing `sex_contig=` during construction.1 parent 9c1bb56 commit 69db59c
File tree
3 files changed
+45
-11
lines changed- malariagen_data
- anoph
3 files changed
+45
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
32 | 58 | | |
33 | 59 | | |
34 | 60 | | |
| |||
290 | 316 | | |
291 | 317 | | |
292 | 318 | | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
| 319 | + | |
298 | 320 | | |
299 | 321 | | |
300 | 322 | | |
| |||
557 | 579 | | |
558 | 580 | | |
559 | 581 | | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
| 582 | + | |
565 | 583 | | |
566 | 584 | | |
567 | 585 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| |||
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
34 | 43 | | |
35 | 44 | | |
36 | 45 | | |
| |||
41 | 50 | | |
42 | 51 | | |
43 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
44 | 58 | | |
45 | 59 | | |
46 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| |||
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
| 183 | + | |
182 | 184 | | |
183 | 185 | | |
184 | 186 | | |
| |||
0 commit comments