Communitygithub.com

scVelo — RNA-Geschwindigkeitsanalyse

RNA-Geschwindigkeitsanalyse mit scVelo. Schätzt Zellzustandsübergänge aus ungespleißter/gespleißter mRNA-Dynamik, leitet Trajektorienrichtungen ab, berechnet latente Zeit und identifiziert Treibergene in scRNA-seq-Daten. Ergänzt Scanpy/scVI-tools für die Trajektorieninferenz.

Was ist scVelo — RNA-Geschwindigkeitsanalyse?

scVelo ist das führende Python-Paket für die RNA-Geschwindigkeitsanalyse in Einzelzell-RNA-seq-Daten. Es modelliert die Kinetik des mRNA-Spleißens, um Zellzustandsübergänge zu rekonstruieren, ohne dass Zeitreihendaten erforderlich sind. Das Paket unterstützt verschiedene Geschwindigkeitsmodelle (stochastisch, deterministisch, dynamisch), wobei das dynamische Modell die vollständige Spleißkinetik anpasst und die genauesten Ergebnisse liefert, insbesondere zur Identifizierung von Treibergenen und zur Berechnung der latenten Zeit. Es ist nahtlos in das Scanpy-Ökosystem integriert und erfordert AnnData-Objekte mit gespleißten und ungespleißten Schichten, die aus Vorverarbeitungstools wie Velocyto oder STARsolo stammen. scVelo wird häufig für Entwicklungsbiologie, Schicksalsvorhersage, Trajektorieninferenz und die Identifizierung von Zellentscheidungen verwendet.

Funktioniert mit~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/scvelo

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Was macht scVelo — RNA-Geschwindigkeitsanalyse?

Überblick

scVelo ist das führende Python-Paket für die RNA-Geschwindigkeitsanalyse in Einzelzell-RNA-seq-Daten. Es leitet Zellzustandsübergänge ab, indem es die Kinetik des mRNA-Spleißens modelliert – indem es das Verhältnis von ungespleißter (prä-mRNA) zu gespleißter (reifer mRNA) Häufigkeit verwendet, um zu bestimmen, ob ein Gen in jeder Zelle hoch- oder herunterreguliert wird. Dies ermöglicht die Rekonstruktion von Entwicklungstrajektorien und die Identifizierung von Zellschicksalentscheidungen, ohne dass Zeitreihendaten erforderlich sind.

Installation: uv pip install scvelo

Wichtige Ressourcen:

Wann man diese Fähigkeit einsetzen sollte

Verwenden Sie scVelo, wenn:

  • Trajektorieninferenz aus Schnappschussdaten: Bestimmen Sie, in welche Richtung sich Zellen differenzieren
  • Vorhersage des Zellschicksals: Identifizieren Sie Vorläuferzellen und ihre nachgeschalteten Schicksale
  • Identifizierung von Treibergenen: Finden Sie Gene, deren Dynamik die beobachteten Trajektorien am besten erklärt
  • Entwicklungsbiologie: Modellieren Sie Hämatopoese, Neurogenese, epithelial-mesenchymale Übergänge
  • Schätzung der latenten Zeit: Ordnen Sie Zellen entlang einer aus der Spleißdynamik abgeleiteten Pseudozeit an
  • Ergänzung zu Scanpy: Fügen Sie UMAP-Einbettungen Richtungsinformationen hinzu

Voraussetzungen

scVelo erfordert Zählmatrizen für sowohl ungespleißte als auch gespleißte RNA. Diese werden generiert durch:

  1. STARsolo oder kallisto|bustools mit dem Modus lamanno
  2. velocyto CLI: velocyto run10x / velocyto run
  3. alevin-fry / simpleaf mit gespleißtem/ungespleißtem Output

Die Daten werden in einem AnnData-Objekt mit layers["spliced"] und layers["unspliced"] gespeichert.

Standard RNA-Geschwindigkeits-Workflow

1. Einrichtung und Datenladen

import scvelo as scv
import scanpy as sc
import numpy as np
import matplotlib.pyplot as plt

# Einstellungen konfigurieren
scv.settings.verbosity = 3       # Berechnungsschritte anzeigen
scv.settings.presenter_view = True
scv.settings.set_figure_params('scvelo')

# Daten laden (AnnData mit gespleißten/ungespleißten Schichten)
# Option A: Aus loom laden (velocyto-Output)
adata = scv.read("cellranger_output.loom", cache=True)

# Option B: Velocyto-loom mit Scanpy-verarbeitetem AnnData zusammenführen
adata_processed = sc.read_h5ad("processed.h5ad")  # Hat UMAP, Cluster
adata_velocity = scv.read("velocyto.loom")
adata = scv.utils.merge(adata_processed, adata_velocity)

