Alterlab lamindb

From AlterLab-IEU/AlterLab-Academic-Skills · View interactive version

Alterlab lamindb is an AI agent skill from the GitHub repository AlterLab-IEU/AlterLab-Academic-Skills. Manage, annotate, and trace biological data with LaminDB, an open-source FAIR data framework that makes datasets queryable, versioned, and reproducible. Use when registering or querying biological datasets (scRNA-seq, spatial, flow cytometry), validating and curating data against ontologies (genes,

How to use this skill

Skill file

LaminDB

Overview

LaminDB is an open-source data framework for biology designed to make data queryable, traceable, reproducible, and FAIR (Findable, Accessible, Interoperable, Reusable). It provides a unified platform that combines lakehouse architecture, lineage tracking, feature stores, biological ontologies, LIMS (Laboratory Information Management System), and ELN (Electronic Lab Notebook) capabilities through a single Python API.

Core Value Proposition:

When to Use This Skill

Use this skill when:

Does NOT Trigger

| Scenario | Use Instead |

|----------|-------------|

| Analysing an scRNA-seq AnnData (QC, clustering, DE) rather than registering it | alterlab-scanpy |

| Wrangling the AnnData object itself (slicing, concat, h5ad/zarr I/O) | alterlab-anndata |

| Pulling reference cells from the public CELLxGENE Census | alterlab-cellxgene |

| A lab ELN/LIMS (Benchling) as the system of record | alterlab-benchling |

| Depositing a finished dataset in a public repository with a DOI | alterlab-open-science |

Hand-off rule. When the request matches a row above, open your answer by naming that skill by its exact id (for example alterlab-scanpy) and saying in one line why it fits better, then stop applying this skill's procedure. Name it even when you also need to ask for missing input. If only part of the request is out of scope, name the skill for that part and do only the in-scope part. A brief general pointer is fine; the named skill does the work.

Core Capabilities

LaminDB provides six interconnected capability areas, each documented in detail in the references folder.

1. Core Concepts and Data Lineage

Core entities:

Key workflows:

Reference: references/core-concepts.md - Read this for detailed information on artifacts, records, runs, transforms, features, versioning, and lineage tracking.

2. Data Management and Querying

API names that changed. Query results are materialized with .to_dataframe()

(the old .df()), artifacts are annotated with features.set_values({...}) /

features.remove_values([...]) (the old add_values), and a remote instance is opened

as a database object — db = ln.DB("account/instance"), then db.Artifact.filter(...)

— rather than by importing its registries. ln.track() / ln.finish() and the

ln.Artifact.from_dataframe / from_anndata constructors are unchanged.

Query capabilities:

Key workflows:

Reference: references/data-management.md - Read this for comprehensive query patterns, filtering examples, streaming strategies, and data organization best practices.

3. Annotation and Validation

Curation process:

  1. Validation: Confirm datasets match desired schemas
  2. Standardization: Fix typos, map synonyms to canonical terms
  3. Annotation: Link datasets to metadata entities for queryability

Schema types:

Supported data types:

Key workflows:

Reference: references/annotation-validation.md - Read this for detailed curation workflows, schema design patterns, handling validation errors, and best practices.

4. Biological Ontologies

Available ontologies (via Bionty):

Key workflows:

Reference: references/ontologies.md - Read this for comprehensive ontology operations, standardization strategies, hierarchy navigation, and annotation workflows.

5. Integrations

Workflow managers:

MLOps platforms:

Storage systems:

Array stores:

Visualization:

Version control:

Reference: references/integrations.md - Read this for integration patterns, code examples, and troubleshooting for third-party systems.

6. Setup and Deployment

Installation:

is gone), e.g. uv pip install 'lamindb[gcp,fcs]'

lamin init --storage ./mydata --modules bionty

Instance types:

Storage options:

Configuration:

Deployment patterns:

Reference: references/setup-deployment.md - Read this for detailed installation, configuration, storage setup, database management, security best practices, and troubleshooting.

Common Use Case Workflows

Use Case 1: Single-Cell RNA-seq Analysis with Ontology Validation

import lamindb as ln
import bionty as bt
import anndata as ad

# Start tracking
ln.track(params={"analysis": "scRNA-seq QC and annotation"})

