- signal/normalization/numerics.py: vendor percentile, trimmean, MAD sigma (old/new), bisquare robust fits, float32/float64 typing and sequential sums reproduced exactly (ported from gtc2vcf, MIT) - signal/normalization/fit.py: outlier removal, offset, rotation, shear, scale, nn12/rr12, single-channel model for small Infinium I bins, exact and binned nearest-neighbour sweeps; vendor quirks marked QUIRK - signal/normalization/apply.py: affine transform and theta/R - pipeline/normalize.py + CLI `simurg normalize` - oracle GTCs rebuilt with -ffp-contract=off (aarch64 gcc fuses a*b+c by default, shifting the last bits); the old FMA oracle differed by <=4 ULP Result: transforms bit-identical to the oracle for all 36 GSA samples x 48 bins, for both normalization versions (3456/3456 bins, 0 ULP).
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
"""Phase P2 acceptance on P0 data: raw X/Y and control intensities assembled from IDATs equal the arrays stored
|
|
in oracle GTCs (TOC 1000/1001, 500/501). The same check on vendor GTCs runs in scripts/validate_p1_large.py --p2.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import numpy as np
|
|
import pytest
|
|
from tests.conftest import GSA_BPM, GSA_IDATS, ORACLE_GTCS, need
|
|
|
|
from simurg.formats.bpm import read_bpm
|
|
from simurg.formats.gtc import read_gtc
|
|
from simurg.formats.idat import read_idat
|
|
from simurg.signal.raw_xy import LocusMapCache, assemble_raw_xy, check_coverage
|
|
|
|
pytestmark = pytest.mark.data
|
|
|
|
|
|
def test_raw_xy_equals_oracle_gtcs() -> None:
|
|
need(GSA_BPM, GSA_IDATS, ORACLE_GTCS)
|
|
m = read_bpm(GSA_BPM)
|
|
cache = LocusMapCache(m)
|
|
gtcs = sorted(ORACLE_GTCS.glob("*.gtc"))
|
|
assert gtcs
|
|
for g in gtcs:
|
|
sid = g.stem
|
|
chip = sid.split("_")[0]
|
|
grn = read_idat(GSA_IDATS / chip / f"{sid}_Grn.idat")
|
|
red = read_idat(GSA_IDATS / chip / f"{sid}_Red.idat")
|
|
assert check_coverage(grn, m)[0] == 1.0
|
|
raw = assemble_raw_xy(grn, red, m, cache=cache)
|
|
ref = read_gtc(g)
|
|
assert np.array_equal(raw.raw_x, ref.raw_x), sid
|
|
assert np.array_equal(raw.raw_y, ref.raw_y), sid
|
|
assert np.array_equal(raw.controls_x, ref.controls_x), sid
|
|
assert np.array_equal(raw.controls_y, ref.controls_y), sid
|