lamindb
它能做什么
LaminDB 可以帮你整理和追踪生物数据及其分析过程。你可以用它登记数据集、为元数据添加注释,并确保结果可以复现。
适用场景
- ✓登记生物数据集。
- ✓为 DataFrame 或 AnnData 的元数据添加注释。
- ✓追踪科研脚本或工作流程。
技能链接
https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/lamindb/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“帮我整理基因实验数据,并记录我做过的分析。”
每周 5 个新技能,1 分钟读完。
工作原理
你需要先定义数据的结构(schema)以及哪些信息是重要的(features)。之后,你就可以登记文件和脚本,确保一切都能被找到并复现。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
LaminDB
When to use
Use for registering biological datasets, curating DataFrame/AnnData metadata, querying annotated artifacts, and tracking scientific scripts or workflows. LaminDB stores metadata in SQLite/PostgreSQL and files in configured storage; registration alone does not establish scientific validity or FAIR compliance.
This skill targets LaminDB 2.10.0 and Bionty 2.5.0. The local examples were
executed on Python 3.12, pandas 3.0.6, and AnnData 0.13.2. The LaminDB release
caps AnnData at 0.13.2; preserve its dependency constraints. Install IPython for
registry synonym helpers (add_synonym() imports it in this release).
Workflow
- Confirm the intended instance, storage, and write scope with
lamin info. Use a new local development directory for experiments. See setup and deployment. - Define typed
Featurerecords and aSchemafor the biological data. Use registry-backed categorical dtypes for controlled vocabularies;dtype=stronly checks strings. See annotation and validation. - Review the ontology source/version and organism. Standardize only reviewed synonyms and preserve unresolved annotations. See Bionty ontologies.
- In a script or notebook, start
ln.track(), load registered inputs, validate, and save outputs.curator.validate()returnsNoneon success and raisesln.errors.ValidationErroron failure. Repair, then validate again. - Save through the curator or a schema-aware artifact constructor. Check the
stored schema and round-trip content; finish a successful run with
ln.finish(). - Query metadata before loading content. Record artifact UIDs and schema/source provenance for reproducibility; a key can resolve to a newer version later. See queries and streaming.
Local worked example
Run in a dedicated environment and an empty project directory:
uv venv --python 3.12
uv pip install 'lamindb==2.10.0' 'bionty==2.5.0' 'ipython==9.17.1'
source .venv/bin/activate
lamin init --storage ./storage --name biology-demo --modules bionty
Save the following as curate_qc.py, then run python curate_qc.py:
import pandas as pd
import lamindb as ln
ln.track(params={"analysis": "QC metadata curation"})
count = ln.Feature(name="gene_count", dtype=int).save()
condition = ln.Feature(name="condition", dtype=str).save()
schema = ln.Schema(
name="qc_metadata",
features=[count, condition],
maximal_set=True, # reject extra columns
).save()
df = pd.DataFrame({
"gene_count": [120, 130],
"condition": ["control", "treated"],
})
curator = ln.curators.DataFrameCurator(df, schema)
curator.validate() # raises on invalid data; do not use as an if condition
artifact = curator.save_artifact(key="experiments/qc.parquet")
assert artifact.schema == schema
pd.testing.assert_frame_equal(artifact.load(), df)
ln.finish()
This validates table structure/types, not whether the counts satisfy assay QC. Add assay-specific checks (units, allowed ranges, missingness, duplicate sample IDs, batch balance) before publication or downstream analysis.
Core objects and contracts
| Object | Purpose and important constraint |
|---|---|
Artifact |
A file/folder or serialized dataset; cache() gets a local path, load() materializes content, open() returns a format-specific accessor. |
Feature |
A typed metadata field; save its definition before artifact.features.set_values(...). |
Schema |
Validation rules and feature membership; maximal_set=True rejects extras. flexible=False alone does not. |
Record, ULabel |
Experimental entities and simple labels. A custom term is not an ontology assertion. |
Run, Transform |
An execution and its code definition. Inputs are run.input_artifacts; outputs are run.output_artifacts. |
Collection |
A versioned group of artifacts; iterate collection.artifacts.all(). |
Project, Branch, Space |
Grouping, change organization, and access scope; branches do not replace permissions. |
Use @ln.flow() for a workflow entry point and @ln.step() within it. Lineage
captures tracked accesses, not arbitrary reads outside LaminDB. Review
core concepts for tracking, labels, and revisions.
Failure patterns to avoid
…
常见问题
什么是“artifact”(工件)?
工件是你登记的文件或文件夹,比如数据集或脚本。LaminDB 会对这些工件进行追踪。
LaminDB 如何保证可复现性?
它会记录输入数据、所用的脚本以及分析参数,形成完整的历史记录,这样你就能重新执行整个分析。
什么是“schema”和“features”?
schema 定义了数据的预期结构(列和数据类型),而 features 是这个结构中的各个字段,比如“基因计数”或“实验条件”。
详情
作者的原始描述
Manages biological datasets and models with LaminDB, including artifact registration, lineage tracking, schema validation, Bionty ontology annotation, query/search, collections, branches, storage, and workflow integrations. Use for reproducible biological data curation or a LaminDB lakehouse.
热度
- GitHub 星标
- 51k
- 排名
- #3485
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …