> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bioptimus.com/llms.txt
> Use this file to discover all available pages before exploring further.

# bioptimus.preprocess.omics.transforms

Concrete omics preprocessing transforms.

## Log1pTransform

```python theme={null}
class Log1pTransform(OmicsPreprocessor)
```

Element-wise `log(1 + x)` ↔ `expm1(x)`.

Entries equal to `NON_MEASURED_GENE` (the missing-gene sentinel) are preserved verbatim rather than transformed, since `log1p(-1) = -inf`. The model is trained to receive the sentinel unchanged in its input space, so it must survive the transform.

***

#### process

```python theme={null}
def process(matrix: np.ndarray) -> np.ndarray
```

Applies element-wise `log1p`, preserving the missing-gene sentinel.

Entries equal to `NON_MEASURED_GENE` are left unchanged; all other entries are `log1p`-transformed.

<ParamField body="matrix">
  Input counts array.
</ParamField>

**Returns**:

Log1p-transformed array with sentinels preserved.

***

#### reverse

```python theme={null}
def reverse(matrix: np.ndarray) -> np.ndarray
```

Applies element-wise `expm1` (inverse of log1p).

Entries equal to `NON_MEASURED_GENE` are preserved unchanged so the transform remains a true inverse of [`process`](/sdk-reference/preprocess/omics/transforms#process).

<ParamField body="matrix">
  Log1p-transformed array.
</ParamField>

**Returns**:

Array in original counts space.

## Expm1Transform

```python theme={null}
class Expm1Transform(OmicsPreprocessor)
```

Element-wise `expm1(x)` ↔ `log1p(x)`.

Inverse of [`Log1pTransform`](/sdk-reference/preprocess/omics/transforms#log1ptransform).  Useful as a standalone post-processor to convert log1p-space model output back to raw counts.

***

#### process

```python theme={null}
def process(matrix: np.ndarray) -> np.ndarray
```

Applies element-wise `expm1`.

<ParamField body="matrix">
  Log-space array.
</ParamField>

**Returns**:

Array in counts space.

***

#### reverse

```python theme={null}
def reverse(matrix: np.ndarray) -> np.ndarray
```

Applies element-wise `log1p` (inverse of expm1).

<ParamField body="matrix">
  Counts-space array.
</ParamField>

**Returns**:

Log1p-transformed array.

## TPMNormaliser

```python theme={null}
class TPMNormaliser(factor: float = 1000000.0)
```

Transcripts Per Million normalisation (row-wise).

Forward:  counts → (counts / row\_sum) \* 1e6 Not reversible without storing original totals.

Entries equal to `NON_MEASURED_GENE` (the missing-gene sentinel) are excluded from the row total and preserved verbatim in the output, so a partially or fully unmeasured sample is not scaled by a meaningless negative sum and the sentinel survives for downstream transforms.

***

#### process

```python theme={null}
def process(matrix: np.ndarray) -> np.ndarray
```

Normalises each row to sum to *factor* (default 1e6).

All-zero rows remain all zeros (division is skipped). Entries equal to `NON_MEASURED_GENE` are excluded from the row sum and left unchanged in the output.

<ParamField body="matrix">
  Raw counts array.
</ParamField>

**Returns**:

TPM-normalised array with missing-gene sentinels preserved.

## ZScoreNormaliser

```python theme={null}
class ZScoreNormaliser(mean: np.ndarray, std: np.ndarray, eps: float = 1e-08)
```

Gene-wise z-score normalisation.

Forward:  `(x - mean) / std` Reverse:  `x * std + mean`

***

#### process

```python theme={null}
def process(matrix: np.ndarray) -> np.ndarray
```

Applies gene-wise z-score normalisation.

<ParamField body="matrix">
  Raw expression array.
</ParamField>

**Returns**:

Z-scored array.

***

#### reverse

```python theme={null}
def reverse(matrix: np.ndarray) -> np.ndarray
```

Reverses z-score normalisation to recover original scale.

<ParamField body="matrix">
  Z-scored array.
</ParamField>

**Returns**:

Array in original expression scale.

## SubsetColumns

```python theme={null}
class SubsetColumns(indices: list[int])
```

Selects and reorders columns by index.

Not reversible (information is discarded).

***

#### process

```python theme={null}
def process(matrix: np.ndarray) -> np.ndarray
```

Selects columns at the stored indices.

<ParamField body="matrix">
  Input array with columns to subset.
</ParamField>

**Returns**:

Array with only the selected columns.

**Raises**:

* `ValueError` - If any index is out of range for the matrix's last-axis size.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.