Agent skill
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 this agent skill to your Project
npx add-skill https://github.com/FreedomIntelligence/OpenClaw-Medical-Skills/tree/main/skills/bulk-wgcna-analysis
SKILL.md
Bulk WGCNA analysis with omicverse
Overview
Activate this skill for users who want to reproduce the WGCNA workflow from t_wgcna.ipynb. It guides you through loading expression data, configuring PyWGCNA, constructing weighted gene co-expression networks, and inspecting modules of interest.
Instructions
- Prepare the environment
- Import
omicverse as ov,scanpy as sc,matplotlib.pyplot as plt, andpandas 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
from statsmodels import robustandgene_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
pyWGCNA_5xFAD.geneExprlooks correct before proceeding.
- Create
- Preprocess the dataset
- Run
pyWGCNA_5xFAD.preprocess()to drop low-expression genes and problematic samples.
- Run
- Construct the co-expression network
- Evaluate soft-threshold power:
pyWGCNA_5xFAD.calculate_soft_threshold(). - Build adjacency and TOM matrices via
calculating_adjacency_matrix()andcalculating_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
plot_matrix(save=False)if needed.
- Generate dendrograms and modules:
- Inspect specific modules
- Extract genes from modules with
get_sub_module([...], mod_type='module_color'). - Build sub-networks using
get_sub_network(mod_list=[...], mod_type='module_color', correlation_threshold=0.2)and plot them viaplot_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
analyseWGCNA()to compute module–trait statistics. - Plot module eigengene heatmaps and bar charts with
plotModuleEigenGene(module, metadata, show=True)andbarplotModuleEigenGene(...).
- 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
save=Falseto avoid writing many intermediate files. - If module detection fails, confirm enough genes remain after MAD filtering and adjust
deepSplitorsoftPower. - 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
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
vcf-annotator
Annotate VCF variants with VEP, ClinVar, gnomAD frequencies, and ancestry-aware context. Generates prioritised variant reports.
chemist-analyst
Analyzes events through chemistry lens using molecular structure, reaction mechanisms, thermodynamics, kinetics, and analytical techniques (spectroscopy, chromatography, mass spectrometry). Provides insights on chemical processes, material properties, reaction pathways, synthesis, and analytical methods. Use when: Chemical reactions, material analysis, synthesis planning, process optimization, environmental chemistry. Evaluates: Molecular structure, reaction mechanisms, yield, selectivity, safety, environmental impact.
bio-alignment-io
Read, write, and convert multiple sequence alignment files using Biopython Bio.AlignIO. Supports Clustal, PHYLIP, Stockholm, FASTA, Nexus, and other alignment formats for phylogenetics and conservation analysis. Use when reading, writing, or converting alignment file formats.
sleep-analyzer
分析睡眠数据、识别睡眠模式、评估睡眠质量,并提供个性化睡眠改善建议。支持与其他健康数据的关联分析。
metabolomics-workbench-database
Access NIH Metabolomics Workbench via REST API (4,200+ studies). Query metabolites, RefMet nomenclature, MS/NMR data, m/z searches, study metadata, for metabolomics and biomarker discovery.
bio-hi-c-analysis-matrix-operations
Balance, normalize, and transform Hi-C contact matrices using cooler and cooltools. Apply iterative correction (ICE), compute expected values, and generate observed/expected matrices. Use when normalizing or transforming Hi-C matrices.
Didn't find tool you were looking for?