Skip to content

Commit 0d5df41

Browse files
committed
Add AnnData output support for multiplex-quant
1 parent a50c9ef commit 0d5df41

7 files changed

Lines changed: 219 additions & 34 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ seq_geom_parser = "1.1"
4949
# mapping is deprecated, and piscem handles geometry strings directly.
5050
# All geometry validation uses seq_geom_parser 1.0 (above).
5151
roers = { version = "0.4.0" }
52-
af-anndata = { version = "0.3.3" }
52+
af-anndata = { version = "0.4.0" }
5353

5454
anyhow = "^1.0"
5555
clap = { version = "4.5.37", features = [

docs/source/flex-quant-command.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ The command needs:
2727

2828
If the chemistry registry contains the needed metadata, ``simpleaf`` can automatically download and cache the probe set, the cell barcode whitelist, and the sample barcode list. If you already have local resources, you can override these defaults with ``--index``, ``--probe-set``, or ``--sample-bc-list``.
2929

30+
The default output is the standard Matrix Market directory under ``af_quant/alevin``. If you pass ``--anndata-out``, ``simpleaf`` will additionally write an AnnData ``.h5ad`` file at ``af_quant/alevin/quants.h5ad``.
31+
32+
For multiplex output, the resulting AnnData object is intended to preserve the extra sample-level structure of the experiment:
33+
34+
- ``obs_names`` are sample-qualified cell identifiers
35+
- ``obs["cell_barcode"]`` stores the corrected cell barcode without the sample prefix
36+
- ``obs["sample_name"]`` stores the sample / probe-barcode assignment
37+
- ``var["gene_id"]`` remains the matrix feature identifier
38+
- ``var["gene_symbol"]`` is added when a ``gene_id_to_name.tsv`` mapping is available from the probe set or index
39+
- ``uns`` stores the standard ``gpl_info``, ``collate_info``, ``quant_info``, and ``simpleaf_map_info`` records, and for multiplex runs it also stores ``sample_info`` plus ``simpleaf_multiplex_quant_info``
40+
3041
The relevant options (which you can obtain by running ``simpleaf multiplex-quant -h``) are below:
3142

3243
.. code-block:: console
@@ -70,6 +81,9 @@ The relevant options (which you can obtain by running ``simpleaf multiplex-quant
7081
Permit List Options:
7182
--min-reads <MIN_READS> Minimum read count threshold for unfiltered permit list [default: 10]
7283
84+
Output Options:
85+
--anndata-out Generate an anndata (h5ad format) count matrix from the standard (matrix-market format) output
86+
7387
Resource resolution
7488
-------------------
7589

@@ -139,6 +153,18 @@ Use a pre-built probe index:
139153
--reads2 sample_R2.fastq.gz \
140154
--output flex_out
141155
156+
Request AnnData output in addition to the Matrix Market output:
157+
158+
.. code-block:: console
159+
160+
$ simpleaf multiplex-quant \
161+
--chemistry 10x-flexv1-gex-3p \
162+
--organism human \
163+
--reads1 sample_R1.fastq.gz \
164+
--reads2 sample_R2.fastq.gz \
165+
--output flex_out \
166+
--anndata-out
167+
142168
Request USA-mode probe quantification:
143169

144170
.. code-block:: console
@@ -159,6 +185,10 @@ The command creates the requested output directory and writes:
159185

160186
- ``af_map/``: the ``piscem`` mapping output
161187
- ``af_quant/``: the ``alevin-fry`` permit-list, collate, and quantification output
188+
- ``af_quant/simpleaf_map_info.json``: parsed mapping metadata copied into the quantification directory for downstream consumers such as AnnData conversion
189+
- ``af_quant/simpleaf_multiplex_quant_info.json``: multiplex pipeline metadata copied into the quantification directory so it can be embedded into AnnData ``uns``
190+
- ``af_quant/gene_id_to_name.tsv``: optional gene ID to gene symbol/name mapping copied when available from the probe set or index
191+
- ``af_quant/alevin/quants.h5ad``: optional AnnData output written when ``--anndata-out`` is requested
162192
- ``simpleaf_multiplex_quant_info.json``: a metadata record describing the resolved inputs, executed commands, and step timings
163193

164194
Notes

src/simpleaf_commands.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,10 @@ pub struct MultiplexQuantOpts {
625625
/// Minimum read count threshold for unfiltered permit list
626626
#[arg(long, default_value_t = 10, help_heading = "Permit List Options")]
627627
pub min_reads: usize,
628+
629+
/// Generate an anndata (h5ad format) count matrix from the standard (matrix-market format) output
630+
#[arg(long, help_heading = "Output Options")]
631+
pub anndata_out: bool,
628632
}
629633

630634
#[derive(Debug, Subcommand)]

0 commit comments

Comments
 (0)