CellTypist MCP服务器
MCP(模型上下文协议)服务器,用于使用CellTypist和自然语言在scRNA-seq分析中进行自动细胞类型注释!
🎯 它能做什么?
- 自动单元格类型注释 使用预先训练的CellTypist模型
- 列出可用型号 带有描述和元数据
- 下载型号 来自CellTypist存储库
- 列车定制模型 在您自己的注释数据上
- 提取标记基因 针对特定细胞类型
- 多数票表决 基于局部子聚类的稳健预测
- 可视化 使用点图将预测与参考标签进行比较
🧬 关于CellTypist
CellTypist是一种基于逻辑回归分类器的scRNA-seq数据集的自动细胞类型注释工具。它提供:
- 使用正则化线性模型进行快速准确的预测
- 各种组织和细胞类型的预训练模型
- 多数投票方法来完善预测
- 自定义模型训练功能
📦 安装
来源
git clone
cd celltypist-mcp
pip install -e .🚀 快速开始
使用stdio传输在本地运行
celltypist-mcp run使用预加载的数据集运行
celltypist-mcp run --data /path/to/your/data.h5ad使用SSE传输运行(用于远程访问)
celltypist-mcp run --transport sse --port 8000 --host 0.0.0.0🔧 配置
适用于AI客户端(例如,Claude Desktop、Cherry Studio)
添加到MCP客户端配置中:
{
"mcpServers": {
"celltypist": {
"command": "celltypist-mcp",
"args": ["run"]
}
}
}带有预加载数据
{
"mcpServers": {
"celltypist": {
"command": "celltypist-mcp",
"args": ["run", "--data", "/path/to/your/data.h5ad"]
}
}
}远程SSE连接
首先,在您的计算机上运行服务器:
celltypist-mcp run --transport sse --port 8000然后配置您的MCP客户端:
http://localhost:8000/sse🛠️ 可用工具
1. celltypist_list_models
列出所有可用的CellTypist型号及其说明。
示例用法:
"Show me available CellTypist models"
"List all immune cell type models"2. celltypist_annotate
在scRNA-seq数据中注释细胞类型。
参数:
model:型号名称(例如,“Immune_All_High.pkl”)majority_voting:启用多数投票(默认值:False)over_clustering:adata.obs中用于集群的列(可选)mode:“最佳匹配”或“prob匹配”(默认值:“最佳匹配对”)p_thres:多标签的概率阈值(默认值:0.5)
示例用法:
"Annotate my cells using the Immune_All_High model"
"Run CellTypist with majority voting on my data"
"Use the Immune_All_Low model with leiden clustering for majority voting"3. celltypist_download_model
下载CellTypist模型。
参数:
model:型号名称或名称列表(无下载全部)force_update:强制更新到最新版本(默认值:False)
示例用法:
"Download the Immune_All_High model"
"Download all available CellTypist models"
"Update the Immune_All_Low model to the latest version"4. celltypist_get_model_info
获取特定型号的详细信息。
参数:
model:型号名称
示例用法:
"What cell types are in the Immune_All_High model?"
"Show me information about the Immune_All_Low model"
"How many features does the Immune_All_High model use?"5. celltypist_extract_markers
提取特定细胞类型的顶部标记基因。
参数:
model:型号名称cell_type:单元格类型名称top_n:顶部标记的数量(默认值:10)
示例用法:
"What are the top marker genes for T cells in Immune_All_High?"
"Show me 20 marker genes for macrophages"
"Extract markers for B cells from the Immune_All_Low model"6. celltypist_train
训练一个定制的CellTypist模型。
参数:
labels:adata.obs中带有单元格类型标签的列model_name:保存模型的文件名use_SGD:对大型数据集使用SGD学习(默认值:False)C:L2正则化强度(默认值:1.0)max_iter:最大迭代次数(可选)feature_selection:启用功能选择(默认值:False)top_genes:要选择的顶级基因数量(默认值:300)
示例用法:
"Train a CellTypist model using the 'cell_type' column and save it as 'my_model.pkl'"
"Create a custom model with SGD learning and feature selection"7. celltypist_dotplot
生成一个将预测与参考标签进行比较的点图。
参数:
use_as_reference:adata.obs中带有参考标签的列use_as_prediction:“predicted_labels”或“majority_voting”(默认值:“majority-voting”)save:保存图形的文件名(可选)
示例用法:
"Create a dotplot comparing CellTypist predictions with my cell_type labels"
"Visualize the majority voting results against leiden clusters"
"Generate a dotplot and save it as 'results.png'"📊 典型工作流程
- 列出可用型号
"What CellTypist models are available?"- 下载模型 (如果尚未下载)
"Download the Immune_All_High model"- 为您的单元格添加注释
"Annotate my cells using Immune_All_High with majority voting"- 可视化结果
"Create a dotplot comparing predictions with my manual annotations"- 提取标记 (可选)
"What are the marker genes for T cells in this model?"🧪 对话示例
示例1:快速注释
User: "I have scRNA-seq data loaded. Can you annotate the cell types?"
Assistant: [Lists available models]
User: "Use the Immune_All_High model"
Assistant: [Runs celltypist_annotate and shows results]示例2:自定义模型训练
User: "I want to train my own CellTypist model"
Assistant: "What column contains your cell type labels?"
User: "The 'cell_type' column"
Assistant: [Runs celltypist_train and saves the model]🔬 数据需求
- 输入数据应采用AnnData格式(
.h5ad) - 表达式矩阵应为 log1p标准化为每个细胞10000个计数
- 用于培训:单元格类型标签应位于
adata.obs
📝 备注
- 第一次使用模型时,它将自动下载
- 多数投票需要现有的集群或自动集群
- 训练好的模型保存在本地,可以重复使用
- 所有结果都保存到
adata.obs前缀为的列celltypist_