# Schichten überprüfen
print(adata)
# obs × var: N × G
# layers: 'spliced', 'unspliced' (erforderlich)
# obsm['X_umap'] (erforderlich für die Visualisierung)

2. Vorverarbeitung

# Filtern und normalisieren. Seit scVelo 0.3 filtert filter_and_normalize() nur
# Gene und normalisiert pro Zelle – es nimmt kein n_top_genes mehr und
# log-transformiert nicht mehr, daher kommen der log-Schritt und die HVG-Auswahl von Scanpy.
scv.pp.filter_and_normalize(
    adata,
    min_shared_counts=20    # Mindestanzahl an Counts in gespleißt+ungespleißt
)
sc.pp.log1p(adata)
sc.pp.highly_variable_genes(adata, n_top_genes=2000, subset=True)

# Momente erster und zweiter Ordnung berechnen (Mittelwerte und Varianzen)
# knn_connectivities müssen zuerst berechnet werden
sc.pp.neighbors(adata, n_neighbors=30, n_pcs=30)
scv.pp.moments(
    adata,
    n_pcs=30,
    n_neighbors=30
)

3. Geschwindigkeitsschätzung — Stochastisches Modell

Das stochastische Modell ist schnell und geeignet für explorative Analysen:

# Stochastische Geschwindigkeit (schneller, weniger genau)
scv.tl.velocity(adata, mode='stochastic')
scv.tl.velocity_graph(adata)

# Visualisieren
scv.pl.velocity_embedding_stream(
    adata,
    basis='umap',
    color='leiden',
    title="RNA-Geschwindigkeit (Stochastisch)"
)

4. Geschwindigkeitsschätzung — Dynamisches Modell (Empfohlen)

Das dynamische Modell passt die vollständige Spleißkinetik an und ist genauer:

# Dynamik wiederherstellen (rechenintensiv; ~10-30 Min. für 10K Zellen)
scv.tl.recover_dynamics(adata, n_jobs=4)

# Geschwindigkeit aus dem dynamischen Modell berechnen
scv.tl.velocity(adata, mode='dynamical')
scv.tl.velocity_graph(adata)

5. Latente Zeit

Das dynamische Modell ermöglicht die Berechnung einer gemeinsamen latenten Zeit (Pseudozeit):

# Latente Zeit berechnen
scv.tl.latent_time(adata)

# Latente Zeit auf UMAP visualisieren
scv.pl.scatter(
    adata,
    color='latent_time',
    color_map='gnuplot',
    size=80,
    title='Latente Zeit'
)

# Top-Gene identifizieren, geordnet nach latenter Zeit
top_genes = adata.var['fit_likelihood'].sort_values(ascending=False).index[:300]
scv.pl.heatmap(
    adata,
    var_names=top_genes,
    sortby='latent_time',
    col_color='leiden',
    n_convolve=100
)

6. Treibergen-Analyse

# Gene mit der höchsten Geschwindigkeitsanpassung identifizieren
scv.tl.rank_velocity_genes(adata, groupby='leiden', min_corr=0.3)
df = scv.DataFrame(adata.uns['rank_velocity_genes']['names'])
print(df.head(10))

# Geschwindigkeit und Kohärenz
scv.tl.velocity_confidence(adata)
scv.pl.scatter(
    adata,
    c=['velocity_length', 'velocity_confidence'],
    cmap='coolwarm',
    perc=[5, 95]
)

# Phasenporträts für bestimmte Gene
scv.pl.velocity(adata, ['Cpe', 'Gnao1', 'Ins2'],
               ncols=3, figsize=(16, 4))

7. Geschwindigkeitspfeile und Pseudozeit

# Pfeilplot auf UMAP
scv.pl.velocity_embedding(
    adata,
    arrow_length=3,
    arrow_size=2,
    color='leiden',
    basis='umap'
)

# Stromlinienplot (sauberere Visualisierung)
scv.pl.velocity_embedding_stream(
    adata,
    basis='umap',
    color='leiden',
    smooth=0.8,
    min_mass=4
)

# Geschwindigkeits-Pseudozeit (Alternative zur latenten Zeit)
scv.tl.velocity_pseudotime(adata)
scv.pl.scatter(adata, color='velocity_pseudotime', cmap='gnuplot')

8. PAGA-Trajektoriengraph

# PAGA-Graph mit geschwindigkeitsinformierten Übergängen
scv.tl.paga(adata, groups='leiden')
df = scv.get_df(adata, 'paga/transitions_confidence', precision=2).T
df.style.background_gradient(cmap='Blues').format('{:.2g}')

