BU

bulk-rna-seq-deconvolution-with-bulk2single

Reconstruct single-cell datasets from bulk RNA-seq data using OmicVerse.

Install

mkdir -p .claude/skills/bulk-rna-seq-deconvolution-with-bulk2single && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/6656" && unzip -o skill.zip -d .claude/skills/bulk-rna-seq-deconvolution-with-bulk2single && rm skill.zip

Installs to .claude/skills/bulk-rna-seq-deconvolution-with-bulk2single

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Turn bulk RNA-seq cohorts into synthetic single-cell datasets using omicverse's Bulk2Single workflow for cell fraction estimation, beta-VAE generation, and quality control comparisons against reference scRNA-seq.
212 charsno explicit “when” trigger
Advanced

Key capabilities

  • Estimate cell fractions from bulk RNA-seq
  • Generate synthetic single-cell datasets
  • Train beta-VAE generators
  • Benchmark synthetic data against reference atlases
  • Filter noisy synthetic cells

How it works

It uses a beta-VAE generator to reconstruct single-cell profiles from bulk cohorts, validated against reference atlases for quality control.

Inputs & outputs

You give it
Bulk RNA-seq cohort and reference scRNA-seq AnnData
You get back
Synthetic single-cell AnnData and cell fraction estimates

When to use bulk-rna-seq-deconvolution-with-bulk2single

  • Estimate cell fractions from bulk RNA-seq
  • Reconstruct single-cell profiles from cohort data
  • Perform QC comparisons against scRNA-seq references

About this skill

Bulk RNA-seq deconvolution with Bulk2Single

Overview

Use this skill when a user wants to reconstruct single-cell profiles from bulk RNA-seq together with a matched reference scRNA-seq atlas. It follows t_bulk2single.ipynb, which demonstrates how to harmonise PDAC bulk replicates, train the beta-VAE generator, and benchmark the output cells against dentate gyrus scRNA-seq.

Instructions

  1. Load libraries and data
    • Import omicverse as ov, scanpy as sc, scvelo as scv, anndata, and matplotlib.pyplot as plt, then call ov.plot_set() to match omicverse styling.
    • Read the bulk counts table with ov.read(...)/ov.utils.read(...) and harmonise gene identifiers via ov.bulk.Matrix_ID_mapping(<df>, 'genesets/pair_GRCm39.tsv').
    • Load the reference scRNA-seq AnnData (e.g., scv.datasets.dentategyrus()) and confirm the cluster labels (stored in adata.obs['clusters']).
  2. Initialise the Bulk2Single model
    • Instantiate ov.bulk2single.Bulk2Single(bulk_data=bulk_df, single_data=adata, celltype_key='clusters', bulk_group=['dg_d_1', 'dg_d_2', 'dg_d_3'], top_marker_num=200, ratio_num=1, gpu=0).
    • Explain GPU selection (gpu=-1 forces CPU) and how bulk_group names align with column IDs in the bulk matrix.
  3. Estimate cell fractions
    • Call model.predicted_fraction() to run the integrated TAPE estimator, then plot stacked bar charts per sample to validate proportions.
    • Encourage saving the fraction table for downstream reporting (df.to_csv(...)).
  4. Preprocess for beta-VAE
    • Execute model.bulk_preprocess_lazy(), model.single_preprocess_lazy(), and model.prepare_input() to produce matched feature spaces.
    • Clarify that the lazy preprocessing expects raw counts; skip if the user has already log-normalised data and instead provide aligned matrices manually.
  5. Train or load the beta-VAE
    • Train with model.train(batch_size=512, learning_rate=1e-4, hidden_size=256, epoch_num=3500, vae_save_dir='...', vae_save_name='dg_vae', generate_save_dir='...', generate_save_name='dg').
    • Mention early stopping via patience and how to resume by reloading weights with model.load('.../dg_vae.pth').
    • Use model.plot_loss() to monitor convergence.
  6. Generate and filter synthetic cells
    • Produce an AnnData using model.generate() and reduce noise through model.filtered(generate_adata, leiden_size=25).
    • Store the filtered AnnData (.write_h5ad) for reuse, noting it contains PCA embeddings in obsm['X_pca'].
  7. Benchmark against the reference atlas
    • Plot cell-type compositions with ov.bulk2single.bulk2single_plot_cellprop(...) for both generated and reference data.
    • Assess correlation using ov.bulk2single.bulk2single_plot_correlation(single_data, generate_adata, celltype_key='clusters').
    • Embed with generate_adata.obsm['X_mde'] = ov.pl.mde(generate_adata.obsm['X_pca']) and visualise via ov.pl.embedding(..., color=['clusters'], palette=ov.pl.sc_color()).
  8. Defensive validation
    # Before Bulk2Single: verify gene name overlap between bulk and reference
    shared_genes = set(bulk_df.index) & set(adata.var_names)
    assert len(shared_genes) > 100, f"Only {len(shared_genes)} shared genes — check gene ID format (Ensembl vs symbol)"
    # Verify bulk_group column names match
    for g in bulk_group:
        assert g in bulk_df.columns, f"Bulk group '{g}' not found in bulk data columns"
    # Verify cell type key exists
    assert celltype_key in adata.obs.columns, f"Cell type column '{celltype_key}' not found in reference AnnData"
    
  9. Troubleshooting tips
    • If marker selection fails, increase top_marker_num or provide a curated marker list.
    • Alignment errors typically stem from mismatched bulk_group names—double-check column IDs in the bulk matrix.
    • Training on CPU can take several hours; advise switching gpu to an available CUDA device for speed.

