Metadata-Version: 2.4
Name: agentype
Version: 1.1.0
Summary: 统一的细胞类型分析工具包，集成四个专业Agent提供完整的细胞类型注释流程
Author-email: CellType Agent Team <contact@agentype.com>
License: MIT License
        
        Copyright (c) 2025 CellType Agent Team
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/agentype/celltype-agent
Project-URL: Bug Tracker, https://github.com/agentype/celltype-agent/issues
Project-URL: Documentation, https://github.com/agentype/celltype-agent/wiki
Project-URL: Source, https://github.com/agentype/celltype-agent
Project-URL: Changelog, https://github.com/agentype/celltype-agent/blob/main/CHANGELOG.md
Keywords: single-cell,RNA-seq,cell-type,annotation,SingleR,scType,CellTypist,bioinformatics,genomics,MCP
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Classifier: Natural Language :: Chinese (Simplified)
Classifier: Natural Language :: English
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mcp>=1.0.0
Requires-Dist: fastmcp>=0.3.0
Requires-Dist: fastapi>=0.104.0
Requires-Dist: uvicorn[standard]>=0.24.0
Requires-Dist: pydantic>=2.5.0
Requires-Dist: asyncio-mqtt>=0.16.0
Requires-Dist: aiofiles>=23.2.1
Requires-Dist: websockets>=12.0
Requires-Dist: numpy<2.0,>=1.24.0
Requires-Dist: pandas<2.2.0,>=2.1.0
Requires-Dist: scipy>=1.11.0
Requires-Dist: scanpy>=1.9.0
Requires-Dist: anndata>=0.10.0
Requires-Dist: gseapy>=1.1.0
Requires-Dist: h5py>=3.10.0
Requires-Dist: tables>=3.9.0
Requires-Dist: openpyxl>=3.1.0
Requires-Dist: requests>=2.31.0
Requires-Dist: httpx>=0.25.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: jsonschema>=4.20.0
Requires-Dist: loguru>=0.7.0
Requires-Dist: click>=8.1.0
Requires-Dist: rich>=13.7.0
Requires-Dist: tqdm>=4.66.0
Requires-Dist: pathlib2>=2.3.7
Requires-Dist: filetype>=1.2.0
Requires-Dist: typing-extensions>=4.8.0
Requires-Dist: pydantic-settings>=2.1.0
Requires-Dist: babel>=2.13.0
Requires-Dist: python-i18n>=0.3.9
Requires-Dist: psutil>=5.9.0
Requires-Dist: python-dateutil>=2.8.0
Requires-Dist: pytz>=2023.3
Provides-Extra: annotation
Requires-Dist: celltypist>=1.6.0; extra == "annotation"
Requires-Dist: rpy2>=3.5.0; extra == "annotation"
Requires-Dist: bioservices>=1.11.0; extra == "annotation"
Requires-Dist: biopython>=1.81; extra == "annotation"
Provides-Extra: ml
Requires-Dist: scikit-learn>=1.3.0; extra == "ml"
Requires-Dist: torch>=2.0.0; extra == "ml"
Requires-Dist: numba>=0.58.0; extra == "ml"
Provides-Extra: viz
Requires-Dist: matplotlib>=3.8.0; extra == "viz"
Requires-Dist: seaborn>=0.12.0; extra == "viz"
Requires-Dist: plotly>=5.17.0; extra == "viz"
Provides-Extra: performance
Requires-Dist: dask[complete]>=2023.12.0; extra == "performance"
Requires-Dist: joblib>=1.3.0; extra == "performance"
Requires-Dist: diskcache>=5.6.0; extra == "performance"
Provides-Extra: deploy
Requires-Dist: gunicorn>=21.2.0; extra == "deploy"
Requires-Dist: docker>=6.1.0; extra == "deploy"
Provides-Extra: dev
Requires-Dist: pytest>=7.4.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
Requires-Dist: black>=23.11.0; extra == "dev"
Requires-Dist: flake8>=6.1.0; extra == "dev"
Requires-Dist: mypy>=1.7.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Provides-Extra: all
Requires-Dist: agentype[annotation,deploy,ml,performance,viz]; extra == "all"
Dynamic: license-file

