bulk-rna-seq-deconvolution-with-bulk2single
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.
Install
mkdir -p .claude/skills/bulk-rna-seq-deconvolution-with-bulk2single && curl -L -o skill.zip "https://mcp.directory/api/skills/download/6656" && unzip -o skill.zip -d .claude/skills/bulk-rna-seq-deconvolution-with-bulk2single && rm skill.zipInstalls to .claude/skills/bulk-rna-seq-deconvolution-with-bulk2single
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
- Load libraries and data
- Import
omicverse as ov,scanpy as sc,scvelo as scv,anndata, andmatplotlib.pyplot as plt, then callov.plot_set()to match omicverse styling. - Read the bulk counts table with
ov.read(...)/ov.utils.read(...)and harmonise gene identifiers viaov.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 inadata.obs['clusters']).
- Import
- 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=-1forces CPU) and howbulk_groupnames align with column IDs in the bulk matrix.
- Instantiate
- 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(...)).
- Call
- Preprocess for beta-VAE
- Execute
model.bulk_preprocess_lazy(),model.single_preprocess_lazy(), andmodel.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.
- Execute
- 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
patienceand how to resume by reloading weights withmodel.load('.../dg_vae.pth'). - Use
model.plot_loss()to monitor convergence.
- Train with
- Generate and filter synthetic cells
- Produce an AnnData using
model.generate()and reduce noise throughmodel.filtered(generate_adata, leiden_size=25). - Store the filtered AnnData (
.write_h5ad) for reuse, noting it contains PCA embeddings inobsm['X_pca'].
- Produce an AnnData using
- 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 viaov.pl.embedding(..., color=['clusters'], palette=ov.pl.sc_color()).
- Plot cell-type compositions with
- 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" - Troubleshooting tips
- If marker selection fails, increase
top_marker_numor provide a curated marker list. - Alignment errors typically stem from mismatched
bulk_groupnames—double-check column IDs in the bulk matrix. - Training on CPU can take several hours; advise switching
gputo an available CUDA device for speed.
- If marker selection fails, increase
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
- Tutorial notebook:
t_bulk2single.ipynb - Example data and weights:
omicverse_guide/docs/Tutorials-bulk2single/data/ - Quick copy/paste commands:
reference.md
More by Starlitnightly
View all skills by Starlitnightly →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversUnlock AI-ready web data with Firecrawl: scrape any website, handle dynamic content, and automate web scraping for resea
Serena is a free AI code generator toolkit providing robust code editing and retrieval, turning LLMs into powerful artif
DeepWiki converts deepwiki.com pages into clean Markdown, with fast, secure extraction—perfect as a PDF text, page, or i
Transform Figma designs into high-quality code with AI. Seamless figma to code and figma to html workflows for efficient
GistPad (GitHub Gists) turns gists into a powerful knowledge management system for daily notes and versioned content.
Analyze Perfetto traces easily with Perfetto Trace Analyzer: turn natural language into actionable trace analysis insigh
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.