Skip to main content

Malva Client

PyPI Documentation GitHub

Python client for the Malva genomic search platform. Search genes, sequences, and natural language queries across >7,000 single-cell and spatial transcriptomics samples.

For full documentation, visit malva-client.readthedocs.io.

Installation

pip install malva-client

For single-cell analysis workflows:

pip install malva-client scanpy

Authentication

Generate an API token at malva.bio (login with ORCID, then go to Profile > Generate API Token), then configure the client:

malva_client config --server https://malva.mdc-berlin.de --token YOUR_API_TOKEN

Quick Start (CLI)

malva_client search "CD3D" --output results.csv
malva_client search "ATCGATCGATCGATCGATCGATCG" --output sequence_results.json --format json
malva_client search "CD4 T cells in brain tissue" --output nl_results.csv --format csv

Quick Start (Python)

from malva_client import MalvaClient

client = MalvaClient()

# Search for a gene and inspect aggregate expression rows
results = client.search("CD3D")
print(results.df.head())

# Search a DNA sequence of at least 24 nt
sequence_results = client.search_sequences("ATCGATCGATCGATCGATCGATCG")
print(sequence_results.df.head())

Per-cell matrices

# First run a normal expression search
result = client.search("SPP1")

# Retrieve positive cells from that search job
cells = client.retrieve_cells(result, include_sample_metadata=False)
sample_id = int(cells.cells.iloc[0]["sample_id"])

# Inspect cells from one real encoded sample ID
sample_cells = client.retrieve_cells(result, sample_ids=[sample_id], include_sample_metadata=True)
cell_ids = sample_cells.get_cell_ids()
cell_df = sample_cells.to_dataframe(include_sample_metadata=True)
print(cell_ids.head())
print(cell_df.head())

# Fetch all cells for that sample once from metadata for denominator analyses
all_cells = client.get_cells_by_metadata(sample_ids=[sample_id])
print(all_cells.head())

# Full-database retrieval is also available; it queues a server-side export.
# all_cells = client.get_cells_by_metadata(include_all_database_cells=True)

Working with Results

# Enrich results with metadata
results.enrich_with_metadata()

# Filter and aggregate
filtered = results.filter_by(disease='normal', organ='brain')
by_cell_type = results.aggregate_by('cell_type', agg_func='mean')
print(filtered.df.head())
print(by_cell_type.head())

See the tutorials for coverage analysis, dataset discovery, cell-level searches, and more.

Streaming expression to AnnData

import anndata as ad
from malva_client import MalvaClient

client = MalvaClient()
sample_id = 30064771072  # replace with a sample id from client.search_samples()

# Terminal conversion: obs names are "sample:cell", var names are genes,
# X is CSR float32. Each server batch is folded into a sparse block as it
# arrives, so peak memory stays close to one copy of the expression data.
adata = client.stream_cell_expression(
    sample_ids=[sample_id],
    gene_ids=["SPP1", "CD3D"],
).to_anndata()
print(adata)

# Chunked streaming: yield a chunk once the accumulated batches hold at
# least 5,000 cells. A chunk carries every gene discovered so far, and a
# gene keeps its column once it appears.
chunks = client.stream_cell_expression(
    sample_ids=[sample_id],
).iter_anndata(chunk_obs=5_000)
for chunk in chunks:
    print(chunk.shape)  # e.g. (5000, 812), (5000, 830), (1200, 830)

# A gene first seen after a chunk was emitted is missing from that chunk.
# Combine chunks with an outer join when you need one rectangular matrix.
combined = ad.concat(
    client.stream_cell_expression(sample_ids=[sample_id]).iter_anndata(chunk_obs=5_000),
    join="outer",
    fill_value=0,
)
print(combined)

Per-cell metadata is joined into obs for every conversion method. With an explicit cell list, the first conversion fetches it once from the metadata service:

cells = [(sample_id, cell_id)]  # replace with your (sample_id, cell_id) pairs

adata = client.stream_cell_expression(
    cells=cells,
    gene_ids=["SPP1", "CD3D"],
).to_anndata()
print(adata.obs[["cell_type", "total_counts"]].head())

Pass cell_metadata=frame to supply your own table keyed by sample_id and cell_id, include_cell_metadata=False to skip both the fetch and the join, or call enrich() to fetch ahead of time.

Indexing Your Own Data

For local indexing and quantification, see Malva Tools (malva CLI).

Citation

If you use Malva in your research, please cite our paper in Nature:

@article{LenPerin2026,
  title = {Ultrafast and reference-free sequence discovery in single-cell data},
  ISSN = {1476-4687},
  url = {http://dx.doi.org/10.1038/s41586-026-10975-w},
  DOI = {10.1038/s41586-026-10975-w},
  journal = {Nature},
  publisher = {Springer Science and Business Media LLC},
  author = {León-Periñán,  Daniel and Karaiskos,  Nikos and Rajewsky,  Nikolaus},
  year = {2026},
  month = Aug 
}

License

The Clear BSD License - Copyright (c) 2025-2026 Malva

Metadata

Release files for malva-client 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for malva-client 0.9.0
File Size Uploaded Provenance Actions
malva_client-0.9.0.tar.gz 144.5 kB With provenance Details for malva_client-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for malva-client 0.9.0
File Interpreter ABI Platform Actions
malva_client-0.9.0-py3-none-any.whl Python 3 none any Details for malva_client-0.9.0-py3-none-any.whl

Total release size: 245.6 kB

Release files / malva_client-0.9.0.tar.gz

Download URL malva_client-0.9.0.tar.gz
Size 144.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6137354df1e77609460e5fefd5971f6e3f57df33325c3fa8a1e4110fbef629d0
BLAKE2b-256 checksum
How to use checksums
77d4db11ef8d705b5d06442b4076f2a3c4681e81670b62ff1700f4055398fd48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / malva_client-0.9.0-py3-none-any.whl

Download URL malva_client-0.9.0-py3-none-any.whl
Size 101.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35368c9a39486947faceabd35d23e6c476a8d5784e0c3c0b86dcd065f30a1287
BLAKE2b-256 checksum
How to use checksums
218d74a2a5337be9efbf7a059c0e9430bb3e0b972200c70ff5a8495dfc31d58a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for malva-client 0.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for malva_client-0.9.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page