Logo Wgcna Analysis

Wgcna Analysis

Tổ chứcPhổ biến
aipoch
wgcna-analysis

Use when building a weighted gene co-expression network from a bulk expression matrix and a sample group file, filtering variable genes by MAD, identifying co-expression modules with WGCNA, correlating modules with traits, and exporting module-level plots and gene tables. NOT for single-cell RNA-seq, differential expression testing, methylation analysis, or datasets that are too small for WGCNA after quality control.

Add to TypingMind

Tổng quan

Nhà phát hànhaipoch
Kho mãmedical-research-skills
Tên kỹ năngwgcna-analysis
Sao
1.9K
Bản fork
188
Tệp đi kèm
16
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 16 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được aipoch công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Wgcna Analysis trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/aipoch/medical-research-skills/tree/main/awesome-med-research-skills/Data%20Analysis/wgcna-analysis
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.

Sử dụng trong TypingMind

Bật Wgcna Analysis trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Wgcna Analysis ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Wgcna Analysis với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Source: https://github.com/aipoch/medical-research-skills

WGCNA Analysis

When to Read External Files

AI Agent: This section tells you when to read additional files.

SituationFile to ReadPurpose
Need algorithm detailsreferences/algorithm.mdWGCNA workflow, filtering strategy, statistics, assumptions
Need to run analysisscripts/main.RExecute: Rscript scripts/main.R --input_file ... --group_file ...
Encounter errorsreferences/troubleshooting.mdCommon errors, causes, and fixes
Need CLI examplesreferences/cli-guide.mdComplete command examples for common scenarios
Need conversion audit detailsreferences/diagnosis-report.mdSkill readiness assessment and remediation summary
Need test datatests/data/Minimal example input files for validation

When Not to Use

  • Do not use for single-cell RNA-seq matrices.
  • Do not use for methylation data, DEG testing, or other non-WGCNA workflows.
  • Do not use if the user only wants exploratory discussion and does not want the analysis executed.
  • Do not proceed if the dataset is obviously too small for WGCNA or becomes too small after QC.

When an input is out of scope, stop early and state which limitation applies.


Usage

bash
Rscript scripts/main.R \
  --input_file ./expression_matrix.csv \
  --group_file ./group_info.csv \
  --output_dir ./output/ \
  --sample_column sample \
  --group_column group \
  --network_type unsigned \
  --cor_type pearson \
  --mad_quantile 0.25 \
  --min_mad 0.01 \
  --max_genes 5000 \
  --min_module_size 30 \
  --merge_cut_height 0.25 \
  --soft_r2_cutoff 0.85 \
  --module_of_interest auto \
  --top_modules 1 \
  --tom_sample_size 400 \
  --chunk_size 0 \
  --seed 42 \
  --timeout_seconds 0

Arguments

ShortLongTypeDefaultDescription
-i--input_filecharacterrequiredExpression matrix file with genes in rows and samples in columns
-g--group_filecharacterrequiredSample-to-group mapping file
-o--output_dircharacter./output/Output directory
-a--sample_columncharactersampleSample column in the group file; falls back to the first column if not found
-b--group_columncharactergroupGroup column in the group file; falls back to the second column if not found
-n--network_typecharacterunsignedNetwork type for WGCNA: unsigned or signed
-c--cor_typecharacterpearsonCorrelation type: pearson or bicor
-q--mad_quantiledouble0.25MAD quantile used to define the variability cutoff
-m--min_maddouble0.01Minimum MAD cutoff combined with the quantile filter
-k--max_genesinteger0Maximum number of retained variable genes; 0 keeps all filtered genes
-p--min_module_sizeinteger30Minimum module size used by blockwiseModules()
-r--merge_cut_heightdouble0.25Merge cut height for module merging
-u--soft_r2_cutoffdouble0.85Target scale-free topology R-squared cutoff for soft-threshold selection
-t--trait_of_interestcharacterNULLTrait column used for module membership vs trait scatter plots; defaults to the first trait column
-x--module_of_interestcharacterautoModule color or comma-separated module colors to export; auto ranks modules by absolute module-trait correlation
--top_modulesinteger1Number of top-ranked modules to export when module_of_interest=auto
-y--tom_sample_sizeinteger400Number of genes sampled for the TOM heatmap
--chunk_sizeinteger0Row chunk size for large expression matrices; 0 disables chunked loading
-s--seedinteger42Random seed for reproducibility and TOM heatmap sampling
-z--timeout_secondsinteger0Optional elapsed-time limit in seconds; 0 disables timeout

