|
2 | 2 |
|
3 | 3 | Virasign can compute a **background-corrected Z-score** per reported virus using **water controls** (e.g. negative controls). This mirrors a common idea in metagenomic reporting: quantify whether a signal is unusually high compared to background contamination. |
4 | 4 |
|
5 | | -This concept is used in CZ ID / IDseq as part of their “background model” reporting. See: |
6 | | -- IDseq paper (GigaScience, 2020): `https://ncbi.nlm.nih.gov/pmc/articles/PMC7566497/` (background models and z-scores described at a high level) |
7 | | -- CZ ID workflows wiki: `https://github.com/chanzuckerberg/czid-workflows/wiki` |
8 | | - |
9 | 5 | --- |
10 | 6 |
|
11 | 7 | ## Why use a Z-score? |
@@ -43,36 +39,12 @@ Virasign computes the Z-score using the per-hit **remapped** `mapped_reads` (the |
43 | 39 |
|
44 | 40 | ## Formula |
45 | 41 |
|
46 | | -For a given virus label `v`, and a set of water controls `W`: |
47 | | - |
48 | | -- Compute the transformed values in each water control: |
49 | | - |
50 | | -```text |
51 | | -y[w,v] = log10(x[w,v] + 1) |
52 | | -``` |
53 | | - |
54 | | -where `x[w,v]` is `mapped_reads` for virus `v` in water sample `w`. If a virus is absent from a water sample, `x[w,v] = 0`. |
55 | | - |
56 | | -- Compute background mean and standard deviation: |
| 42 | +Virasign computes, for each virus, a Z-score as the number of standard deviations that the sample’s log-transformed `mapped_reads` signal is above/below the mean of the selected water controls. |
57 | 43 |
|
58 | | -```text |
59 | | -mu[v] = mean( y[w,v] for w in W ) |
60 | | -sigma[v] = stdev( y[w,v] for w in W ) # sample stdev (ddof=1) |
61 | | -``` |
62 | | - |
63 | | -For a non-water sample `s`: |
64 | | - |
65 | | -```text |
66 | | -z[s,v] = ( y[s,v] - mu[v] ) / sigma[v] |
67 | | -``` |
| 44 | +This follows the same background-correction idea used by CZ ID / IDseq background models. For more information, see: |
68 | 45 |
|
69 | | -### Zero-variance case (`sigma[v] = 0`) |
70 | | - |
71 | | -If all controls have exactly the same value for a virus, the classical Z-score is undefined. Virasign keeps the output numeric and directional by using a tiny `epsilon` in the denominator and capping extremes: |
72 | | - |
73 | | -- equal to controls → `z = 0` |
74 | | -- higher than controls → large positive Z |
75 | | -- lower than controls → large negative Z |
| 46 | +- IDseq paper (GigaScience, 2020): `https://ncbi.nlm.nih.gov/pmc/articles/PMC7566497/` |
| 47 | +- CZ ID workflows wiki: `https://github.com/chanzuckerberg/czid-workflows/wiki` |
76 | 48 |
|
77 | 49 | --- |
78 | 50 |
|
|
0 commit comments