Skip to content

Commit 970eb3b

Browse files
committed
.
1 parent 9fd7548 commit 970eb3b

1 file changed

Lines changed: 4 additions & 32 deletions

File tree

docs/Z_SCORE.md

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
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.
44

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-
95
---
106

117
## Why use a Z-score?
@@ -43,36 +39,12 @@ Virasign computes the Z-score using the per-hit **remapped** `mapped_reads` (the
4339

4440
## Formula
4541

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.
5743

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:
6845

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`
7648

7749
---
7850

0 commit comments

Comments
 (0)