# Beta-value and M-value of a CpG, and the conversion between them, version 2.0.0

genome-methylation-level\@2.0.0: this version's equations with their symbols, each constant's value, their sources and whether each was read, a worked example where the record holds one, its level and what it was checked against, the number of cases, and what was not checked. This version's record is not rewritten; a correction is added under Changes.

## What this page can and cannot show

**Level: Checked against a reference; Eq. 1 to 3 at 60 digits; Du et al.'s printed Eq. 3 pairs reproduced; offsets as stated. Reference kind: our own exact-arithmetic script and a hand-worked case; the source's own worked example, CPython standard library (decimal), 3.13.18.**

Checked by this project, not independently reviewed. Every method on this page has its equations, constants, sources and cases on record, and its cases agree with the stated reference within the stated tolerance. A reader can follow each method's worked example by hand; that shows the stated method gives the stated answer for one set of inputs, and does not test the code. The other cases and their values are not printed, so a reader cannot re-run these checks. No independent scientist has yet reviewed them.

[Every version of this method](https://www.drybench.com/methods/m/genome-methylation-level) · [Every method](https://www.drybench.com/methods/m) · [What the levels mean](https://www.drybench.com/methods/levels)

## Version 2.0.0

**Level: Checked against a reference; Eq. 1 to 3 at 60 digits; Du et al.'s printed Eq. 3 pairs reproduced; offsets as stated. Reference kind: our own exact-arithmetic script and a hand-worked case; the source's own worked example, CPython standard library (decimal), 3.13.18.** `genome-methylation-level@2.0.0`

Built, not hosted. Generated from a snapshot of the library's records taken on 2026-11-25, as committed on 2026-11-25. A later snapshot replaces this one, so these records and this page can change.

**Verification statement:** Eq. 1 to 3 at 60 digits in a script of our own, hand-worked, with Du et al.'s printed pairs (beta 0.2, 0.5 and 0.8 with M -2, 0 and 2) reproduced in both directions; offsets as stated

Du et al. 2010: beta = max(meth, 0) / (max(unmeth, 0) + max(meth, 0) + alpha\_beta) and M = log2((max(meth, 0) + alpha\_M) / (max(unmeth, 0) + alpha\_M)) from methylated and unmethylated signals with stated offsets, or beta and M converted by Eq. 3, which ignores offsets. Negative signals are set to zero and reported; no site is called.

- **How results are reported:** none: full double precision, unrounded; M from signals within a few ulps of the exact log2 ratio on the stated signals and offset (log1p where |x| \<= 1/2, x = (m' - u')/(u' + alpha\_M); one division otherwise; the difference of logs only where the ratio overflows or falls below the smallest normal double); beta from M within two ulps; M from beta within a few ulps of the exact value on the stated decimal; measured by stored reference values against mpmath at 50 digits
- **Uncertainty:** Double-precision arithmetic on the supplied signals; measurement noise is not propagated.
- **Reference, as its record states it:** Du et al.'s printed Eq. 3 pairs (the outside comparison, reproduced exactly), with a 60-digit decimal script of our own
- **Level confirmed by this project's ruling of** 14 November 2026

[What this page can and cannot show](#what-this-page-can-and-cannot-show)

### What was checked

91 cases in 3 files, linked by this exact version.

Run through the tool at build against our own exact-arithmetic script and a hand-worked case; the source's own worked example, CPython standard library (decimal), 3.13.18: 55 agree within the tolerance the file states, 36 refuse as the case expects, 0 differ, 0 were not run.

- **File 1, 46 cases**
  - **Where the expected values came from:** our own exact-arithmetic script and a hand-worked case
  - **Recorded on:** 2026-11-14
  - **Reference:** second implementation (Python 3.13), 2026-11-14; licence BSD-3-Clause
  - **Tolerance as the file states it:** beta-values relative 1e-14 (zero exact); M-values absolute 1e-14 in log2; counts, positions, texts, statuses and codes exact

- **File 2, 42 cases**
  - **Where the expected values came from:** our own exact-arithmetic script and a hand-worked case
  - **Recorded on:** 2026-11-14
  - **Reference:** CPython standard library (decimal), 3.13.18; licence PSF-2.0
  - **Tolerance as the file states it:** beta-values relative 1e-14 (zero exact); M-values absolute 1e-14 in log2; counts, positions, texts, statuses and codes exact

- **File 3, 3 cases**
  - **Where the expected values came from:** the source's own worked example, Du P et al. (2010), BMC Bioinformatics 11:587, doi 10.1186/1471-2105-11-587, Results, 'Relationship between Beta-value and M-value', Eq. 3 (Europe PMC XML, read 11 and 14 November 2026): 'Beta-values of 0.2, 0.5 and 0.8 correspond to M-values of -2, 0 and 2, respectively'
  - **Recorded on:** 2026-11-14
  - **Reference:** CPython standard library (decimal), 3.13.18; licence PSF-2.0
  - **Tolerance as the file states it:** beta-values relative 1e-14 (zero exact); M-values absolute 1e-14 in log2; counts, positions, texts, statuses and codes exact

Apart from the worked example, the cases and their values are not printed here. This shows agreement with this project's recorded cases. It does not show that a method suits your work, and it is not a qualification.

### What was not checked

Probe type, dye bias, normalisation and detection p-values; saturated intensities; any default offset of a package.

### Definition or model

A closed form: the result follows from the inputs by the equations alone.

### Equations

**Equation 1**

```equation
beta = max(meth, 0) / (max(unmeth, 0) + max(meth, 0) + alpha_beta): Du et al.'s Eq. 1, with negatives "reset to 0" as the source states
the source quotes Illumina's default offset ("by default, α = 100"), and requiring the caller to state it is this project's ruling
read counts as signals are the record's extension (the source treats array intensities)
inputs are read as the exact value of their shortest decimal
signals are at most 1e15 and offsets at most 1e12 (the kit's OUT_OF_RANGE above, tested on that value)
order of checks: the kit's checks of each argument, then CONFLICTING_ARGUMENT for an argument the chosen from does not use, then MISSING_ARGUMENT (signalKind, the signals, betaOffset, mOffset, in that order), then MATRIX_ABOVE_CAP (methylated and unmethylated together above 6,000 values), then VALUES_MISALIGNED, then the ids (VALUES_MISALIGNED, DUPLICATE_NAME), then for read counts NOT_AN_INTEGER (a negative read count included), then per site in order BETA_UNDEFINED, M_UNDEFINED and BETA_BELOW_DOUBLE_RANGE (RAISE-X5)
setToZero positions count from 0
```

| Symbol | Meaning and unit |
| --- | --- |
| beta | beta-value |
| meth | methylated signal |
| unmeth | unmethylated signal |
| alpha\_beta | the caller's beta offset |

Source: Du P, Zhang X, Huang C-C, Jafari N, Kibbe WA, Hou L, Lin SM (2010), Comparison of Beta-value and M-value methods for quantifying methylation levels by microarray analysis, BMC Bioinformatics 11:587, doi 10.1186/1471-2105-11-587, equation Eq. 1 to 3, section Results: Eq. 1 and 2 under "Definition of Beta-value and M-value"; Eq. 3 under "Relationship between Beta-value and M-value", version of record, Europe PMC full-text XML; read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning f8b9e65e8677. Free to read (CC BY), checked 2026-11-11. No erratum found (searched Europe PMC correction list for doi 10.1186/1471-2105-11-587), 2026-11-11.

**Equation 2**

```equation
M = log2((max(meth, 0) + alpha_M) / (max(unmeth, 0) + alpha_M)): Du et al.'s Eq. 2, whose offset the source gives "by default, α = 1"
requiring it to be stated is this project's ruling
```

| Symbol | Meaning and unit |
| --- | --- |
| M | M-value, log2(1) |
| alpha\_M | the caller's M offset |

Source: Du P, Zhang X, Huang C-C, Jafari N, Kibbe WA, Hou L, Lin SM (2010), Comparison of Beta-value and M-value methods for quantifying methylation levels by microarray analysis, BMC Bioinformatics 11:587, doi 10.1186/1471-2105-11-587, equation Eq. 1 to 3, section Results: Eq. 1 and 2 under "Definition of Beta-value and M-value"; Eq. 3 under "Relationship between Beta-value and M-value", version of record, Europe PMC full-text XML; read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning f8b9e65e8677. Free to read (CC BY), checked 2026-11-11. No erratum found (searched Europe PMC correction list for doi 10.1186/1471-2105-11-587), 2026-11-11.

**Equation 3**

```equation
beta = 2^M / (2^M + 1), offsets ignored
```

| Symbol | Meaning and unit |
| --- | --- |
| beta | beta-value |
| M | M-value, log2(1) |

Source: Du P, Zhang X, Huang C-C, Jafari N, Kibbe WA, Hou L, Lin SM (2010), Comparison of Beta-value and M-value methods for quantifying methylation levels by microarray analysis, BMC Bioinformatics 11:587, doi 10.1186/1471-2105-11-587, equation Eq. 1 to 3, section Results: Eq. 1 and 2 under "Definition of Beta-value and M-value"; Eq. 3 under "Relationship between Beta-value and M-value", version of record, Europe PMC full-text XML; read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning f8b9e65e8677. Free to read (CC BY), checked 2026-11-11. No erratum found (searched Europe PMC correction list for doi 10.1186/1471-2105-11-587), 2026-11-11.

**Equation 4**

```equation
M = log2(beta / (1 - beta)), offsets ignored: computed on the exact value of beta's shortest decimal (SGB-1), b/(1 - b) as a fraction, then log1p of b/(1 - b) - 1 over ln 2 where the ratio is within a factor of 2 of 1, else log2 of its nearest double
so Du et al.'s 0.8 gives exactly 2, and 0.9999999999999999 gives log2(9999999999999999), about 53.15, where the double's 1 - beta would give 53
BETA_AT_BOUND is decided on that decimal, so a typed 0.99999999999999999, which JSON reads as 1, is refused
```

| Symbol | Meaning and unit |
| --- | --- |
| M | M-value, log2(1) |
| beta | beta-value |

Source: Du P, Zhang X, Huang C-C, Jafari N, Kibbe WA, Hou L, Lin SM (2010), Comparison of Beta-value and M-value methods for quantifying methylation levels by microarray analysis, BMC Bioinformatics 11:587, doi 10.1186/1471-2105-11-587, equation Eq. 1 to 3, section Results: Eq. 1 and 2 under "Definition of Beta-value and M-value"; Eq. 3 under "Relationship between Beta-value and M-value", version of record, Europe PMC full-text XML; read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning f8b9e65e8677. Free to read (CC BY), checked 2026-11-11. No erratum found (searched Europe PMC correction list for doi 10.1186/1471-2105-11-587), 2026-11-11.

### Conventions

What each mode computes:

- `from = signals`: beta and M from methylated and unmethylated signals, by Eq. 1 and 2 with the stated offsets
- `from = beta`: M from beta-values by Eq. 3, which ignores offsets
- `from = m-value`: beta from M-values by Eq. 3, which ignores offsets

### Constants

Constants: none used.

### Worked example

Worked example: one case of genome-methylation-level\@2.0.0, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.

**Inputs**

- from = signals
- signalKind = intensities
- methylated.values\[0\] = 3000
- methylated.unit = 1
- unmethylated.values\[0\] = 1000
- unmethylated.unit = 1
- betaOffset = 100
- mOffset = 1

**Steps**

1. b = 0.73170732, from methylated, unmethylated, betaOffset; by equation 1; gives result.betaValue.values\[0\].
2. m = 1.5840013 log2(1), from methylated, unmethylated, mOffset; by equation 2; gives result.mValue.values\[0\].

The working, as the case writes it:

```equation
[0] beta = 3000/(1000+3000+100) = 0.7317073170731707317073170731707317073171
M = log2((3000+1)/(1000+1)) = 1.584001344762294793309824886573047887911
```

**Answer**

- `result.betaValue.values[0]` = **0.73170732**
- `result.mValue.values[0]` = **1.5840013 log2(1)**

Where these values came from: our own exact-arithmetic script and a hand-worked case; Worked by hand by Drybench on 11 November 2026 (ruling 3). This is not an independent check.

At build the tool returned this answer within the tolerance the file states: beta-values relative 1e-14 (zero exact); M-values absolute 1e-14 in log2; counts, positions, texts, statuses and codes exact.

Who worked this case: not recorded.

### What it refuses, and its input ranges

- `BETA_UNDEFINED`: both signals are zero after negatives are set to zero and the beta offset is zero, so beta is zero over zero Next: State a beta offset above zero, or leave out the sites with no signal.
- `M_UNDEFINED`: a signal is zero after negatives are set to zero and the M offset is zero, so M is infinite Next: State an M offset above zero, or leave out the sites with a zero signal.
- `BETA_AT_BOUND`: a beta-value of zero or one has no finite M-value Next: Leave out beta-values of exactly zero or one, or convert from the signals with offsets.
- `BETA_BELOW_DOUBLE_RANGE`: a beta-value, from signals or from an M-value, would be a non-zero number below the smallest normal double, which a double holds only to reduced precision; a beta that rounds to zero is returned as zero Next: Use the M-value, which stays finite, or leave out the site.
- `VALUES_MISALIGNED` (invalid input): the methylated and unmethylated vectors, or the ids, are not one per site
- `MATRIX_ABOVE_CAP` (invalid input): the values sent are more numeric cells than the tool's cap

### Changes

#### 2026-11-14-genome-methylation-level\@2.0.0-1

2026-11-14 · [`genome-methylation-level@2.0.0`](https://www.drybench.com/methods/m/genome-methylation-level) · Corrections to our methods

- **What was wrong:** Three conversions lost digits in 1.0.0. M from signals was formed as a difference of two logarithms, which loses digits wherever the signals plus their offset are large relative to their difference: with signals 3000 and 1000 and an M offset of 1e12, M was 1.1e-6 relative off. Beta from M was one ulp low, or exactly 1, from about M = 52, and exactly 0 at M of -1024 and below, where beta is a subnormal. M from beta formed 1 - beta on the double, so it moved by ulps everywhere (Du et al.'s 0.8 gave 2 plus one ulp) and, close to 1, by more: 0.9999999999999999 gave 53 where its decimal gives about 53.15. The m-value statement said beta is exactly one or zero at large M, which is true of the double returned but not of beta. A beta-value below the smallest normal double, such as about 1e-315 from signals 1e-300 and 1e15, was served as a subnormal number held to reduced precision.
- **Affected:** Version 1.0.0 of the assistant tool genome\_methylation\_level: M-values from signals wherever the signals plus offset are large relative to their difference; beta-values from M above about 52 and below about -1024; every M-value from a beta-value, by ulps, and by more for beta-values within a few parts in 10^16 of 1; and the wording of the m-value statement. Beta-values from signals did not change.
- **What changed:** In 2.0.0, M keeps full relative precision near zero (log1p) and elsewhere (one division); M from beta is taken on the exact decimal, so Du et al.'s 0.8 gives exactly 2; beta from M is within two ulps of the exact value everywhere (a series above M of 30), and the statement names the three forms, says that beta is in the open interval and that a returned one or zero is rounding. The bounds are measured by stored reference values. A beta-value that would be a non-zero subnormal is refused as BETA\_BELOW\_DOUBLE\_RANGE (a served subnormal beta-value becomes a refusal; RAISE-X5).
- **How it was found:** A second implementation in Python by a separate agent of the same model family, in the raising run's full check of 14 November 2026 (finding SEQ-F7), and the CSO's review of the same run (S102 to S104).
- **Cases added:** stored reference values and stored reference values re-record the retired -1 and -2 at 2.0.0, with the SEQ-F7 case, M near zero at small and maximal offsets, beta's double at and just inside 0 and 1, a beta just below 1, and the bounds either side.

## Tools that use it

- [`genome_methylation_level`](https://www.drybench.com/methods/tools/genome-methylation-level)

## Cite this version

Beta-value and M-value of a CpG, and the conversion between them. Drybench; genome-methylation-level\@2.0.0; [https://www.drybench.com/methods/m/genome-methylation-level/2.0.0](https://www.drybench.com/methods/m/genome-methylation-level/2.0.0) (accessed \[date\]).