# PAGA mit Geschwindigkeit plotten
scv.pl.paga(
    adata,
    basis='umap',
    size=50,
    alpha=0.1,
    min_edge_width=2,
    node_size_scale=1.5
)

Vollständiges Workflow-Skript

import scvelo as scv
import scanpy as sc

def run_rna_velocity(adata, n_top_genes=2000, mode='dynamical', n_jobs=4):
    """
    Vollständiger RNA-Geschwindigkeits-Workflow.

    Args:
        adata: AnnData mit 'spliced'- und 'unspliced'-Schichten, UMAP in obsm
        n_top_genes: Anzahl der Top-HVGs für die Geschwindigkeit
        mode: 'stochastic' (schnell) oder 'dynamical' (genau)
        n_jobs: Parallele Jobs für das dynamische Modell

    Returns:
        Verarbeitetes AnnData mit Geschwindigkeitsinformationen
    """
    scv.settings.verbosity = 2

    # 1. Vorverarbeitung (scVelo 0.3 hat log/HVG aus filter_and_normalize entfernt)
    scv.pp.filter_and_normalize(adata, min_shared_counts=20)
    sc.pp.log1p(adata)
    sc.pp.highly_variable_genes(adata, n_top_genes=n_top_genes, subset=True)

    if 'neighbors' not in adata.uns:
        sc.pp.neighbors(adata, n_neighbors=30)

    scv.pp.moments(adata, n_pcs=30, n_neighbors=30)

    # 2. Geschwindigkeitsschätzung
    if mode == 'dynamical':
        scv.tl.recover_dynamics(adata, n_jobs=n_jobs)

    scv.tl.velocity(adata, mode=mode)
    scv.tl.velocity_graph(adata)

    # 3. Nachgelagerte Analysen
    if mode == 'dynamical':
        scv.tl.latent_time(adata)
        scv.tl.rank_velocity_genes(adata, groupby='leiden', min_corr=0.3)

    scv.tl.velocity_confidence(adata)
    scv.tl.velocity_pseudotime(adata)

    return adata

Wichtige Ausgabefelder in AnnData

Nach Ausführung des Workflows werden die folgenden Felder hinzugefügt:

OrtSchlüsselBeschreibung
adata.layersvelocityRNA-Geschwindigkeit pro Gen pro Zelle
adata.layersfit_tAngepasste latente Zeit pro Gen pro Zelle
adata.obsmvelocity_umap2D-Geschwindigkeitsvektoren auf UMAP
adata.obsvelocity_pseudotimePseudozeit aus der Geschwindigkeit
adata.obslatent_timeLatente Zeit aus dem dynamischen Modell
adata.obsvelocity_lengthGeschwindigkeit jeder Zelle
adata.obsvelocity_confidenceKonfidenzwert pro Zelle
adata.varfit_likelihoodGüte der Modellanpassung auf Genebene
adata.varfit_alphaTranskriptionsrate
adata.varfit_betaSpleißrate
adata.varfit_gammaAbbaurate
adata.unsvelocity_graphZell-Zell-Übergangswahrscheinlichkeitsmatrix

Vergleich der Geschwindigkeitsmodelle

ModellGeschwindigkeitGenauigkeitWann verwenden
stochasticSchnellMittelExplorative Analyse; große Datensätze
deterministicMittelMittelEinfache lineare Kinetik
dynamicalLangsamHochPublikationsqualität; identifiziert Treibergene

Best Practices

  • Beginnen Sie mit dem stochastischen Modus zur Exploration; wechseln Sie für die finale Analyse zum dynamischen Modell
  • Benötigen gute Abdeckung der ungespleißten Reads: Kurze Reads (< 100 bp) können die Intronabdeckung verpassen
  • Mindestens 2.000 Zellen: RNA-Geschwindigkeit ist bei weniger Zellen verrauscht
  • Die Geschwindigkeit sollte kohärent sein: Pfeile sollten der bekannten Biologie folgen; Zufälligkeit weist auf Probleme hin
  • k-NN-Bandbreite ist wichtig: Zu wenige Nachbarn → verrauschte Geschwindigkeit; zu viele → überglättet
  • Plausibilitätsprüfung: Wurzelzellen (Vorläufer) sollten hohe ungespleißte/gespleißte Verhältnisse für Markergene aufweisen
  • Das dynamische Modell erfordert verschiedene kinetische Zustände: Funktioniert am besten für klare Differenzierungsprozesse

Fehlerbehebung

