CN: per-probe LRR noise from the batch reference (CYTO-042), --probe-lrr-sd/--no-probe-lrr-sd
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01814GKVzZVL3FuF3DeiZXhv
This commit is contained in:
1 parent
f1a30aa104
commit
210dbaf964
6 files changed
+67
-7
No files matched your search
@@ -86,3 +86,18 @@ def reference_het_spread(baf: npt.NDArray[np.float32]) -> npt.NDArray[np.float32
|
||||
mad = np.nanmedian(np.abs(het - med), axis=0)
|
||||
n = np.isfinite(het).sum(axis=0)
|
||||
return np.where(n >= 5, 1.4826 * mad, np.nan).astype(np.float32)
|
||||
|
||||
|
||||
def reference_lrr_spread(lrr: npt.NDArray[np.float32], ref_lrr: npt.NDArray[np.float32]) -> npt.NDArray[np.float32]:
|
||||
"""Per-probe robust SD (1.4826·MAD) of LRR across reference samples after removing each sample's median and the
|
||||
probe's reference median [OURS; per-probe noise as in PennCNV's per-marker SD, LIT: Wang et al. 2007]; NaN with
|
||||
fewer than 5 finite values."""
|
||||
import warnings
|
||||
|
||||
x = np.where(np.isfinite(lrr), lrr, np.nan).astype(np.float32)
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", RuntimeWarning)
|
||||
x = x - np.nanmedian(x, axis=1, keepdims=True) - ref_lrr[None, :]
|
||||
mad = np.nanmedian(np.abs(x - np.nanmedian(x, axis=0)), axis=0)
|
||||
n = np.isfinite(x).sum(axis=0)
|
||||
return np.where(n >= 5, 1.4826 * mad, np.nan).astype(np.float32)
|
||||
Reference in new issue
Block a user