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
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.12"
cache: "pip"
cache-dependency-path: "**/pyproject.toml"
- name: Install build dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python: "3.10"
- os: ubuntu-latest
python: "3.12"
- os: ubuntu-latest
python: "3.13"
- os: ubuntu-latest
python: "3.12"
pip-flags: "--pre"
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# https://docs.readthedocs.io/en/stable/config-file/v2.html
version: 2
build:
os: ubuntu-20.04
os: ubuntu-22.04
tools:
python: "3.10"
python: "3.12"
sphinx:
configuration: docs/conf.py
# disable this for more lenient docs builds
Expand Down
51 changes: 33 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,61 @@ and this project adheres to [Semantic Versioning][].
[keep a changelog]: https://keepachangelog.com/en/1.0.0/
[semantic versioning]: https://semver.org/spec/v2.0.0.html

## Unreleased

### Changed

- Migrated to scvi-tools ≥1.4 (Lightning 2.x): replaced `use_gpu` with `accelerator`/`devices`, updated `SaveBestState` → `SaveCheckpoint`, `_initialize_model`, and `_get_loaded_data` call sites.
- `GroupDataSplitter` now splits at the **sample level** (not cell level) using `external_indexing`, ensuring every validation bag is complete.
- Bumped `requires-python` to `>=3.12`; switched package manager to [uv](https://docs.astral.sh/uv/) with a committed `uv.lock`.
- numpy ≥2.0 and anndata ≥0.12 compatibility fixes (dtype identity check, pandas `groupby(observed=True)`).

### Fixed

- Single-layer regressor head used `z_dim` instead of `class_input_dim` when sample covariates are present.
- `.squeeze()` on 1-element tensors in `create_df` produced 0-d scalars; wrapped with `np.atleast_1d`.
- Fixed floating-point undercount in `GroupDataSplitter` (`floor(1.0 - 0.9) = 0` edge case).

## [0.3.2] - 2025-12-16

### Added

- tutorial for regression
- support for sample-covariate embeddings, experimental, only one-hot
- tutorial for regression
- support for sample-covariate embeddings, experimental, only one-hot

### Changed

- removed `muon` from dependencies for tutorials
- changed the classification tutorial to include training across 3 CV folds
- removed `muon` from dependencies for tutorials
- changed the classification tutorial to include training across 3 CV folds

## Fixed
### Fixed

- fixed a bug in regression which was caused by a wrong key when accessing the continuous covariates registered with scvi-tools
- fixed a bug in regression which was caused by a wrong key when accessing the continuous covariates registered with scvi-tools

## [0.3.1] - 2025-07-14

### Fixed

- Fixed a bug in `score_top_cells` that didn't set the specified `key_added` column in .obs to True.
- Fixed a bug in `score_top_cells` that set the `key_added` to be categorical, which resulted in wrong indexing in `get_sample_representations`.
- Fixed a bug in `score_top_cells` that didn't set the specified `key_added` column in .obs to True.
- Fixed a bug in `score_top_cells` that set the `key_added` to be categorical, which resulted in wrong indexing in `get_sample_representations`.

## [0.3.0] - 2025-07-13

### Added

- **Utility functions**: Added `score_top_cells` and `get_sample_representations` to utils module
- `score_top_cells`: Function to identify and score top cells based on attention weights
- `get_sample_representations`: Function to aggregate cell-level data to sample-level representations
- **Utility functions**: Added `score_top_cells` and `get_sample_representations` to utils module
- `score_top_cells`: Function to identify and score top cells based on attention weights
- `get_sample_representations`: Function to aggregate cell-level data to sample-level representations

### Changed

- **Major refactoring**: Removed MultiVAE and MultiVAE_MIL models, keeping only MIL classifier
- **Code cleanup**: Removed MLP attention weight learning from Aggregator class
- **Parameter consistency**: Fixed default values between model and module classes
- **Dynamic z_dim**: Automatically infer z_dim from input data shape instead of hardcoded value
- **Major refactoring**: Removed MultiVAE and MultiVAE_MIL models, keeping only MIL classifier
- **Code cleanup**: Removed MLP attention weight learning from Aggregator class
- **Parameter consistency**: Fixed default values between model and module classes
- **Dynamic z_dim**: Automatically infer z_dim from input data shape instead of hardcoded value

### Fixed

- **Make categorical covariates categorical**: Ensure the correct type in `setup_anndata`.
- **Improved error handling**: If the prediction covariate hasn't been registered with `setup_anndata`, throw an error.
- **Dead links to API and changelog**: Fixed in README.
- **Make categorical covariates categorical**: Ensure the correct type in `setup_anndata`.
- **Improved error handling**: If the prediction covariate hasn't been registered with `setup_anndata`, throw an error.
- **Dead links to API and changelog**: Fixed in README.
23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,35 @@

Please refer to the [documentation][link-docs]. In particular, the

- [API documentation][link-api]
- [API documentation][link-api]

and the tutorials:

- [Classification with MultiMIL](https://multimil.readthedocs.io/en/latest/notebooks/mil_classification.html) [![Open In Colab][badge-colab]](https://colab.research.google.com/github/theislab/multimil/blob/main/docs/notebooks/mil_classification.ipynb)
- [Regression with MultiMIL](https://multimil.readthedocs.io/en/latest/notebooks/mil_regression.html) [![Open In Colab][badge-colab]](https://colab.research.google.com/github/theislab/multimil/blob/main/docs/notebooks/mil_regression.ipynb)
- [Classification with MultiMIL](https://multimil.readthedocs.io/en/latest/notebooks/mil_classification.html) [![Open In Colab][badge-colab]](https://colab.research.google.com/github/theislab/multimil/blob/main/docs/notebooks/mil_classification.ipynb)
- [Regression with MultiMIL](https://multimil.readthedocs.io/en/latest/notebooks/mil_regression.html) [![Open In Colab][badge-colab]](https://colab.research.google.com/github/theislab/multimil/blob/main/docs/notebooks/mil_regression.ipynb)

Please also check out our [sample prediction pipeline](https://github.com/theislab/sample-prediction-pipeline), which contains MultiMIL and several other baselines.

## Installation

You need to have Python 3.10 or newer installed on your system. We recommend installing [Mambaforge](https://github.com/conda-forge/miniforge#mambaforge).
You need to have Python 3.12 or newer installed on your system. We recommend using [uv](https://docs.astral.sh/uv/) for environment management.

To create and activate a new environment:
Install the latest release of `multimil` from [PyPI][link-pypi]:

```bash
mamba create --name multimil python=3.10
mamba activate multimil
uv pip install multimil
```

Next, there are several alternative options to install multimil:

1. Install the latest release of `multimil` from [PyPI][link-pypi]:
Or install the latest development version:

```bash
pip install multimil
uv pip install git+https://github.com/theislab/multimil.git@main
```

2. Or install the latest development version:
Alternatively, with plain pip:

```bash
pip install git+https://github.com/theislab/multimil.git@main
pip install multimil
```

## Release notes
Expand Down
28 changes: 28 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,31 @@

module.MILClassifierTorch
```

## Neural network components

```{eval-rst}
.. module:: multimil.nn
.. currentmodule:: multimil

.. autosummary::
:toctree: generated

nn.MLP
nn.Aggregator
```

## Utilities

```{eval-rst}
.. module:: multimil.utils
.. currentmodule:: multimil

.. autosummary::
:toctree: generated

utils.get_sample_representations
utils.score_top_cells
utils.setup_ordinal_regression
utils.plt_plot_losses
```
32 changes: 20 additions & 12 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ to the [scanpy developer guide][].
## Installing dev dependencies

In addition to the packages needed to _use_ this package, you need additional python packages to _run tests_ and _build
the documentation_. It's easy to install them using `pip`:
the documentation_. We use [uv](https://docs.astral.sh/uv/) for dependency management:

```bash
cd multimil
uv sync --extra dev --extra test --extra doc
```

This creates a `.venv/` and installs all dependencies from `uv.lock`. Prefix commands with `uv run` (e.g. `uv run pytest`) to use the managed environment.

Alternatively, with plain pip:

```bash
pip install -e ".[dev,test,doc]"
```

Expand Down Expand Up @@ -51,7 +59,7 @@ and [prettier][prettier-editors].
## Writing tests

```{note}
Remember to first install the package with `pip install -e '.[dev,test]'`
Remember to first install the package with `uv sync --extra dev --extra test` (or `pip install -e '.[dev,test]'`).
```

This package uses the [pytest][] for automated testing. Please [write tests][scanpy-test-docs] for every function added
Expand All @@ -61,7 +69,7 @@ Most IDEs integrate with pytest and provide a GUI to run tests. Alternatively, y
command line by executing

```bash
pytest
uv run pytest
```

in the root of the repository.
Expand Down Expand Up @@ -99,11 +107,11 @@ Specify `vX.X.X` as a tag name and create a release. For more information, see [

Please write documentation for new or changed features and use-cases. This project uses [sphinx][] with the following features:

- the [myst][] extension allows to write documentation in markdown/Markedly Structured Text
- [Numpy-style docstrings][numpydoc] (through the [napoloen][numpydoc-napoleon] extension).
- Jupyter notebooks as tutorials through [myst-nb][] (See [Tutorials with myst-nb](#tutorials-with-myst-nb-and-jupyter-notebooks))
- [Sphinx autodoc typehints][], to automatically reference annotated input and output types
- Citations (like {cite:p}`Virshup_2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/)
- the [myst][] extension allows to write documentation in markdown/Markedly Structured Text
- [Numpy-style docstrings][numpydoc] (through the [napoloen][numpydoc-napoleon] extension).
- Jupyter notebooks as tutorials through [myst-nb][] (See [Tutorials with myst-nb](#tutorials-with-myst-nb-and-jupyter-notebooks))
- [Sphinx autodoc typehints][], to automatically reference annotated input and output types
- Citations (like {cite:p}`Virshup_2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/)

See the [scanpy developer docs](https://scanpy.readthedocs.io/en/latest/dev/documentation.html) for more information
on how to write documentation.
Expand All @@ -120,10 +128,10 @@ repository.

#### Hints

- If you refer to objects from other packages, please add an entry to `intersphinx_mapping` in `docs/conf.py`. Only
if you do so can sphinx automatically create a link to the external documentation.
- If building the documentation fails because of a missing link that is outside your control, you can add an entry to
the `nitpick_ignore` list in `docs/conf.py`
- If you refer to objects from other packages, please add an entry to `intersphinx_mapping` in `docs/conf.py`. Only
if you do so can sphinx automatically create a link to the external documentation.
- If building the documentation fails because of a missing link that is outside your control, you can add an entry to
the `nitpick_ignore` list in `docs/conf.py`

#### Building the docs locally

Expand Down
Loading
Loading