fedgwas-sim CLI
fedgwas-sim is the command line interface for creating and running local
FedGWAS simulation projects. It is the recommended entry point for users who
install FedGWAS from PyPI and want to run examples outside the repository
checkout.
Install the package and confirm that the command is available:
python -m pip install FedGWAS
fedgwas-sim --help
The CLI manages a study directory, writes Flower project files, prepares or
verifies data, launches flwr run . local-simulation, and collects or evaluates
outputs after the run.
Quickstart
The recommended workflow starts from a user-owned study directory:
mkdir my_study
cd my_study
fedgwas-sim init
fedgwas-sim setup-experiment syn-tiny --seed 42
fedgwas-sim check
fedgwas-sim run --rounds 100
fedgwas-sim baseline generate --output data/centralized_baseline
fedgwas-sim evaluate results --baseline data/centralized_baseline --king
fedgwas-sim results collect --label tiny_run
The legacy one-command project creation flow remains supported:
fedgwas-sim setup-experiment syn-tiny --out tiny-study
Command Reference
| Command | Purpose | Common options |
|---|---|---|
fedgwas-sim init | Create the base project layout in the current directory. | --from-example, --force, --prepare-data/--no-prepare-data, --seed |
fedgwas-sim setup-experiment <preset> | Configure a runnable synthetic or real-world preset. | --out, --force, --seed, --download/--no-download |
fedgwas-sim prepare-data | Generate missing synthetic data or run the generated real-world preparation script. | --download |
fedgwas-sim check | Run readiness checks before a simulation. | --project, --software, --configs, --data, --outputs |
fedgwas-sim run | Launch the local Flower simulation after readiness checks pass. | --rounds, --stream/--no-stream |
fedgwas-sim baseline generate | Generate a centralized baseline for later comparison. | --output |
fedgwas-sim evaluate [results_dir] | Compare federated outputs with centralized baseline outputs. | --baseline, --report, --no-plots, --king, --qc-only, --lr-only, --king-only |
fedgwas-sim results collect | Collect run metadata and timing summaries. | --time-file, --label, --output-dir |
fedgwas-sim summarize data | Inspect prepared data under a data directory. | --path |
fedgwas-sim summarize experiment | Inspect simulation project metadata and readiness signals. | --path |
fedgwas-sim data configure | Point a center config at a user-supplied PLINK prefix. | --center, --bfile |
fedgwas-sim reset / clear | Remove CLI-managed generated files from a simulation project. | --yes, --keep-data, --keep-configs, --keep-results |
Local Development Testing
Use this section when testing the CLI from a local repository checkout before publishing or installing a built wheel.
From the repository root, create or activate a Python environment, then install FedGWAS in editable mode:
cd D:/min/research_projects/FedGWAS_pipeline
source .venv/Scripts/activate
uv pip install -e .
On Windows PowerShell, activate the same environment with:
.\.venv\Scripts\Activate.ps1
Confirm that the console scripts are available:
fedgwas-sim --help
Run a minimal local smoke test in a temporary project directory:
mkdir local_cli_smoke
cd local_cli_smoke
fedgwas-sim init
fedgwas-sim setup-experiment syn-tiny --seed 42
fedgwas-sim check
fedgwas-sim summarize experiment --path .
fedgwas-sim summarize data --path data
fedgwas-sim run performs the same readiness checks as fedgwas-sim check
before launching Flower. If any project, software, config, data, or output check
fails, it prints the Rich check report and exits without starting the
simulation:
fedgwas-sim run --rounds 5 --no-stream
After testing, reset the project back to the initialized state or delete the temporary directory:
fedgwas-sim reset --yes
cd ..
For automated regression tests from the repository root:
pytest tests/test_cli_sim.py -q
pytest tests/test_synthetic_data.py tests/test_monitoring_config.py tests/test_run_retention.py -q
For a syntax/import smoke check:
$files = @("pipeline\cli\sim.py") + (Get-ChildItem pipeline\cli\simulation\*.py | ForEach-Object { $_.FullName })
python -m py_compile @files
Project Initialization
fedgwas-sim init creates the base project structure in the current directory.
It does not choose an experiment preset or generate data.
mkdir my_study
cd my_study
fedgwas-sim init
Initial structure:
my_study/
fedgwas.yaml
pyproject.toml
config.yaml
configs/
data/
results/
logs/
fedgwas.yaml stores CLI project settings such as mode: simulation,
config_dir, data_dir, results_dir, and PLINK discovery settings.
pyproject.toml contains the minimal Flower app wiring:
[tool.flwr.app.components]
serverapp = "pipeline.server_app:app"
clientapp = "pipeline.client_app:app"
[tool.flwr.federations]
default = "local-simulation"
Built-In Examples
Use init --from-example to initialize a project from a packaged example
template that mirrors the repository experiments with project-relative paths.
By default, examples also prepare their configured data so the project can move
directly to check and run:
fedgwas-sim init --from-example tiny-even
fedgwas-sim init --from-example small-even
fedgwas-sim init --from-example medium-even
fedgwas-sim init --from-example 1000genomes
Use --no-prepare-data when working offline, avoiding large downloads, or only
inspecting the generated YAML/TOML files:
fedgwas-sim init --from-example tiny-even --no-prepare-data
fedgwas-sim init --from-example 1000genomes --no-prepare-data
Synthetic examples accept --seed for reproducible generated data:
fedgwas-sim init --from-example tiny-even --seed 42
Supported examples:
| Example | Repository reference | Purpose |
|---|---|---|
tiny-even | experiments/correctness/tiny_even | Small correctness experiment. |
small-even | experiments/performance/small_even | Small performance benchmark. |
medium-even | experiments/performance/medium_even | Medium performance benchmark. |
1000genomes | experiments/real_world/1000genomes | 1000 Genomes chr22 application experiment. |
Example initialization writes config.yaml, configs/server.yaml, and
configs/center_*.yaml using the same key experiment settings as the repository
example. Paths are normalized to the local project layout. Synthetic examples
generate PLINK triplets under data/center_*. The 1000genomes example
downloads chromosome 22 inputs, converts them to PLINK, assigns binary
phenotypes, and partitions samples into two center datasets.
Setup Experiment
fedgwas-sim setup-experiment <preset> configures the current project for a
named preset. If the current directory is not initialized, the command creates
the standard project files as part of setup.
fedgwas-sim setup-experiment syn-tiny
fedgwas-sim setup-experiment syn-small --seed 42
fedgwas-sim setup-experiment syn-medium
fedgwas-sim setup-experiment 1000genomes-chr22
fedgwas-sim setup-experiment hapmap
Synthetic presets generate PLINK data automatically. After:
fedgwas-sim setup-experiment syn-tiny
the project has a runnable structure:
my_study/
fedgwas.yaml
pyproject.toml
config.yaml
configs/
server.yaml
center_1.yaml
center_2.yaml
data/
center_1/
tiny_center_1.bed
tiny_center_1.bim
tiny_center_1.fam
center_2/
tiny_center_2.bed
tiny_center_2.bim
tiny_center_2.fam
results/
center_1/
intermediate/
logs/
center_2/
intermediate/
logs/
server/
intermediate/
logs/
logs/
Real-world presets default to running their data preparation adapter. Use
--no-download to generate only configuration and preparation scripts:
fedgwas-sim setup-experiment hapmap --no-download
fedgwas-sim setup-experiment 1000genomes-chr22 --no-download
Data Preparation
fedgwas-sim prepare-data is data-focused. It can regenerate missing synthetic
data for synthetic presets or run the generated preparation script for
real-world presets.
fedgwas-sim prepare-data
fedgwas-sim prepare-data --download
For user-supplied data, center configs should point to PLINK prefixes without file extensions:
input_data:
path: data/center_1/study_center_1
type: bed
Checks
fedgwas-sim check is the unified readiness command. It checks:
fedgwas.yamlexists and declaresmode: simulation.- Python, FedGWAS, Flower, and PLINK are available.
- Center and server configs exist.
- Configured center PLINK triplets exist.
- Results and logs directories are writable.
Run all checks:
fedgwas-sim check
Run only selected categories:
fedgwas-sim check --project
fedgwas-sim check --software
fedgwas-sim check --configs
fedgwas-sim check --data
fedgwas-sim check --outputs
fedgwas-sim check --configs --data
Use check --data for data verification. The data configuration command remains
available for pointing a center config at a user-supplied PLINK prefix:
fedgwas-sim check --data
fedgwas-sim data configure --center 1 --bfile data/center_1/study_center_1
Summaries
Use summarize commands to inspect prepared data or project metadata:
fedgwas-sim summarize data --path data
fedgwas-sim summarize experiment --path .
The output is a Rich terminal report. The data summary reports path existence, center count, file count, PLINK triplet count, human-readable size, and a per-center table:
Data Summary
Path my_study/data
Exists yes
Centers 2
Files 6
PLINK triplets 2
Size 78 B
Centers
Center Files PLINK triplets Size
center_1 3 1 39 B
center_2 3 1 39 B
The experiment summary reports preset/example metadata, scenario, client count, key directories, and readiness signals:
Experiment Summary
Path my_study
Mode simulation
State configured
Preset syn-tiny
Example None
Experiment tiny_even
Category correctness
Scenario correctness_tiny
Clients 2
Project Readiness
Area Detail Status
Configs my_study/configs 2 center config(s)
Data my_study/data 2 PLINK triplets
Results my_study/results exists
Reset A Project
fedgwas-sim reset restores the current simulation project to the same base
state created by fedgwas-sim init.
fedgwas-sim reset
fedgwas-sim reset --yes
fedgwas-sim clear --yes
The command only runs inside a directory with fedgwas.yaml and
mode: simulation. By default it asks for confirmation; use --yes in scripts
or tests.
Reset removes only CLI-managed paths:
config.yaml
pyproject.toml
configs/
data/
results/
logs/
scripts/
Unknown user files such as README.md, notes, notebooks, and custom scripts are
left untouched. Use keep flags for large or hand-managed artifacts:
fedgwas-sim reset --keep-data --yes
fedgwas-sim reset --keep-configs --yes
fedgwas-sim reset --keep-results --yes
Run, Evaluate, And Collect Results
Run the local Flower simulation. The command first runs all readiness checks and only starts Flower when every check passes:
fedgwas-sim run --rounds 50
fedgwas-sim run --rounds 100 --no-stream
Generate a centralized comparison baseline when needed:
fedgwas-sim baseline generate
fedgwas-sim baseline generate --output results/baseline
Evaluate federated outputs against a centralized baseline. This command delegates
to the same core evaluator as python -m pipeline.evaluation.evaluate_all:
fedgwas-sim evaluate
fedgwas-sim evaluate --baseline results/baseline --king
fedgwas-sim evaluate results --baseline results/baseline --qc-only
fedgwas-sim evaluate results --baseline results/baseline --lr-only --no-plots
fedgwas-sim evaluate results --baseline results/baseline --king-only --king-center-id 1
By default, evaluate uses the configured project results_dir, reads the
baseline from results/baseline, writes evaluation_report.md, and runs QC +
LR evaluation. Add --king to include KING accumulator comparison, or use one
of --qc-only, --lr-only, or --king-only for a single stage.
Collect run metadata and timing files:
fedgwas-sim results collect
fedgwas-sim results collect --time-file results/server_app_time.txt --label tiny_run
Packaging Notes
PyPI users should not need a repository checkout. Built-in examples are packaged
inside pipeline.cli.simulation, and generated configs use project-relative
paths rather than experiments/... paths.
The simulation CLI entry point is:
fedgwas-sim # local multi-client simulation mode