dsh-bulk-scrna-concordance: Bulk and Single-cell Pseudo-bulk Expression Concordance Analysis

Introduction

In a transcriptomics workflow, the same biological sample often has both bulk RNA-seq and single-cell RNA-seq data. Bulk measures mixed expression at the sample level, whereas single-cell data must be aggregated by cell type or individual into pseudo-bulk profiles to enable comparison with bulk data in the same gene dimension. Manually performing CPM, log2(x+1), summing/averaging by group, and then calculating correlations and plotting involves many steps and is prone to errors in matching group names.

DeepSeek Harness (DSH) packages capabilities as plugins, enabling direct tool invocation within conversations or workflows. Below is the community-maintained dsh-bulk-scrna-concordance: registered as bulk_scrna_concordance in a DSH Host, the same analysis can also be accessed via Python CLI or MCP by clients such as Claude, ChatGPT, etc.

What is this

Bulk–scRNA Concordance is used to compare whether bulk RNA-seq expression profiles are consistent with single-cell group-wise aggregated pseudo-bulk profiles. Maintained by Wanner122333, repository wanner122333/dsh-bulk-scrna-concordance, classified as model inference in the SkillHub plugin directory. The plugin package name is @local/dsh-bulk-scrna-concordance (package.json version 1.0.0).

The tool outputs Pearson, Spearman correlations, linear regression, optional group matching diagnostics, and plots; each run logs parameters, input/output hashes, and dependency package versions. The README clearly states: this is a descriptive comparison; group-wise aggregation cannot replace the estimation of biological replicate variability; the optional matched–mismatched correlation gap can indicate abnormal matches but cannot prove biological consistency.

Core Features

Inputs and Analysis Logic

  1. Single-cell raw counts: .h5ad, or a “gene × cell” matrix CSV plus cell metadata.
  2. Bulk expression: gene × sample CSV/TSV.
  3. Grouping: each cell has a column of group labels; bulk sample names must contain the corresponding group name as an exactly delimited token.

Single-cell counts are summed by group, while bulk expressions are averaged within the same group. Default normalization is CPM, followed by log2(x+1); regression and plotting use bulk as x and pseudo-bulk as y, with consistent gene sets and transformations.

For .h5ad, the default counts come from layers['counts'] (if present), otherwise use X; specify a layer with --sc-layer <name>, or use --sc-use-raw to use raw.X. Single-cell input must be raw counts: non-finite, negative, or non-integer values will be rejected; even integer-typed data may be a transformed matrix, so confirm the source before running.

Outputs

Results are written under --out-dir, mainly including:

File Content
<prefix>_results.json Parameters, per-group statistics, diagnostics, and warnings (CLI requires --results-json)
<prefix>_bulk_scrna_correlation_stats.csv Per-group statistics
<prefix>_discriminability.csv Pseudo-bulk × bulk correlation matrix (when discriminability is enabled)
<prefix>_bulk_scrna_correlation.{png,pdf,svg} Scatter plot (regression line and y=x)
<prefix>_manifest.json Code/input/output hashes and environment versions
<prefix>_run.log Analysis log when invoked via DSH or MCP

DSH and MCP

  • DSH: register tool name bulk_scrna_concordance; if restart-required is prompted after installation, restart DSH.
  • MCP: after installing requirements-mcp.txt, run python/python/mcp_server.py; expose the same tool via stdio or Streamable HTTP. Input files must exist locally on the server; HTTP binds to loopback by default without built-in authentication, requiring isolation or placement behind an authentication proxy.

Environment and Dependencies

Python requires numpy, pandas, scipy, matplotlib; reading .h5ad also requires anndata, h5py. Install in the repository root directory:

python -m pip install -r requirements.txt

Optional MCP dependencies:

python -m pip install -r requirements-mcp.txt

Installation and Activation

The DSH community directory has no official affiliation with DeepSeek / High-Flyer; read the repository source code and license before installation. The plugin executes Python subprocesses with the current DSH process privileges; do not blindly add untrusted paths.

