> For the complete documentation index, see [llms.txt](https://docs.owkin.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.owkin.com/explore-and-analyse-data/data-analysis/patient-stratification-biomarkers/biomarker-feature-extraction.md). Agents can also search and read this documentation through its [MCP server](https://docs.owkin.com/~gitbook/mcp).

# Biomarker feature extraction

Identify small, stable sets of candidate biomarkers that distinguish predefined groups, with selection-stability estimates, cross-validated predictive performance, and interpretable decision trees.

Identify small, stable sets of candidate biomarkers that distinguish predefined groups, with selection-stability estimates, cross-validated predictive performance, and interpretable decision trees.

## Per-label feature extraction (heatmap)

### Description

#### Analysis summary

For each value of a categorical label — a cluster, subtype or response group, typically the output of consensus clustering — identifies a minimal set of numeric features that recovers the assignment (one label vs the rest): the candidate features most consistently selected across bootstrap resamples as separating that label from the rest. The result is a small, stable, interpretable candidate marker set per label — a biomarker-development starting point, not a validated deployable signature — mixing any modality the input provides: gene expression, gene-signature scores, clinical numerics, histomics densities. Each label's set comes with its selection stability (how consistently each feature was chosen across resamples), cross-validated predictive metrics, and an interpretable decision tree spelling out the rules behind the label.

#### Computation

Runs one-vs-rest feature selection per label value. Each draw takes a stratified subsample of the samples, without replacement (the complement serves as held-out validation), z-scores the candidate features, optionally prunes redundant ones — a supervised correlation prune that ranks features by how strongly they separate the label from the rest and drops the weaker feature of any highly correlated pair, recommended when candidates include co-expressed gene programs — and fits the selection model: Orthogonal Matching Pursuit with a fixed sparsity budget, or elastic-net logistic regression swept over several penalty strengths, each fit capped at its strongest coefficients. A feature's selection frequency is the fraction of draws that selected it; each label's final set takes the most frequently selected features up to the sparsity budget. Predictive metrics — ROC-AUC, AUC-PR, accuracy, balanced accuracy, weighted F1 and Cohen's kappa — are computed on the held-out splits for the selection model, and the chosen set is re-evaluated by independent classifiers retrained under a repeated stratified cross-validation (a CatBoost model and a shallow decision tree) to estimate how the set performs beyond the selection procedure itself. For each label, a shallow, interpretable decision tree is also fitted on the whole dataset over that label's selected features and reported as readable text — the rules that separate the label from the rest.

#### When to use

Use when a cohort already carries a categorical assignment to explain — a cluster (typically from consensus\_agglomerative\_clustering), a subtype, a response group — and the question is which small, multimodal set of features characterises or predicts each label. To discover the labels themselves, run consensus\_agglomerative\_clustering first and feed its cluster column in as the label.

#### Caveats

A selected feature set predicts the label — it is not evidence that the features drive it. Sets are less stable with few samples per label or a large candidate pool, and selection frequency depends on the sparsity budget requested. The analysis needs at least two distinct label values, and each label needs enough samples on both sides of the one-vs-rest split for the cross-validated re-evaluation (it raises with guidance otherwise); feature columns must be complete and numeric — missing values are not imputed, and the analysis raises on the first null or non-numeric feature column.

### Example questions

<details>

<summary><code>example questions</code></summary>

* What are the top 5 genes that distinguish each cluster from the rest in the MOSAIC NSCLC consensus clustering ?
* Use stability selection to find a robust 3-gene feature set for label 2.
* Extract a minimal feature set per endotype and report cross-validated ROC-AUC.
* Find a multimodal feature set per label mixing gene expression, H\&E histomics densities and clinical numerics.
* Use stability selection over a wide panel of transcriptomics, histomics and clinical features to characterize each subtype.

</details>

### Input columns

<details>

<summary><code>input columns</code></summary>

| column      | type        | required | description                                                                                                                                                       |
| ----------- | ----------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| index       | any         | required | Sample or patient identifier — one row per sample/patient.                                                                                                        |
| label       | categorical | required | Categorical assignment to explain for each sample (string or integer): a cluster, subtype, response group, etc. Typically the `cluster` column from consensus\_a… |
| patient\_id | categorical | required | Patient identifier required for population summary plots.                                                                                                         |
|             | numeric     | required | One column per candidate feature. Anything numeric the SQL SELECT'd besides the reserved columns. All values must be numeric and non-null.                        |

</details>

### Visualizations

* `heatmap` How to read: Rows are candidate features, columns are the label values (each vs the rest), and cell colour encodes the feature's selection frequency for that label — the higher the cell, the more consistently the feature was chosen across the resampling draws (see the colour bar). With sorting enabled, the most selected features gather top-left. A label with no selected feature still appears as a column, at frequency zero.

### Example analysis 1

#### Name — Top-3 Multimodal Features per CD8A-Tertile cluster (Mosaic Bladder: genes + lymphocyte density + age)

#### Analysis parameters

<details>

<summary><code>analysis_name, analysis_params, viz_params</code></summary>

```json
{
  "analysis_name": "feature_extraction",
  "analysis_params": {
    "selector": "omp",
    "n_features": 3,
    "n_repeats": 2,
    "n_splits": 4,
    "seed": 42,
    "reeval_with_catboost": true,
    "reeval_with_decision_tree": true,
    "prune_correlated_features": true,
    "correlation_cutoff": 0.8
  },
  "viz_params": {
    "plot_name": "heatmap",
    "color_label": "Selection frequency",
    "title": "Top-3 Multimodal Features per CD8A-Tertile cluster (Mosaic Bladder: genes + lymphocyte density + age)"
  }
}
```

</details>

#### Visualization — `heatmap`

![Top-3 Multimodal Features per CD8A-Tertile cluster (Mosaic Bladder: genes + lymphocyte density + age)](https://1034377358-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTmCjUj6W0sltjW7q2vBp%2Fuploads%2Fgit-blob-a0df5930a5cb459919e0cd06389d2d854bd94cb8%2Ffeature_extraction__feature_extraction__heatmap.png?alt=media)

#### Output table

<details>

<summary><code>descriptive_stats</code> (3 rows)</summary>

| label | n\_samples\_in\_label | n\_samples\_out | n\_features\_union | n\_features\_intersection | n\_features\_selected | top\_feature                    | top\_feature\_frequency | top\_features                                    | decision\_tree\_text                                                                 |
| ----- | --------------------- | --------------- | ------------------ | ------------------------- | --------------------- | ------------------------------- | ----------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------ |
| 1     | 5                     | 9               | 10                 | 0                         | 3                     | cd8a\_tpm                       | 0.85                    | cd8a\_tpm, tp53\_tpm, ror1\_tpm                  | \|--- cd8a\_tpm <= 3.12 \| \|--- class: 1 \|--- cd8a\_tpm > 3.12 \| \|--- ror1\_tpm… |
| 2     | 5                     | 9               | 10                 | 0                         | 3                     | density\_lymphocytes\_in\_tumor | 0.51                    | density\_lymphocytes\_in\_tumor, mki67\_tpm, age | \|--- mki67\_tpm <= 37.77 \| \|--- class: 1 \|--- mki67\_tpm > 37.77 \| \|--- dens…  |
| 3     | 4                     | 10              | 8                  | 1                         | 3                     | cd8a\_tpm                       | 1.0                     | cd8a\_tpm, mki67\_tpm, tp53\_tpm                 | \|--- cd8a\_tpm <= 7.96 \| \|--- class: 0 \|--- cd8a\_tpm > 7.96 \| \|--- class: 1   |

</details>

<details>

<summary><code>statistical_tests</code> (first 10 of 54 rows)</summary>

| label | evaluator        | metric             | mean   | std    | n\_bootstraps\_or\_n\_folds | avg\_train\_pct | avg\_test\_pct | avg\_n\_input\_features |
| ----- | ---------------- | ------------------ | ------ | ------ | --------------------------- | --------------- | -------------- | ----------------------- |
| 1     | selector         | roc\_auc           | 0.77   | 0.3116 | 200                         | 71.43           | 28.57          | 7.425                   |
| 1     | selector         | aucpr              | 0.7538 | 0.3043 | 200                         | 71.43           | 28.57          | 7.425                   |
| 1     | selector         | accuracy           | 0.6362 | 0.2547 | 200                         | 71.43           | 28.57          | 7.425                   |
| 1     | selector         | balanced\_accuracy | 0.6825 | 0.2659 | 200                         | 71.43           | 28.57          | 7.425                   |
| 1     | selector         | f1\_weighted       | 0.6338 | 0.2612 | 200                         | 71.43           | 28.57          | 7.425                   |
| 1     | selector         | cohen\_kappa       | 0.3085 | 0.4747 | 200                         | 71.43           | 28.57          | 7.425                   |
| 1     | catboost\_reeval | roc\_auc           | 1.0    | 0.0    | 8                           | 75.0            | 25.0           | 3.0                     |
| 1     | catboost\_reeval | aucpr              | 1.0    | 0.0    | 8                           | 75.0            | 25.0           | 3.0                     |
| 1     | catboost\_reeval | accuracy           | 1.0    | 0.0    | 8                           | 75.0            | 25.0           | 3.0                     |
| 1     | catboost\_reeval | balanced\_accuracy | 1.0    | 0.0    | 8                           | 75.0            | 25.0           | 3.0                     |

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.owkin.com/explore-and-analyse-data/data-analysis/patient-stratification-biomarkers/biomarker-feature-extraction.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