ProblemLösung
Fehlende ungespleißte SchichtFühren Sie velocyto erneut aus oder verwenden Sie STARsolo mit --soloFeatures Gene Velocyto
Sehr wenige GeschwindigkeitsgeneVerringern Sie min_shared_counts; überprüfen Sie die Sequenziertiefe
Zufällig aussehende PfeileVersuchen Sie andere n_neighbors oder ein anderes Geschwindigkeitsmodell
Speicherfehler bei dynamischem ModellSetzen Sie n_jobs=1; reduzieren Sie n_top_genes
Negative Geschwindigkeit überallÜberprüfen Sie, ob die gespleißten/ungespleißten Schichten nicht vertauscht sind

Zusätzliche Ressourcen

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

adaptyv

How to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.

aeon

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

alphagenome

Look up precomputed AlphaGenome Atlas effects for any GRCh38 single-nucleotide variant (AVI score with Phred and 18 SHAP feature attributions, plus raw and quantile scores for RNA-seq, DNase, ATAC, ChIP-TF, ChIP-histone, CAGE, PRO-cap, splicing, polyadenylation and contact-map tracks), score variants or scan windows on demand with the AlphaGenome model for human and mouse (variant scoring, in silico mutagenesis, REF-versus-ALT track prediction), and build Atlas website deep links. Use when the user mentions AlphaGenome, AlphaGenome Atlas, AVI or AlphaGenome Variant Impact, DeepMind variant effect prediction, or wants to prioritise or mechanistically interpret non-coding, regulatory, splicing, enhancer, promoter, or chromatin-accessibility effects of SNVs from a VCF, credible set, or region. Research use only; not a clinical tool.

analytical-method-validation

Plan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include

anndata

Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.

arbor

Autonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g.

arboreto

Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.

astropy

Core Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.

autoskill

Observe the user

benchling-integration

Benchling Python SDK and REST API integration for registry entities, inventory, ELN entries, workflows, Benchling Apps, and Data Warehouse queries. Use when automating lab data with benchling-sdk or the v2 API.

bgpt-paper-search

Search scientific papers and retrieve structured experimental data extracted from full-text studies via the BGPT MCP server. Returns 25+ fields per paper including methods, results, sample sizes, quality scores, and conclusions. Use for literature reviews, evidence synthesis, and finding experimental details not available in abstracts alone.

bids

>

biopython

Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.

bioservices

Unified Python interface to 40+ bioinformatics services. Use when querying multiple databases (UniProt, KEGG, ChEMBL, Reactome) in a single workflow with consistent API. Best for cross-database analysis, ID mapping across services. For quick single-database lookups use gget; for sequence/file manipulation use biopython.

bulk-rnaseq

End-to-end bulk RNA-seq orchestrator — takes raw FASTQ reads through QC and trimming (FastQC, fastp/Trim Galore), alignment and quantification (STAR, Salmon, featureCounts), assembles a gene-level counts matrix, then hands off to differential expression (pydeseq2), pathway/GSEA enrichment (pathway-enrichment), and publication figures (scientific-visualization). Use whenever the user has bulk RNA-seq reads or quant output and wants a complete, reproducible differential-expression workflow — e.g.

cellxgene-census

Query the CZ CELLxGENE Census programmatically for versioned public single-cell and spatial transcriptomics data. Use when you need population-scale cell metadata, gene expression slices, Census summary counts, source H5AD URIs/downloads, embeddings, spatial Census data, or reference atlas comparisons across organisms, tissues, diseases, assays, and cell types. For analyzing your own local single-cell data use scanpy, anndata, or scvi-tools.

cirq

Google quantum computing framework. Use when targeting Google Quantum AI hardware, designing noise-aware circuits, or running quantum characterization experiments. Best for Google hardware, noise modeling, and low-level circuit design. For IBM hardware use qiskit; for quantum ML with autodiff use pennylane; for physics simulations use qutip.

citation-management

Comprehensive citation management for academic research. Search OpenAlex, PubMed, and Google Scholar for papers, extract accurate metadata, validate citations, and generate properly formatted BibTeX entries. This skill should be used when you need to find papers, verify citation information, convert DOIs to BibTeX, or ensure reference accuracy in scientific writing.

clinical-decision-support

Prepare and validate research-only clinical decision-support evaluation, evidence-profile, cohort, survival, biomarker/model, privacy, and governance artifacts. Use for aggregate or synthetic research documentation and traceability—not patient care or live clinical operation.

clinical-reports

Create safety-bounded draft structures and run local deterministic checks for clinical case, diagnostic, trial, safety, and aggregate research reports. Use only with synthetic, de-identified, or aggregate inputs and verified source-fact manifests; every output requires qualified review.

Verwandte Skills