Input Format

Expression Matrix (input_file)

CSV file with gene identifiers in the first column and sample IDs in the header row. All expression columns must be numeric.

csv
,TCGA-78-7156,TCGA-44-6774,TCGA-69-A59K
A1BG,2.612908495,2.077948602,3.865545859
A1BG-AS1,3.526391179,3.221923473,4.684308865
A1CF,1.179552278,1.136255654,1.188781778

Requirements:

  • First column contains non-empty gene IDs
  • Sample column names are unique and non-empty
  • Expression values are numeric
  • After QC, the matrix must remain large enough for WGCNA

Group File (group_file)

CSV file with at least two columns: one sample ID column and one group column.

csv
sample,group
TCGA-78-7156,Control
TCGA-44-6774,Control
TCGA-69-A59K,Control
TCGA-44-6147,Case

Requirements:

  • Sample IDs must match expression matrix column names
  • Sample IDs must be unique
  • Group values must be non-empty
  • At least two groups are required

Output Files

All files are written under output_dir.

FileFormatDescription
session_info.txttextR session information and package versions
plots/soft_threshold.pdfPDFScale-free topology fit and mean connectivity across tested powers
plots/sample_clustering.pdfPDFSample dendrogram with group color annotation
plots/gene_cluster_modules.pdfPDFGene dendrogram with module color labels
plots/module_eigengene_heatmap.pdfPDFEigengene adjacency heatmap
plots/tom_heatmap.pdfPDFTOM-based network heatmap for a sampled subset of genes
plots/module_trait_relationships.pdfPDFHeatmap of module-trait correlations and p-values
plots/module_membership_vs_trait_<module>_<trait>.pdfPDFScatter plot for each exported module against the selected trait
tables/sft_fit_indices.csvCSVSoft-threshold fit statistics returned by pickSoftThreshold()
tables/module_trait_cor.csvCSVModule eigengene vs trait correlation matrix
tables/module_trait_p.csvCSVP-value matrix corresponding to module-trait correlations
tables/module_assignments.csvCSVPer-gene module assignments
tables/selected_modules.csvCSVRanked summary of exported modules for the selected trait
tables/module_genes_<module>.csvCSVGene-level export for each selected module
tables/analysis_summary.csvCSVSummary of samples, retained genes, selected power, selected trait, and exported modules
data/net.rdsRDSFull WGCNA network object returned by blockwiseModules()
data/analysis_objects.rdsRDSSaved analysis objects, trait data, statistics, and selected modules
data/wgcna_tom-block.*.RDataRDataSaved TOM block file(s) produced by blockwiseModules()

Workflow

Step 1: Load and validate inputs

  • Validate file existence and CLI parameters
  • Read the expression matrix and group file
  • Check sample ID consistency between files

Step 2: Filter variable genes

  • Compute per-gene MAD values
  • Keep genes above the quantile-based MAD cutoff
  • Optionally cap the retained genes with max_genes

Step 3: Build the WGCNA network

  • Transpose the matrix into the WGCNA sample-by-gene format
  • Select soft-threshold power with pickSoftThreshold()
  • Build modules with blockwiseModules()

Step 4: Associate modules with traits

  • Encode groups as a trait matrix
  • Compute module-trait and gene-trait correlations
  • Rank modules by absolute correlation with the selected trait

