This guide explains how to reproduce the analyses from the fedRBE preprint, including centralized limma correction, federated fedRBE correction, and downstream evaluation.
environment.yml, or separate Python 3.8+ and R 4.0+ installations.Set up Git LFS locally:
Install git lfs following the git lfs documentation.
Initialize Git LFS:
git lfs install
Get the repository and large files:
For a fresh clone:
git clone https://github.com/Freddsle/fedRBE.git
cd fedRBE
git lfs pull
For an existing clone:
cd fedRBE
git pull
git lfs pull
Set up Python and R dependencies:
Choose one of the following setup paths.
Option A: Conda or Mamba environment
The Conda environment installs Python 3.11, R, the CRAN and Bioconductor packages used by the notebooks, and the FeatureCloud Python package:
conda env create -f environment.yml
conda activate fedRBE
Mamba can use the same environment.yml. The file pins
conda-forge::openblas=0.3.3 to avoid pthread_create() failures in
affy::rma() on conda environments.
If the older OpenBLAS build cannot be resolved for your platform or channel
setup, use the preprocessCore source-install command from Option B after
activating this conda environment.
Install the GitHub-only R dependency:
Rscript -e 'remotes::install_github("mwgrassgreen/RobNorm")'
Option B: Separate Python and R installations
Set up Python dependencies:
python3 -m venv fedrbe_env
source fedrbe_env/bin/activate # on Windows: fedrbe_env\Scripts\activate
pip install -r requirements.txt
requirements_r.txt lists CRAN, Bioconductor, and GitHub dependencies in
separate sections. Install them with:
Rscript -e 'install.packages(c("data.table","ggpubr","gridExtra","ggsci","ggtext","glue","IRkernel","invgamma","jsonlite","knitr","nipals","patchwork","pheatmap","remotes","reshape2","scales","tidyverse","umap","viridis"), repos="https://cloud.r-project.org")'
Rscript -e 'if (!requireNamespace("BiocManager", quietly=TRUE)) install.packages("BiocManager", repos="https://cloud.r-project.org"); BiocManager::install(c("AnnotationDbi","affy","GEOquery","GO.db","hgu133acdf","hgu133plus2cdf","impute","limma","variancePartition"), ask=FALSE, update=FALSE)'
Rscript -e 'BiocManager::install("preprocessCore", configure.args=c(preprocessCore="--disable-threading"), type="source", force=TRUE, ask=FALSE, update=FALSE)'
Rscript -e 'install.packages("WGCNA", repos="https://cloud.r-project.org")'
Rscript -e 'if (!requireNamespace("remotes", quietly=TRUE)) install.packages("remotes", repos="https://cloud.r-project.org"); remotes::install_github("mwgrassgreen/RobNorm")'
This section guides you through running both federated and centralized batch effect corrections and comparing their results. Any step can be skipped because the corresponding outputs are already committed in the repository.
Recommended order:
before/ inputs and central limma outputs, see 1. Preparing inputs and obtaining centrally corrected data.before/ inputs, or use the fedRBE outputs already committed in evaluation_data/*/after/, see 2. Obtaining federated corrected data.Prepare the per-dataset before/ inputs and perform centralized batch effect correction using limma’s removeBatchEffect for comparison.
Run the dataset preparation and central-correction notebooks from their own directories, or set the notebook working directory to the listed folder so relative paths resolve correctly.
| Dataset | Run order |
|---|---|
| Simulated | evaluation_data/simulated/01_data_prep_and_central_RBE.ipynb |
| E. coli | evaluation_data/ecoli/01_data_prep_and_central_RBE.ipynb |
| Ovarian cancer | evaluation_data/ovarian_cancer/00_harmonize_meta_load_data.ipynb (run time ~30 minutes), then evaluation_data/ovarian_cancer/02_central_RBE.ipynb |
| ccRCC proteomics | python evaluation_data/ccRCC_studies/prepare_ccRCC_data.py, then evaluation_data/ccRCC_studies/01_central_RBE.ipynb |
| Quartet multiomics | evaluation_data/quartet_multiomics/01_preprocess_eda.ipynb, evaluation_data/quartet_multiomics/02_prepare_RBE_inputs.ipynb, then evaluation_data/quartet_multiomics/03_central_RBE.ipynb |
For simulated datasets, if all 30 runs were not re-generated, the
evaluation_data/simulated/01_data_prep_and_central_RBE.ipynbnotebook will only run the single-run central correction for the committed inputs. If you want to run the full 30-run evaluation, first generate thebefore/intermediate/andafter/runs/files viaevaluation_data/simulated/00_data_simulation.ipynb, which will take 1-2 hours, then re-run the notebook.
Output:
evaluation_data/[dataset]/before/ for each dataset.evaluation_data/[dataset]/after/ for each dataset.evaluation_data/<dataset>/README.md files.Note: The preprocessing and centralized correction notebooks have already been run for the committed outputs. You can skip this step when using the provided inputs and corrected data.
For simulated data, committed run-1 inputs support a quick check. The full 30-run evaluation requires generated before/intermediate/ and after/runs/ files via evaluation_data/simulated/00_data_simulation.ipynb.
Use the provided utility script to perform the configured federated batch
effect correction experiments from the prepared evaluation_data/[dataset]/before/
inputs. Edit the experiment list in the script to enable or disable any of the
datasets; currently all datasets are enabled by default.
python3 ./generate_fedrbe_corrected_datasets.py
Steps Performed by the Script:
evaluation_data/[dataset]/before/.evaluation_data/[dataset]/after/ for each dataset.Output:
evaluation_data/[dataset]/after/individual_results/. The merged client data is also written directly to evaluation_data/[dataset]/after/ as FedApp_corrected_data.tsv, or FedApp_corrected_data_smpc.tsv when SMPC is used.evaluation_data/[dataset]/after/individual_results/, detailed logs and correction reports can be found.Notes:
experiments.append(ovarian_cancer_experiment) block in generate_fedrbe_corrected_datasets.py.Customization:
## ADD EXPERIMENTS, CHANGE HERE TO INCLUDE/EXCLUDE EXPERIMENTS in generate_fedrbe_corrected_datasets.py.evaluation_data/[dataset]/before/ entries following the existing structure.evaluation_data/quartet_multiomics/02_prepare_RBE_inputs.ipynb; run that notebook before the federated correction script if those folders were regenerated or removed.For simulated data, the script checks that before/lab*/ inputs still match run 1 before writing the single-run FedApp_corrected_data*.tsv files used by analyse_fedvscentral.py.
Use the provided script to analyze and compare the results of federated and centralized batch effect corrections.
python3 ./analyse_fedvscentral.py
What this does:
Output:
fed_vc_cent_results.tsv in the evaluation_data/ directory.To reproduce the tables and figures from the preprint, run the provided Jupyter notebooks in the evaluation/ directory:
evaluation/evaluation_simulated.ipynbevaluation/evaluation_simulated_30runs.ipynb (may take several hours to run if all 30 runs are generated)evaluation/evaluation_ecoli.ipynbevaluation/evaluation_ovarian_cancer.ipynbevaluation/evaluation_ccRCC.ipynbevaluation/evaluation_quartet_multiomics.ipynbThese notebooks expect the corrected data from Steps 1 and 2. evaluation_simulated_30runs.ipynb can use the committed precomputed 30-run LMPV summary cache for the final variance-partitioning plots; full recalculation still requires the generated simulated before/intermediate/ and after/runs/ files. Figures are written under evaluation/plots/ and related evaluation output folders.
First run the classification experiments. This can take several hours; the repository already contains the generated results.
The classification experiments are split into the two different experiment types:
python3 evaluation_classification_after_correction/run_classification_train_test_split.py
python3 evaluation_classification_after_correction/run_classification_leave_one_cohort_out.py
The experiment results are saved in evaluation_classification_after_correction/results.
To visualize the experiments with plots, run the corresponding analysis script:
python3 evaluation_classification_after_correction/analyse_classification_metric_report.py
The resulting plots can be found in evaluation_classification_after_correction/plots.
You can also use the helper shell scripts:
run_all_classification_analysis.sh: runs all three scripts sequentially; this can take several hours.run_all_classification_analysis_tmux.sh: runs the same script in a tmux session so the terminal can disconnect safely. Logs are stored as classification_analysis_{TIMESTAMP}.log.Note: If you want to inspect the RandomForest logic, this is located in evaluation_classification_after_correction/fc_fed_forest_simple_app.
To reproduce the clustering results from the preprint, run the real-dataset clustering notebooks under evaluation_clusterization_after_correction/.
R and Python3 environments set up with the required dependencies as described in the Prerequisites and setup section.cd evaluation_clusterization_after_correction/federated_kmeans_upd/
./build.sh
Run the notebooks in evaluation_clusterization_after_correction/real_datasets/:
00_build_kmeans_matrices.ipynb — required only for Quartet multiomics.01_data_preparation.ipynb02_central_kmeans.ipynb03_federated_runs.ipynb — optional; required only when regenerating federated k-means outputs.04_analysis_metrics_plots.ipynb05_multiple_runs.ipynb — optional repeated seeded federated runs.See evaluation_clusterization_after_correction/real_datasets/README.md for detailed options and output paths.
Note: If you want to inspect the FedKMeans logic, this is located in evaluation_clusterization_after_correction/federated_kmeans_upd.
Understanding the repository layout helps in navigating the files and scripts.
fedRBE/
├── README.md # General repository overview
├── batchcorrection/ # fedRBE FeatureCloud app
├── evaluation_data/ # Data used for evaluation
│ ├── ccRCC_studies/ # ccRCC proteomics datasets
│ ├── ecoli/ # E. coli dataset
│ ├── ovarian_cancer/ # Ovarian cancer datasets
│ │ ├── before/ # Uncorrected data with structure needed to run the app
│ │ ├── after/ # Corrected data
│ │ ├── 00_harmonize_meta_load_data.ipynb # Data harmonization notebook
│ │ ├── 01_check_datasets_intersection.ipynb
│ │ └── 02_central_RBE.ipynb # Centralized removeBatchEffect run
│ ├── quartet_multiomics/ # Quartet multiomics datasets
│ └── simulated/ # Simulated datasets
├── analyse_fedvscentral.py # Compares federated and centralized batch effect corrections.
├── generate_fedrbe_corrected_datasets.py # Runs fedRBE on all configured datasets and saves results
├── run_sample_experiment.py # Runs fedRBE on the sample dataset
├── evaluation_utils/ # Utility scripts for evaluations
│ ├── evaluation_funcs.R
│ ├── featurecloud_api_extension.py
│ ├── fedRBE_simulation_scrip_simdata.py
│ ├── filtering.R
│ ├── plots_eda.R
│ ├── simulation_func.R
│ ├── upset_plot.py
│ └── utils_analyse.py
├── evaluation/ # Main evaluation scripts to produce results and figures
│ ├── eval_simulation/ # Evaluations on simulated data
│ ├── evaluation_ccRCC.ipynb
│ ├── evaluation_ecoli.ipynb
│ ├── evaluation_ovarian_cancer.ipynb # Evaluation of ovarian_cancer datasets
│ ├── evaluation_quartet_multiomics.ipynb
│ ├── evaluation_simulated.ipynb
│ ├── evaluation_simulated_30runs.ipynb
├── evaluation_classification_after_correction/ # Classification comparison scripts and outputs
├── evaluation_clusterization_after_correction/ # K-means comparison notebooks and FeatureCloud app
└── [other directories/files]
Main scripts live at the repository root; shared helpers live in evaluation_utils/.
| File | Purpose |
|---|---|
generate_fedrbe_corrected_datasets.py |
Runs configured fedRBE experiments, assigns client inputs, executes the app, and stores corrected outputs. |
analyse_fedvscentral.py |
Loads federated and central corrected datasets, checks shape/index consistency, and writes mean/max difference metrics. |
evaluation_utils/featurecloud_api_extension.py |
Wraps the FeatureCloud testbed with automatic restart and result-extraction helpers used by the fedRBE correction script. |
evaluation_utils/filtering.R |
Provides filtering and preprocessing functions used before centralized limma correction. |
evaluation_utils/plots_eda.R |
Provides boxplot, PCA, UMAP, heatmap, and correction-diagnostic plotting helpers. |
evaluation_utils/upset_plot.py |
Creates UpSet plots for feature-overlap comparisons. |
Common checks:
evaluation_data/[dataset]/before/.For unresolved issues, open a GitHub issue.
For questions, issues, or support, open a GitHub issue.