# Import cell type ontology
bt.CellType.import_source()

# Load data
adata = ad.read_h5ad("raw_counts.h5ad")

# Validate and standardize cell types
adata.obs["cell_type"] = bt.CellType.standardize(adata.obs["cell_type"])

# Curate with schema
curator = ln.curators.AnnDataCurator(adata, schema)
curator.validate()
artifact = curator.save_artifact(key="scrna/validated.h5ad")

# Link ontology annotations (validated CellType records)
cell_types = bt.CellType.from_values(adata.obs.cell_type)
artifact.cell_types.add(cell_types)  # typed accessor: <registry-name-plural>.add(...)

ln.finish()

Use Case 2: Building a Queryable Data Lakehouse

import lamindb as ln

# Register multiple experiments
for i, file in enumerate(data_files):
    artifact = ln.Artifact.from_anndata(
        ad.read_h5ad(file),
        key=f"scrna/batch_{i}.h5ad",
        description=f"scRNA-seq batch {i}"
    ).save()

    # Annotate with features. Current API is set_values / remove_values
    # (add_values was renamed).
    artifact.features.set_values({
        "batch": i,
        "tissue": tissues[i],
        "condition": conditions[i]
    })

# Query across all experiments
immune_datasets = ln.Artifact.filter(
    key__startswith="scrna/",
    tissue="PBMC",
    condition="treated"
).to_dataframe()

# Load specific datasets
for artifact in immune_datasets:
    adata = artifact.load()
    # Analyze

Use Case 3: ML Pipeline with W&B Integration

import lamindb as ln
import wandb

# Initialize both systems
wandb.init(project="drug-response", name="exp-42")
ln.track(params={"model": "random_forest", "n_estimators": 100})

# Load training data from LaminDB
train_artifact = ln.Artifact.get(key="datasets/train.parquet")
train_data = train_artifact.load()

# Train model
model = train_model(train_data)

# Log to W&B
wandb.log({"accuracy": 0.95})

# Save model in LaminDB with W&B linkage
import joblib
joblib.dump(model, "model.pkl")
model_artifact = ln.Artifact("model.pkl", key="models/exp-42.pkl").save()
model_artifact.features.set_values({"wandb_run_id": wandb.run.id})

ln.finish()
wandb.finish()

Use Case 4: Nextflow Pipeline Integration

# In Nextflow process script
import lamindb as ln

ln.track()

# Load input artifact
input_artifact = ln.Artifact.get(key="raw/batch_${batch_id}.fastq.gz")
input_path = input_artifact.cache()

# Process (alignment, quantification, etc.)
# ... Nextflow process logic ...

# Save output
output_artifact = ln.Artifact(
    "counts.csv",
    key="processed/batch_${batch_id}_counts.csv"
).save()

ln.finish()

Getting Started Checklist

To start using LaminDB effectively:

  1. Installation & Setup (references/setup-deployment.md)

(add --db postgresql://... for a Postgres-backed instance)

  1. Learn Core Concepts (references/core-concepts.md)
  1. Master Querying (references/data-management.md)
  1. Set Up Validation (references/annotation-validation.md)
  1. Integrate Ontologies (references/ontologies.md)
  1. Connect Tools (references/integrations.md)

Key Principles

Follow these principles when working with LaminDB:

  1. Track everything: Use ln.track() at the start of every analysis for automatic lineage capture
  1. Validate early: Define schemas and validate data before extensive analysis
  1. Use ontologies: Leverage public biological ontologies for standardized annotations
  1. Organize with keys: Structure artifact keys hierarchically (e.g., project/experiment/batch/file.h5ad)
  1. Query metadata first: Filter and search before loading large files
  1. Version, don't duplicate: Use built-in versioning instead of creating new keys for modifications
  1. Annotate with features: Define typed features for queryable metadata
  1. Document thoroughly: Add descriptions to artifacts, schemas, and transforms
  1. Leverage lineage: Use view_lineage() to understand data provenance
  1. Start local, scale cloud: Develop locally with SQLite, deploy to cloud with PostgreSQL

Reference Files

This skill includes comprehensive reference documentation organized by capability:

Read the relevant reference file(s) based on the specific LaminDB capability needed for the task at hand.

Additional Resources

Part of the AlterLab Academic Skills suite.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.