> 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/single-cell-spatial/gene-co-expression-overlap.md).

# Gene co-expression overlap

Quantify expression overlap between two genes or signatures, including the fractions of cells expressing either or both and their Jaccard similarity.

Quantify expression overlap between two genes or signatures, including the fractions of cells expressing either or both and their Jaccard similarity.

## Two-feature Jaccard / co-expression overlap

### Description

#### Analysis summary

Quantifies how two features — genes or signatures — overlap across cells or spots: what fraction of observations express only the first, only the second, or both, summarised by a Jaccard index per group.

#### Computation

For each group, every observation is classified by which of the two features it expresses (a feature is expressed when its presence signal is greater than zero after aggregation; with signatures, a feature's score is the mean of its member genes' signals), giving the percentage of observations expressing only feature A, only feature B, or both — the percentages are calculated over all observations in the group, so the three categories sum to 100% only when every observation expresses at least one feature. Alongside each category's percentage, the mean expression of the observations in it is computed. The Jaccard index — the number of co-expressing observations divided by the number expressing at least one feature — summarises the overlap; it is computed once per group and reported alongside it. A Fisher exact test of the two features' association within each group is computed automatically, with its odds ratio and 95% confidence interval.

#### When to use

Use this analysis ONLY when the goal is to quantify the overlap between exactly two features — overlap fractions, the Jaccard index, the co-occurrence association. For standard expression summaries of many genes across cell types, use sparse\_aggregation\_analysis instead.

#### Caveats

Two features only: no more, no fewer. Mean expression is the mean over all observations in the category, expressing or not. With the spatial neighbourhood option, 'expressing' means the observation itself or any of its nearest neighbours express the feature, while mean expression still reflects the observation itself — the two dimensions are then not strictly comparable.

### Example questions

<details>

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

* Single-cell co-expression of two genes or signatures across cell types
* Spatial co-expression of two genes or signatures across spot groups

</details>

### Input columns

<details>

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

| column          | type        | required | description                                                                                                                                                        |
| --------------- | ----------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| index           | any         | required | Observation identifier (e.g. cell\_id, spot\_id). Unit of co-expression measurement.                                                                               |
| value\_sparsity | numeric     | required | Threshold column — value\_sparsity > 0 means the feature is expressed/present (e.g. count\_raw).                                                                   |
| value           | numeric     | required | Quantity to average for mean expression (e.g. count\_lognorm).                                                                                                     |
| x\_group        | categorical | required | Feature label column. Must contain the gene names belonging to features\[0].members and features\[1].members. The analysis aggregates member genes into per-featu… |
| y\_group        | categorical | optional | Grouping variable across which co-expression is compared (e.g. cell\_type, spot\_group).                                                                           |
| x\_coord        | numeric     | optional | X spatial coordinate. Required when use\_neighbors=True.                                                                                                           |
| y\_coord        | numeric     | optional | Y spatial coordinate. Required when use\_neighbors=True.                                                                                                           |
| sample\_id      | categorical | optional | Sample identifier used to constrain neighbour search within samples. Required when use\_neighbors=True.                                                            |
| patient\_id     | categorical | required | Patient identifier required for population summary statistics.                                                                                                     |

</details>

### Visualizations

* `dotplot` How to read: One row per group (e.g. cell type); the x-axis always holds the three categories — feature A only, feature B only, and both — so dot positions are comparable across any pair of features. Each dot's area is the share of that group's observations falling in the category (size legend in %), and its colour is the category's mean expression (colour bar). The co-expressing dot's hover adds the group's Jaccard index. A Fisher's exact test of the two features' association within each group is reported in the accompanying statistical table.

### Example analysis 1

#### Name — ERBB2 vs TP53 Co-expression in Immune Cells (MOSAIC Bladder)

#### Analysis parameters

<details>

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

```json
{
  "analysis_name": "coexpression_analysis",
  "analysis_params": {
    "features": [
      {
        "members": [
          "ERBB2"
        ],
        "label": "ERBB2"
      },
      {
        "members": [
          "TP53"
        ],
        "label": "TP53"
      }
    ]
  },
  "viz_params": {
    "y_group_label": "Cell Type (Mid Level)",
    "value_label": "Mean Expression<br>(log2(CPM+1))",
    "percent_expressing_label": "Percent Cells<br>Expressing",
    "plot_name": "dotplot",
    "title": "ERBB2 vs TP53 Co-expression in Immune Cells (MOSAIC Bladder)"
  }
}
```

</details>

#### Visualization — `dotplot`

![ERBB2 vs TP53 Co-expression in Immune Cells (MOSAIC Bladder)](https://1034377358-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTmCjUj6W0sltjW7q2vBp%2Fuploads%2Fgit-blob-f68bf35605d6410f91fef3f7dfb70f5e95d984d8%2Fcoexpression_analysis__coexpression__dotplot.png?alt=media)

#### Output table

<details>

<summary><code>descriptive_stats</code> (first 10 of 21 rows)</summary>

| y\_group    | pct\_express | mean\_expression | category   | jaccard\_index | \_pct\_fraction |
| ----------- | ------------ | ---------------- | ---------- | -------------- | --------------- |
| T\_NK       | 2.076        | 6.621            | ERBB2 only |                | 0.02076         |
| Granulocyte | 5.324        | 6.955            | ERBB2 only |                | 0.05324         |
| MoMac       | 2.638        | 6.054            | ERBB2 only |                | 0.02638         |
| Plasma      | 2.852        | 5.191            | ERBB2 only |                | 0.02852         |
| B\_cell     | 2.318        | 6.718            | ERBB2 only |                | 0.02318         |
| DC          | 3.757        | 6.129            | ERBB2 only |                | 0.03757         |
| Mast        | 2.009        | 6.598            | ERBB2 only |                | 0.02009         |
| T\_NK       | 6.909        | 6.821            | TP53 only  |                | 0.06909         |
| Granulocyte | 2.778        | 6.705            | TP53 only  |                | 0.02778         |
| MoMac       | 8.196        | 6.058            | TP53 only  |                | 0.08196         |

</details>

<details>

<summary><code>statistical_tests</code> (7 rows)</summary>

| Test                | Contrast      | y\_group    | fisher\_p\_value | odds\_ratio | odds\_ratio\_ci\_low | odds\_ratio\_ci\_high | Significance level |
| ------------------- | ------------- | ----------- | ---------------- | ----------- | -------------------- | --------------------- | ------------------ |
| Fisher's exact test | ERBB2 vs TP53 | T\_NK       | 0.7691           | 1.096       | 0.5824               | 1.907                 |                    |
| Fisher's exact test | ERBB2 vs TP53 | DC          | 0.09455          | 1.75        | 0.8704               | 3.319                 |                    |
| Fisher's exact test | ERBB2 vs TP53 | Granulocyte | 0.05434          | 4.257       | 0.7214               | 17.38                 |                    |
| Fisher's exact test | ERBB2 vs TP53 | Mast        | 0.4505           | 1.8         | 0.04106              | 12.73                 |                    |
| Fisher's exact test | ERBB2 vs TP53 | B\_cell     | 0.2224           | 1.612       | 0.5964               | 3.741                 |                    |
| Fisher's exact test | ERBB2 vs TP53 | Plasma      | 0.00131          | 2.647       | 1.461                | 4.534                 | ★★                 |
| Fisher's exact test | ERBB2 vs TP53 | MoMac       | 0.4083           | 1.21        | 0.7531               | 1.866                 |                    |

</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/single-cell-spatial/gene-co-expression-overlap.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.