# AgentType

> LLM-powered automatic cell type annotation toolkit for single-cell RNA sequencing

[![PyPI version](https://badge.fury.io/py/agentype.svg)](https://badge.fury.io/py/agentype)
[![Python Version](https://img.shields.io/pypi/pyversions/agentype.svg)](https://pypi.org/project/agentype/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

[中文文档](README_zh.md)

## Installation

```bash
pip install agentype
```

Optional dependencies:

```bash
# CellTypist annotation algorithm
pip install agentype[annotation]

# Full installation
pip install agentype[annotation,ml,viz]
```

## Configuration

Create `agentype_config.json`:

```json
{
  "llm": {
    "api_key": "your-api-key",
    "api_base": "https://api.openai.com/v1",
    "model": "gpt-4o"
  },
  "project": {
    "language": "en",
    "enable_streaming": true,
    "enable_logging": true
  }
}
```

Or configure via environment variables:

```bash
export OPENAI_API_KEY="your-api-key"
export OPENAI_API_BASE="https://api.openai.com/v1"
export OPENAI_MODEL="gpt-4o"
```

## Quick Start

### Full Workflow (Recommended)

```python
from agentype.api.main_workflow import process_workflow_sync

result = process_workflow_sync(
    input_data="path/to/data.rds",      # supports RDS, H5AD, H5, CSV
    tissue_type="PBMC",                  # tissue type
    cluster_column="seurat_clusters",    # cluster label column
    api_key="your-api-key",
    api_base="https://api.openai.com/v1",
    model="gpt-4o",
    output_dir="./outputs",
    language="en",                       # 'en' or 'zh'
    enable_streaming=True,
    enable_llm_logging=True,
)

if result["success"]:
    print(f"Session ID:       {result['session_id']}")
    print(f"Iterations:       {result['total_iterations']}")
    print(f"Output files:     {result['output_file_paths']}")
else:
    print(f"Error:            {result['error']}")
```

### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `input_data` | str | Path to input file |
| `tissue_type` | str | Tissue type, e.g. `"PBMC"`, `"Liver"` |
| `cluster_column` | str | Column name of cluster labels in the data |
| `species` | str \| None | Species; auto-detected when `None` |
| `api_key` | str | LLM API key |
| `api_base` | str | LLM API base URL |
| `model` | str | Model name |
| `output_dir` | str | Directory for output files |
| `language` | str | Prompt language: `"en"` or `"zh"` |
| `enable_streaming` | bool | Enable streaming output |
| `enable_thinking` | bool | Enable thinking mode |
| `enable_llm_logging` | bool | Enable LLM call logging |

### Return Value

| Field | Type | Description |
| --- | --- | --- |
| `success` | bool | Whether the run succeeded |
| `session_id` | str | Session ID for this run |
| `total_iterations` | int | Number of agent iterations |
| `output_file_paths` | dict | Output paths, including `rds_file` |
| `result_file` | str | Path to the summary result file |
| `token_stats` | dict | Token usage statistics |
| `error` | str | Error message on failure |

## Using Individual Agents

**AppAgent — cell type annotation:**

```python
from agentype.appagent.tools.celltypist_simple import celltypist_annotation

result = celltypist_annotation(
    adata_path="data.h5ad",
    model_name="Immune_All_Low.pkl",
    species="human"
)
```

**SubAgent — cell marker gene query:**

```python
from agentype.subagent.tools.fetchers.cellmarker_fetcher import search_cell_markers

markers = search_cell_markers(
    gene_symbols=["CD4", "CD8A", "CD3E"],
    tissue_type="Blood"
)
```

**DataAgent — data format conversion:**

```python
from agentype.dataagent.tools.data_converters import convert_rds_to_h5ad

h5ad_path = convert_rds_to_h5ad(
    rds_path="data.rds",
    output_path="output.h5ad"
)
```

## CLI Tools

```bash
celltype-server          # Start all MCP servers
celltype-manage status   # Show project status
celltype-manage config   # Show current configuration
```

## License

MIT License