Examples

  • "Estimate cell fractions for PDAC bulk replicates and generate synthetic scRNA-seq using Bulk2Single."
  • "Load a pre-trained Bulk2Single model, regenerate cells, and compare cluster proportions to the dentate gyrus atlas."
  • "Plot correlation heatmaps between generated cells and reference clusters after filtering noisy synthetic cells."

References

When not to use it

  • When reference scRNA-seq data is unavailable

Prerequisites

Matched reference scRNA-seq atlasBulk RNA-seq counts table

Limitations

  • Requires gene name overlap between bulk and reference
  • Training on CPU is significantly slower than GPU

How it compares

It automates the deconvolution and synthetic generation process using omicverse workflows rather than manual integration of bulk and single-cell data.

Compared to similar skills

bulk-rna-seq-deconvolution-with-bulk2single side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
bulk-rna-seq-deconvolution-with-bulk2single (this skill)15moNo flagsAdvanced
quant-analyst1032moNo flagsAdvanced
umap-learn62moReviewIntermediate
embedding-strategies82moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

quant-analyst

zenobi-us

Expert quantitative analyst specializing in financial modeling, algorithmic trading, and risk analytics. Masters statistical methods, derivatives pricing, and high-frequency trading with focus on mathematical rigor, performance optimization, and profitable strategy development.

103355

umap-learn

K-Dense-AI

UMAP dimensionality reduction. Fast nonlinear manifold learning for 2D/3D visualization, clustering preprocessing (HDBSCAN), supervised/parametric UMAP, for high-dimensional data.

6100

embedding-strategies

wshobson

Select and optimize embedding models for semantic search and RAG applications. Use when choosing embedding models, implementing chunking strategies, or optimizing embedding quality for specific domains.

890

building-automl-pipelines

jeremylongshore

Build automated machine learning pipelines, including feature engineering, model selection, and performance evaluation.

688

model-compare

rawwerks

Compare 3D CAD models using boolean operations (IoU, Dice, precision/recall). Use when evaluating generated models against gold references, diffing CAD revisions, or computing similarity metrics for ML training. Triggers on: model diff, compare models, IoU, intersection over union, model similarity, CAD comparison, STEP diff, 3D evaluation, gold reference, generated model, precision recall 3D.

783

matchms

davila7

Mass spectrometry analysis. Process mzML/MGF/MSP, spectral similarity (cosine, modified cosine), metadata harmonization, compound ID, for metabolomics and MS data processing.

674

Search skills

Search the agent skills registry