How nourmarzouka/multiclasspairs works
Project Overview
• Type & Purpose:
• An R package (“multiclassPairs”) providing a toolbox for single-sample, pair‐based multiclass classification.
• Implements two schemes:
– One-vs-rest using Top-Score Pairs (TSP via switchBox)
– Random Forest (RF via ranger, optional Boruta pruning)
• Organizes code under /R, documentation under /man + vignettes, assets under /images.
Main Components & Layers
A. Package Structure
• R/ — Source functions (ReadData, filter*, train*, predict*, sort*, plot*).
• man/ — Rd files for each public function.
• vignettes/ — Tutorial workflows (Rmd + generated figures).
• DESCRIPTION, NAMESPACE — Package metadata and exports.
B. Core Functional Modules
1. Data Ingestion & Wrangling
• ReadData: wraps data.frame, matrix, or ExpressionSet → multiclassPairs object.
2. Feature Filtering / Sorting
a. TSP branch: filter_genes_TSP → produces per‐class filtered gene lists.
b. RF branch: sort_genes_RF → ranks genes “altogether” & “one_vs_rest.”
3. Rule Generation & Sorting
a. TSP branch: train_one_vs_rest_TSP builds and scores binary rule sets.
b. RF branch: sort_rules_RF → combines top genes into rules, ranks by importance.
4. Model Training
a. TSP: internally calls switchBox::SWAP.Train.KTSP to pick optimal k‐rules.
b. RF: train_RF uses ranger (with optional Boruta feature pruning) to fit multiclass RF.
5. Prediction & Scoring
• predict_one_vs_rest_TSP / predict_RF apply trained models to new data, output class scores & labels.
6. Visualization
• plot_binary_TSP / plot_binary_RF produce heatmaps of rule truth values and class scores.
C. External Dependencies
• Biobase (ExpressionSet support)
• switchBox (KTSP algorithm & scoring)
• ranger (fast Random Forest)
• Boruta (optional rule pruning)
• caret / gplots / ggplot2 (visualization & evaluation)
Relationships & Data Flow
[User Data] → ReadData → [multiclassPairs object]
↙ ↘
TSP branch RF branch
↓ ↓
filter_genes_TSP sort_genes_RF
↓ ↓
train_one_vs_rest_TSP sort_rules_RF
↓ ↓
predict_one_vs_rest_TSP train_RF
↓ ↓
plot_binary_TSP predict_RF
↓
plot_binary_RF
Architectural Patterns & Design Principles
• Modular design: each logical step is a standalone R function exported in NAMESPACE.
• Dual‐scheme parallelism: two interchangeable branches (TSP vs RF) share interface patterns (filter/train/predict/plot).
• Functional pipeline: pure functions pass well-specified objects, enabling reproducibility via seeds.
• Extensibility points: users can swap underlying algorithms (e.g., supply custom filter or ranger args, toggle Boruta).