How medmaca/pgcna works
Project type and purpose
• Type: Python-based command-line tool for parsimonious gene correlation network analysis.
• Purpose:
• Read gene expression input data
• Compute pairwise correlations
• Retain the top 3 edges per gene (parsimonious pruning)
• Build a gene–gene network
• Detect communities/modules (PGCNA uses original algorithm; PGCNA2 uses improved community detection)
• Output network and module assignments for downstream tools
File structure
• Top‐level: README.md describing both versions.
• Subfolder “PGCNA”:
• pgcna.py – core CLI entrypoint and processing pipeline for original version
• pgcna-multi.py – variant supporting multi‐threading or batch runs
• README.md – usage instructions for original version
• Subfolder “PGCNA2”:
• pgcna2.py – CLI entrypoint using the improved community detection algorithm
• README.md – usage instructions for the 2.0 version
README for architectural clues
• Both versions share the same high-level pipeline up to community detection
• Only the “community detection” block differs between PGCNA and PGCNA2
Main components
a. CLI Interface
• Argument parser (input file paths, parameters, version flag)
b. Data Loader
• CSV/TSV expression matrix reader
c. Correlation Matrix Calculator
• Compute pairwise gene correlation (e.g. Pearson)
d. Parsimonious Pruner
• For each gene, select top-3 edges
e. Network Builder
• Build graph data structure (nodes = genes; edges = top correlations)
• Original algorithm (PGCNA)
• Improved algorithm (PGCNA2)
g. Output Writer
• Module assignments file
• Network edge list file
• (Optionally) visualization files for downstream tools
h. External Libraries/Dependencies
• NumPy/Pandas (data handling)
• NetworkX or igraph (graph operations)
• community-detection library (for PGCNA2)
Relationships and data flows
CLI → Data Loader → Correlation Calculator → Pruner → Network Builder → Community Detection → Output Writer
Architectural patterns and principles
• Pipeline pattern: each step is a separate, composable function/module
• Separation of concerns: data I/O, computation, graph operations, and output
• Version-swap point: isolate community-detection algorithm so it can be replaced (strategy pattern)