Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
### Changed
- Cleanup: removed unused `pixel_size` argument from `novae.spatial_neighbors`

### Fixed
- Upgrade sopa to import `sopa.constants` instead of `sopa._constants` (#38)

## [1.0.1] - 2025-12-10

🎉 Novae is now [published in Nature Methods](https://www.nature.com/articles/s41592-025-02899-6)!
Expand Down
2 changes: 1 addition & 1 deletion docs/advice.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ In that case, you can use other backends (two options shown below).

=== "Backed H5"

You can read your data in "backed mode" to keep `adata.X` on disk and load only the requested slices into memory when needed. It enables scalable operations on large datasets without fully materializing them in RAM.
You can read your data in "backed mode" to keep `adata.X` on disk and load only the requested slices into memory when needed. It enables scalable operations on large datasets without fully materializing them in RAM. **Important:** for now, the backed mode only supports dense matrices (see [this issue](https://github.com/MICS-Lab/novae/issues/37#issuecomment-3748420274)).

For instance, you can read an `h5ad` file as below:
```python
Expand Down
14 changes: 8 additions & 6 deletions docs/tutorials/main_usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To assign domains, you can use the [`assign_domains`](../../api/Novae/#novae.Novae.assign_domains) method, as below. By default, it creates 7 domains, but you can choose the number of domains you want with the `level` argument.\n",
"To assign domains, you can use the [`assign_domains`](../../api/Novae/#novae.Novae.assign_domains) method, as below.\n",
"\n",
"The function will save the domains in `adata.obs`, and return the name of the column in which it was saved (in this case, `adata.obs[\"novae_domains_7\"]`)\n"
"We recommend to **try different number of domains**, depending on your biological questions. For that, just run this function multiple times with a different `level` (or check the others [API parameters](../../api/Novae/#novae.Novae.assign_domains)).\n",
"\n",
"The function adds a new column to `adata.obs`, and returns the column name. In this case, it saved the results in `adata.obs[\"novae_domains_7\"]`.\n"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -231,7 +233,7 @@
}
],
"source": [
"model.assign_domains(adata)"
"model.assign_domains(adata, level=7)"
]
},
{
Expand Down Expand Up @@ -891,7 +893,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "novae-ezkWKrh6-py3.10",
"display_name": "spatial-dev",
"language": "python",
"name": "python3"
},
Expand All @@ -905,7 +907,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.12.12"
}
},
"nbformat": 4,
Expand Down
14 changes: 9 additions & 5 deletions novae/data/_embeddings/_histo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import logging
from typing import TYPE_CHECKING, Callable, Union
from typing import TYPE_CHECKING, Callable

import numpy as np
from anndata import AnnData
Expand All @@ -16,7 +18,7 @@


def compute_histo_embeddings(
sdata: "SpatialData",
sdata: SpatialData,
model: str | Callable = "conch",
table_key: str = "table",
patch_overlap_ratio: float = 0.5,
Expand All @@ -43,7 +45,7 @@ def compute_histo_embeddings(
"""
try:
import sopa
from sopa._constants import SopaAttrs, SopaKeys
from sopa.constants import SopaAttrs, SopaKeys
from spatialdata.models import get_table_keys
except ImportError:
raise ImportError(
Expand Down Expand Up @@ -105,7 +107,9 @@ def _quality_control_join(distances: np.ndarray):


def compute_histo_pca(
sdatas: Union["SpatialData", list["SpatialData"]], n_components: int = 50, table_key: str = "table"
sdatas: SpatialData | list[SpatialData],
n_components: int = 50,
table_key: str = "table",
) -> None:
"""Run PCA on the histology embeddings associated to each cell (from the closest patch).
The embedding is stored in `adata.obsm["histo_embeddings"]`, where `adata` is the table of cell expression.
Expand All @@ -123,7 +127,7 @@ def compute_histo_pca(
if isinstance(sdatas, SpatialData):
sdatas = [sdatas]

def _histo_emb(sdata: "SpatialData") -> np.ndarray:
def _histo_emb(sdata: SpatialData) -> np.ndarray:
_table: AnnData = sdata.tables[table_key]

assert "embedding_key" in _table.obs, (
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies = [
]

[project.optional-dependencies]
multimodal = ["sopa>=2.1.0", "spatialdata>=0.5.0", "timm>=1.0.15"]
multimodal = ["sopa>=2.1.11", "timm>=1.0.15"]
conch = ["einops-exts>=0.0.4", "transformers>=4.52.4"]

[dependency-groups]
Expand Down
Loading
Loading