How ngsfc/scgraphverse works
Project Type and Purpose
• Project type: R package for single-cell gene regulatory network (GRN) inference, consensus, evaluation, and visualization.
• Purpose: Provide a suite of interchangeable GRN algorithms (GENIE3, GRNBoost2, ZILGM, PCzinb, JRF), thresholding/consensus tools, performance metrics, and plotting utilities on single-cell RNA-seq data.
File Structure
Top-level directories:
• R/ – Core R functions, each file encapsulates one algorithm or utility (e.g., community_path.R, infer_networks.R, plotg.R).
• man/ – Auto-generated Rd documentation.
• tests/ – testthat unit tests for networks, comparisons, simulations.
• vignettes/ – User-facing how-to guides and case studies (RMarkdown).
• docs/, pkgdown.yml – Static site (pkgdown) for HTML docs, articles, reference.
• DESCRIPTION, NAMESPACE – R package metadata and exports.
• _pkgdown.yml – Controls site layout.
• NEWS.md, LICENSE – Release notes and license.
README for Additional Insights
• High-level workflow: data ingestion → GRN inference (multiple engines) → thresholding → consensus → evaluation → visualization.
• External dependencies: Python’s arboreto (for GRNBoost2), GitHub packages (ZILGM, learn2count, INet-Tool), CRAN/Bioconductor – these must be installed outside R.
Main Components and Interactions
a. Core R Functions (R/ folder) – each boxed as a module:
– GRN inference modules (GENIE3, GRNBoost2 wrapper, ZILGM, PCzinb, JRF)
– null-model thresholding (cutoff_adjacency)
– consensus (create_consensus, compare_consensus)
– evaluation (plotROC, pscores, network topology metrics)
– visualization (plotg, community_similarity, community_path)
– utility/support (generate_adjacency, symmetrize, init_py, utils)
b. External Services & Packages:
– Python Arboreto for GRNBoost2
– GitHub/Bioc packages for ZILGM, PCzinb, INet-Tool
– CRAN packages: igraph, ggraph, etc.
c. Data Flow & Dependencies:
1. User input: single-cell expression matrix (R object or file).
2. init_py() → sets up Python env (reticulate) for GRNBoost2.
3. infer_networks() dispatches to chosen inference module(s).
4. generate_adjacency() composes adjacency matrices.
5. cutoff_adjacency() filters edges via null distributions.
6. create_consensus() or compare_consensus() merges or compares networks.
7. pscores() and plotROC() compute and plot performance metrics.
d. Documentation & Testing:
– vignettes/ illustrate end-to-end workflows (case_study, simulation_study).
– man/ and docs/ generated via roxygen2 + pkgdown.
– tests/ verify algorithm outputs, consistency, edge cases.
Architectural Patterns & Design Principles
• Modular design: one‐function‐per‐file, easy to extend with new inference methods.
• Functional pipeline: pure functions for each step, chaining via lists of adjacency objects.
• Adapter pattern: wrapper functions (e.g., GRNBoost2, ZILGM) normalize external engine interfaces.
• Plugin-style extensibility: new methods simply drop in an R file and register in NAMESPACE.
Final Checklist
– All major R modules and folders represented.
– External engines/services and how they’re invoked.
– Notes on extensibility (plugin points for new methods).
– Sections for documentation and testing to show project maintainability.