In the DSH GUI

Open Settings → Plugins, select the plugin directory containing package.json (absolute path) to install the bundle. Desktop’s own profile can use the in-app installer.

Managing Profiles via CLI

dsh plugin --profile <profile> add /absolute/path/to/dsh-bulk-scrna-concordance

If the environment used by the profile does not have a suitable Python in PATH, set pythonPath in the profile’s plugin configuration (README example):

- id: bulk-scrna-concordance
  name: "@local/dsh-bulk-scrna-concordance"
  config:
    pythonPath: /absolute/path/to/python
    defaultTimeoutMs: 1800000
    maxLogLines: 40

After installation, check the installation result; restart DSH if necessary.

Typical Usage

Quick Run with Synthetic Data

python python/bulk_scrna_concordance.py \
  --sc-matrix-csv examples/synthetic/sc_expr.csv \
  --sc-meta-csv examples/synthetic/sc_meta.csv \
  --bulk-csv examples/synthetic/bulk.csv \
  --group-col Group --discriminability \
  --out-dir results --out-prefix example \
  --results-json results/example_results.json

Real .h5ad Data

python python/bulk_scrna_concordance.py \
  --sc-h5ad /path/to/counts.h5ad --sc-layer counts \
  --bulk-csv /path/to/bulk.csv --group-col Group \
  --out-dir results --out-prefix my_run \
  --results-json results/my_run_results.json

Public Data Example GSE77288

The README provides Tung et al. (2017) human iPSC data (GSE77288): three donors, untransformed read counts, with 92 ERCC columns removed. First prepare the inputs and then run the same command as in the repository:

python examples/gse77288/prepare.py --out-dir results/gse77288/input-data
python python/bulk_scrna_concordance.py \
  --sc-h5ad results/gse77288/input-data/sc_read_counts.h5ad \
  --bulk-csv results/gse77288/input-data/bulk_read_counts.csv \
  --group-col individual --gene-id-key var_names --discriminability \
  --out-dir results/gse77288 --out-prefix GSE77288_real \
  --results-json results/gse77288/GSE77288_real_results.json

prepare.py downloads approximately 13 MB of compressed counts and annotations, verifies fixed SHA-256 hashes, and writes raw counts and provenance. In the README’s published reference run, the Pearson r for the three donors is around 0.97 (see the repository’s results table and examples/gse77288/results/). For parameters, normalization, and limitations, refer to the repository’s docs/usage.md.

MCP Local Service

python python/mcp_server.py --transport stdio --workspace /path/to/data

For client configuration, refer to the repository’s docs/mcp.md.

Applicable Scenarios and Notes

Suitable for: Having both bulk and single-cell raw counts, needing to perform group-wise expression consistency QC or method validation; hoping to call bulk_scrna_concordance in a DSH conversation, or allow Claude / ChatGPT to trigger the same analysis on local data directories via MCP.

Notes:

  • The token matching rule between group names and bulk sample names is strict; naming inconsistencies can lead to silent mismatches or diagnostic warnings. Verify metadata beforehand.
  • Analysis time is related to matrix size; in DSH configuration, set defaultTimeoutMs to a larger value (e.g., 1800000 in the README).
  • MCP does not handle chat attachment uploads, only returns statistics and artifact paths; pay attention to access control when deploying HTTP.
  • For more detailed CLI parameters, MCP deployment, and limitations, refer to the GitHub README and docs/.

Conclusion

dsh-bulk-scrna-concordance turns the consistency check between bulk and single-cell pseudo-bulk into a reproducible pipeline, and integrates with DSH plugins and MCP, facilitating repeated use of the same statistical and plotting procedures in agent workflows. Directory page: SkillHub - dsh-bulk-scrna-concordance; source code and examples: GitHub - Wanner122333/dsh-bulk-scrna-concordance.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye