Metadata-Version: 2.4
Name: aeacus
Version: 0.6.0
Summary: mixture of experts single cell malignancy classifier
License: BSD 3-Clause License
        
        Copyright (c) 2026, Prashant Pandey
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: anndata
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: scanpy
Requires-Dist: scipy
Requires-Dist: torch
Dynamic: license-file

```bash
pip install aeacus
```

from source:

```bash
git clone https://github.com/pandey-ps/aeacus.git
cd aeacus
pip install -e .
```

#### Usage

```python
from aeacus import Profiler

result = Profiler(test_input="query.h5ad").load().profile()
result.obs["malignancy_call"].value_counts()
```

#### Input

| Format | Notes |
|---|---|
| `.h5ad` | genes in `var_names`, cells in `obs_names` |
| `.txt` / `.tsv` | rows = genes, columns = cells |
| `.csv` | rows = genes, columns = cells |
| `AnnData` object | passed directly |

#### Parameters

| Parameter | Default | Description |
|---|---|---|
| `test_input` | required | path to data or `AnnData` object |
| `pretrain_dir` | auto | path to folder with `moe.pt`, `geneorder.tsv`, `train_mean.npy`, `train_std.npy`, `config.json`.|
| `norm_type` | `False` | normalization to apply before inference (see below) |
| `use_raw` | `False` | if `True`, reads from `adata.raw.X` instead of `adata.X` |
| `batch_size` | `8192` | cells per batch, lower if out of memory |
| `device` | auto | `"cuda"` or `"cpu"` |

#### `norm_type` 

model was trained on **CPM + log1p** normalized data, choose `norm_type` based on your input:

| Input | `norm_type` |
|---|---|
| raw `UMI` counts (10x, etc.) | `"cpm_log1p"` (or `True`) |
| `CPM + log1p` normalized | `False` (default) or `"already_normalized"` |
| `TPM` data (smart-seq, etc.) | `"tpm_log1p"` |

**Examples:**

```python
# raw counts - normalize 
Profiler(test_input="raw_counts.h5ad", norm_type="cpm_log1p")

# normalized - skip
Profiler(test_input="normalized.h5ad", norm_type=False)

# TPM - log1p
Profiler(test_input="tpm_data.h5ad", norm_type="tpm_log1p")
```


#### `use_raw`

`use_raw` chooses which data slot to read from:

| Input | `use_raw` | `norm_type` |
|---|---|---|
| raw counts in `.X`, no `.raw` | `False` | `"cpm_log1p"` |
| raw counts in `.raw`, normalized in `.X` | `True` | `"cpm_log1p"` |
| normalized in `.X` | `False` | `False` |

**Example - AnnData with raw counts stored in `.raw`:**

```python
Profiler(
    test_input="adata.h5ad",
    use_raw=True,          # read from adata.raw.X
    norm_type="cpm_log1p", # then normalize
)
```

#### Inference

```python
result = Profiler(test_input="data.h5ad", norm_type="cpm_log1p").load().profile()
```

#### Output

all predictions are added to `result.obs`:

| Column | Description |
|---|---|
| `malignancy_call` | `"Malignant"` or `"Normal"` |
| `malignancy_score` | probability per cell |
| `normal_expert_weight` | weight assigned to the normal expert |
| `malignant_expert_weight` | weight assigned to the malignant expert |gating |

```python
result.obs[["malignancy_call", "malignancy_score"]].head()
```

#### Note

- **missing genes** are filled with zeros after aligning to `geneorder.tsv`; warning showed if >20% of model genes are missing.

