FedscGen is a federated learning framework for privacy-aware batch effect correction in single-cell RNA sequencing (scRNA-seq) data. It enables multiple institutions to collaboratively train a shared variational autoencoder (VAE) model without exchanging raw data. Each site trains a local model and securely shares only model parameters with a central coordinator, which aggregates them to update the global model. After training, the shared model is used to extract latent representations of cells across sites. For each shared cell type, dominant batches are identified, and corresponding mean latent features are calculated and aggregated in a privacy-preserving manner. These latent shifts are then used to locally correct batch effects, allowing new or existing clients to harmonize their datasets while maintaining full control over their data.
To reproduce the results of the paper, please follow the instructions to create two Conda environments:
fedscgen: Python environment for FedscGen.r_eval: R + Python environment for benchmarking.
conda env create -f environment.yml
conda activate fedscgen
export SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True
pip install crypten==0.4.1conda env create -f r_eval.yml
conda activate r_eval
Rscript install_libraries.RFor reproducibility, please ensure the preprocessed datasets are downloaded and extracted to the data/datasets directory. Optionally, the initial models can also be downloaded to the models/ directory.
All models are initialized using a fixed seed for reproducibility.
Navigate to the experiments/ directory and run experiments.sh
while providing a comma-separated list of GPU indices to use for training. For example, to use GPUs 0 and 1:
conda activate fedscgen
cd experiments
chmod +x experiment.sh
./experiment.sh 0,1Once the experiments are complete, run the evaluation metrics by navigating to the metrics/ directory and executing evaluate.sh:
conda activate r_eval
cd metrics
chmod +x evaluation.sh
./evaluation.shAll results will be saved in the results/ directory. Both scripts will automatically fully utilize the available system resources.
FedscGen is implemented for real-world federated collaboration as a FeatureCloud app with automated deployment.
- Explore the app: FedscGen App on FeatureCloud
- Source code: fc-fedscgen GitHub Repository
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
