smithery/Starlitnightly

bulk-wgcna-analysis-with-omicverse

WGCNA co-expression network: soft-threshold, module detection, eigengenes, hub genes, and trait correlation in OmicVerse.

Installation

$ npx skills add smithery/Starlitnightly --skill bulk-wgcna-analysis-with-omicverse

Also in this package

Other skills from smithery/Starlitnightly · top by installs.

npx skills add smithery/Starlitnightly

Browse all from smithery/Starlitnightly

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 4,426 B
  • docs SUMMARY.md 215 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

Bulk WGCNA analysis with omicverse

Overview

Activate this skill for users who want to reproduce the WGCNA workflow from [twgcna.ipynb](../../omicverseguide/docs/Tutorials-bulk/t_wgcna.ipynb). It guides you through loading expression data, configuring PyWGCNA, constructing weighted gene co-expression networks, and inspecting modules of interest.

Instructions

  1. Prepare the environment

- Import omicverse as ov, scanpy as sc, matplotlib.pyplot as plt, and pandas as pd. - Set plotting defaults via ov.plot_set().

  1. Load and filter expression data

- Read expression matrices (e.g., from expressionList.csv). - Calculate median absolute deviation with from statsmodels import robust and genemad = data.apply(robust.mad). - Keep the top variable genes (e.g., data = data.T.loc[genemad.sort_values(ascending=False).index[:2000]]).

  1. Initialise PyWGCNA

- Create pyWGCNA5xFAD = ov.bulk.pyWGCNA(name=..., species='mus musculus', geneExp=data.T, outputPath='', save=True). - Confirm pyWGCNA5xFAD.geneExpr looks correct before proceeding.

  1. Preprocess the dataset

- Run pyWGCNA_5xFAD.preprocess() to drop low-expression genes and problematic samples.

  1. Construct the co-expression network

- Evaluate soft-threshold power: pyWGCNA5xFAD.calculatesoftthreshold(). - Build adjacency and TOM matrices via calculatingadjacencymatrix() and calculatingTOMsimilaritymatrix().

  1. Detect gene modules

- Generate dendrograms and modules: calculategeneTree(), calculatedynamicMods(kwargsfunction={'cutreeHybrid': {...}}). - Derive module eigengenes with calculategenemodule(kwargsfunction={'moduleEigengenes': {'softPower': 8}}). - Visualise adjacency/TOM heatmaps using plot_matrix(save=False) if needed.

  1. Inspect specific modules

- Extract genes from modules with getsubmodule([...], modtype='modulecolor'). - Build sub-networks using getsubnetwork(modlist=[...], modtype='modulecolor', correlationthreshold=0.2) and plot them via plotsubnetwork(...).

  1. Update sample metadata for downstream analyses

- Load sample annotations updateSampleInfo(path='.../sampleInfo.csv', sep=','). - Assign colour maps for metadata categories with setMetadataColor(...).

  1. Analyse module–trait relationships

- Run analyseWGCNA() to compute module–trait statistics. - Plot module eigengene heatmaps and bar charts with plotModuleEigenGene(module, metadata, show=True) and barplotModuleEigenGene(...).

  1. Find hub genes

- Identify top hubs per module using topnhub_genes(moduleName='lightgreen', n=10).

  1. Defensive validation

``python # Before WGCNA: verify enough genes remain after MAD filtering assert data.shape[0] >= 1000, f"Only {data.shape[0]} genes after filtering — WGCNA needs >1000 for meaningful modules" # Verify expression values are numeric and non-negative assert data.dtypes.apply(lambda d: d.kind in 'iuf').all(), "Expression matrix contains non-numeric columns" # Verify enough samples for network construction assert data.shape[1] >= 6, f"Only {data.shape[1]} samples — WGCNA needs >=6 samples for reliable co-expression" ``

  1. Troubleshooting tips

- Large datasets may require increasing save=False to avoid writing many intermediate files. - If module detection fails, confirm enough genes remain after MAD filtering and adjust deepSplit or softPower. - Ensure metadata categories have assigned colours before plotting eigengene heatmaps.

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: [twgcna.ipynb](../../omicverseguide/docs/Tutorials-bulk/t_wgcna.ipynb)
  • Tutorial dataset: [data/5xFADpaper/](../../omicverseguide/docs/Tutorials-bulk/data/5xFAD_paper/)
  • Quick copy/paste commands: [reference.md](reference.md)