Step 5: Export results

  • Save summary tables, module assignments, and per-module gene exports
  • Generate dendrogram, heatmap, TOM, and scatter plot PDFs
  • Save session info and serialized R objects

Error Handling

Common Errors

ErrorCauseSolution
SKILL_FILE_NOT_FOUNDInput file path is wrong or a required TOM file is missingCheck file paths and rerun the analysis from the start
SKILL_MISSING_COLUMNSRequired sample, group, or gene identifier columns are missing or emptyVerify the CSV header and column names
SKILL_EMPTY_DATAInput is empty, no genes pass filtering, or the filtered matrix is too small for WGCNACheck data quality and relax filtering settings
SKILL_INVALID_PARAMETERA CLI value is missing, out of range, or not in the allowed choicesReview parameter values in the command
SKILL_SAMPLE_MISMATCHGroup file sample IDs do not match expression matrix sample IDsMake sample identifiers identical across both files
SKILL_PACKAGE_NOT_FOUNDA required R package is not installedInstall missing packages before running

IF error persists, READ: references/troubleshooting.md


Testing

Smoke Test

bash
# Check CLI help
Rscript scripts/main.R --help

# Run with bundled test data
Rscript scripts/main.R \
  --input_file tests/data/expression.csv \
  --group_file tests/data/group.csv \
  --output_dir tests/output-skill/ \
  --sample_column sample \
  --group_column group \
  --network_type unsigned \
  --cor_type pearson \
  --mad_quantile 0.25 \
  --min_mad 0.01 \
  --max_genes 500 \
  --min_module_size 20 \
  --merge_cut_height 0.25 \
  --soft_r2_cutoff 0.8 \
  --module_of_interest auto \
  --top_modules 1 \
  --tom_sample_size 150 \
  --chunk_size 0 \
  --seed 42 \
  --timeout_seconds 0

# Validate required outputs
Rscript tests/validate_outputs.R tests/output-skill/

Validation Commands

bash
Rscript tests/validate_outputs.R tests/output-skill/

Expected outputs include session_info.txt, the plot PDFs, table CSVs, and the serialized R objects listed above.

Additional Verification

  • When exporting explicit modules, confirm the matching tables/module_genes_<module>.csv files exist.
  • When generating module membership plots, confirm the matching plots/module_membership_vs_trait_<module>_<trait>.pdf files exist.
  • If chunked loading is enabled, compare tables/analysis_summary.csv against a non-chunked run on the same input.

Notes

  • Re-running the same command with the same seed is expected to be reproducible.
  • Failed runs may still create output_dir and session_info.txt before exiting; this is expected and safe to overwrite on retry.

Implementation Checklist

  • CLI parsing with optparse
  • set.seed() for reproducibility
  • Dependency checks with explicit package loading
  • Relative source() paths via get_script_dir()
  • Optional timeout parameter
  • Optional chunked loading for large matrices
  • Session info recording
  • Error handling with SKILL_* codes
  • SKILL.md parameters match the implemented CLI
  • File reading instructions in SKILL.md
  • Test data provided in tests/data/
  • Smoke-test output validation script provided

Last updated: 2026-04-17 | Version: 1.0.0

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Wgcna Analysis làm được gì?

Use when building a weighted gene co-expression network from a bulk expression matrix and a sample group file, filtering variable genes by MAD, identifying co-expression modules with WGCNA, correlating modules with traits, and exporting module-level plots and gene tables. NOT for single-cell RNA-seq, differential expression testing, methylation analysis, or datasets that are too small for WGCNA after quality control.

Vì sao nên dùng Wgcna Analysis trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Wgcna Analysis là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Wgcna Analysis trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/aipoch/medical-research-skills/tree/main/awesome-med-research-skills/Data%20Analysis/wgcna-analysis. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Wgcna Analysis?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Wgcna Analysis với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Wgcna Analysis với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Wgcna Analysis có miễn phí không?

Có. Kỹ năng này được aipoch phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