OpenClaw-Medical-Skills bulk-wgcna-analysis-with-omicverse
Assist Claude in running PyWGCNA through omicverse—preprocessing expression matrices, constructing co-expression modules, visualising eigengenes, and extracting hub genes.
install
source · Clone the upstream repo
git clone https://github.com/FreedomIntelligence/OpenClaw-Medical-Skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/FreedomIntelligence/OpenClaw-Medical-Skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/bulk-wgcna-analysis" ~/.claude/skills/freedomintelligence-openclaw-medical-skills-bulk-wgcna-analysis-with-omicverse && rm -rf "$T"
OpenClaw · Install into ~/.openclaw/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/FreedomIntelligence/OpenClaw-Medical-Skills "$T" && mkdir -p ~/.openclaw/skills && cp -r "$T/skills/bulk-wgcna-analysis" ~/.openclaw/skills/freedomintelligence-openclaw-medical-skills-bulk-wgcna-analysis-with-omicverse && rm -rf "$T"
manifest:
skills/bulk-wgcna-analysis/SKILL.mdsource content
Bulk WGCNA analysis with omicverse
Overview
Activate this skill for users who want to reproduce the WGCNA workflow from
. It guides you through loading expression data, configuring PyWGCNA, constructing weighted gene co-expression networks, and inspecting modules of interest.t_wgcna.ipynb
Instructions
- Prepare the environment
- Import
,omicverse as ov
,scanpy as sc
, andmatplotlib.pyplot as plt
.pandas as pd - Set plotting defaults via
.ov.plot_set()
- Import
- Load and filter expression data
- Read expression matrices (e.g., from
).expressionList.csv - Calculate median absolute deviation with
andfrom statsmodels import robust
.gene_mad = data.apply(robust.mad) - Keep the top variable genes (e.g.,
).data = data.T.loc[gene_mad.sort_values(ascending=False).index[:2000]]
- Read expression matrices (e.g., from
- Initialise PyWGCNA
- Create
.pyWGCNA_5xFAD = ov.bulk.pyWGCNA(name=..., species='mus musculus', geneExp=data.T, outputPath='', save=True) - Confirm
looks correct before proceeding.pyWGCNA_5xFAD.geneExpr
- Create
- Preprocess the dataset
- Run
to drop low-expression genes and problematic samples.pyWGCNA_5xFAD.preprocess()
- Run
- Construct the co-expression network
- Evaluate soft-threshold power:
.pyWGCNA_5xFAD.calculate_soft_threshold() - Build adjacency and TOM matrices via
andcalculating_adjacency_matrix()
.calculating_TOM_similarity_matrix()
- Evaluate soft-threshold power:
- Detect gene modules
- Generate dendrograms and modules:
,calculate_geneTree()
.calculate_dynamicMods(kwargs_function={'cutreeHybrid': {...}}) - Derive module eigengenes with
.calculate_gene_module(kwargs_function={'moduleEigengenes': {'softPower': 8}}) - Visualise adjacency/TOM heatmaps using
if needed.plot_matrix(save=False)
- Generate dendrograms and modules:
- Inspect specific modules
- Extract genes from modules with
.get_sub_module([...], mod_type='module_color') - Build sub-networks using
and plot them viaget_sub_network(mod_list=[...], mod_type='module_color', correlation_threshold=0.2)
.plot_sub_network(...)
- Extract genes from modules with
- Update sample metadata for downstream analyses
- Load sample annotations
.updateSampleInfo(path='.../sampleInfo.csv', sep=',') - Assign colour maps for metadata categories with
.setMetadataColor(...)
- Load sample annotations
- Analyse module–trait relationships
- Run
to compute module–trait statistics.analyseWGCNA() - Plot module eigengene heatmaps and bar charts with
andplotModuleEigenGene(module, metadata, show=True)
.barplotModuleEigenGene(...)
- Run
- Find hub genes
- Identify top hubs per module using
.top_n_hub_genes(moduleName='lightgreen', n=10)
- Identify top hubs per module using
- Troubleshooting tips
- Large datasets may require increasing
to avoid writing many intermediate files.save=False - If module detection fails, confirm enough genes remain after MAD filtering and adjust
ordeepSplit
.softPower - Ensure metadata categories have assigned colours before plotting eigengene heatmaps.
- Large datasets may require increasing
Examples
- "Build a WGCNA network on the 5xFAD dataset, visualise modules, and extract hub genes from the lightgreen module."
- "Load sample metadata, update colours for sex and genotype, and plot module eigengene heatmaps."
- "Create a sub-network plot for the gold module using a correlation threshold of 0.2."
References
- Tutorial notebook:
t_wgcna.ipynb - Tutorial dataset:
data/5xFAD_paper/ - Quick copy/paste commands:
reference.md