genopick 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- genopick-0.3.0/LICENSE +21 -0
- genopick-0.3.0/PKG-INFO +225 -0
- genopick-0.3.0/README.md +198 -0
- genopick-0.3.0/pyproject.toml +59 -0
- genopick-0.3.0/setup.cfg +4 -0
- genopick-0.3.0/src/genopick/__init__.py +3 -0
- genopick-0.3.0/src/genopick/cli.py +230 -0
- genopick-0.3.0/src/genopick/crossval.py +177 -0
- genopick-0.3.0/src/genopick/data/example_geno.csv +401 -0
- genopick-0.3.0/src/genopick/data/example_pheno.csv +401 -0
- genopick-0.3.0/src/genopick/io.py +259 -0
- genopick-0.3.0/src/genopick/metrics.py +56 -0
- genopick-0.3.0/src/genopick/models/__init__.py +104 -0
- genopick-0.3.0/src/genopick/models/_reml.py +122 -0
- genopick-0.3.0/src/genopick/models/base.py +26 -0
- genopick-0.3.0/src/genopick/models/bayesian.py +84 -0
- genopick-0.3.0/src/genopick/models/ensemble.py +103 -0
- genopick-0.3.0/src/genopick/models/gblup.py +57 -0
- genopick-0.3.0/src/genopick/models/rkhs.py +88 -0
- genopick-0.3.0/src/genopick/preprocess.py +121 -0
- genopick-0.3.0/src/genopick/report.py +218 -0
- genopick-0.3.0/src/genopick/templates/report.html +104 -0
- genopick-0.3.0/src/genopick.egg-info/PKG-INFO +225 -0
- genopick-0.3.0/src/genopick.egg-info/SOURCES.txt +36 -0
- genopick-0.3.0/src/genopick.egg-info/dependency_links.txt +1 -0
- genopick-0.3.0/src/genopick.egg-info/entry_points.txt +3 -0
- genopick-0.3.0/src/genopick.egg-info/requires.txt +16 -0
- genopick-0.3.0/src/genopick.egg-info/top_level.txt +1 -0
- genopick-0.3.0/tests/test_cli.py +352 -0
- genopick-0.3.0/tests/test_crossval.py +224 -0
- genopick-0.3.0/tests/test_docs.py +31 -0
- genopick-0.3.0/tests/test_example_data.py +43 -0
- genopick-0.3.0/tests/test_io.py +245 -0
- genopick-0.3.0/tests/test_legacy_gsbench.py +65 -0
- genopick-0.3.0/tests/test_metrics.py +62 -0
- genopick-0.3.0/tests/test_models.py +408 -0
- genopick-0.3.0/tests/test_preprocess.py +145 -0
- genopick-0.3.0/tests/test_report.py +135 -0
genopick-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Joash Joshua Ayo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
genopick-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: genopick
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Genomic Selection Model Benchmarking CLI for Plant Breeding
|
|
5
|
+
Author: Joash Joshua Ayo
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/josh45-source/genopick
|
|
8
|
+
Project-URL: Issues, https://github.com/josh45-source/genopick/issues
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: numpy
|
|
13
|
+
Requires-Dist: pandas
|
|
14
|
+
Requires-Dist: scikit-learn
|
|
15
|
+
Requires-Dist: typer
|
|
16
|
+
Requires-Dist: rich
|
|
17
|
+
Requires-Dist: matplotlib>=3.9
|
|
18
|
+
Requires-Dist: jinja2
|
|
19
|
+
Provides-Extra: full
|
|
20
|
+
Requires-Dist: xgboost; extra == "full"
|
|
21
|
+
Requires-Dist: lightgbm; extra == "full"
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest; extra == "dev"
|
|
24
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
25
|
+
Requires-Dist: ruff<0.18,>=0.16; extra == "dev"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# genopick
|
|
29
|
+
|
|
30
|
+
**Genomic Selection Model Benchmarking CLI for Plant Breeding**
|
|
31
|
+
|
|
32
|
+
[](https://github.com/josh45-source/genopick/actions/workflows/tests.yaml)
|
|
33
|
+
[](https://www.python.org/downloads/)
|
|
34
|
+
[](https://opensource.org/licenses/MIT)
|
|
35
|
+
|
|
36
|
+
genopick cross-validates genomic selection models on your genotype/phenotype
|
|
37
|
+
data and produces a comparison report with prediction accuracy, bias
|
|
38
|
+
diagnostics, and plots from a single command.
|
|
39
|
+
|
|
40
|
+
> genopick was called **gsbench** until 0.3.0. See the
|
|
41
|
+
> [CHANGELOG](https://github.com/josh45-source/genopick/blob/main/CHANGELOG.md)
|
|
42
|
+
> for how to migrate.
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install genopick
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
With gradient-boosting models (XGBoost, LightGBM):
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install genopick[full]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
From source, for development:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
git clone https://github.com/josh45-source/genopick.git
|
|
60
|
+
cd genopick
|
|
61
|
+
pip install -e ".[dev]"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
genopick ships with a simulated example dataset so you can try it immediately:
|
|
67
|
+
400 breeding lines x 2000 SNPs with realistic linkage disequilibrium, and two
|
|
68
|
+
traits: `yield` (polygenic, h2 = 0.5) and `height` (a few moderate-effect QTL
|
|
69
|
+
plus a polygenic background, h2 = 0.6). It is generated by
|
|
70
|
+
[`scripts/simulate_example_data.py`](https://github.com/josh45-source/genopick/blob/main/scripts/simulate_example_data.py) with a
|
|
71
|
+
fixed seed.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Copy the example genotype/phenotype files to the current directory
|
|
75
|
+
genopick example
|
|
76
|
+
|
|
77
|
+
# Benchmark models on the example data
|
|
78
|
+
genopick run example_geno.csv example_pheno.csv --trait yield --models GBLUP,RKHS,RF --folds 5
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
This writes `genopick_output/report.html` with the full comparison report,
|
|
82
|
+
`genopick_output/summary.csv`, and diagnostic plots under
|
|
83
|
+
`genopick_output/plots/`.
|
|
84
|
+
|
|
85
|
+
To try genopick on real data, follow the
|
|
86
|
+
[real-data tutorial](https://github.com/josh45-source/genopick/blob/main/docs/tutorial-real-data.md): it downloads and converts
|
|
87
|
+
the public CIMMYT wheat dataset (599 lines, 1279 DArT markers) from the BGLR
|
|
88
|
+
R package.
|
|
89
|
+
|
|
90
|
+
## CLI Reference
|
|
91
|
+
|
|
92
|
+
### `genopick run`
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
genopick run GENO PHENO --trait TRAIT [OPTIONS]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
| Argument / Option | Default | Description |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| `GENO` | — | Path to the genotype file (CSV/TSV, HapMap, or numeric matrix; format auto-detected). A numeric matrix has no sample IDs, so its rows are matched to the phenotype rows by order and the sample counts must be equal |
|
|
101
|
+
| `PHENO` | — | Path to the phenotype file (CSV/TSV, first column = sample IDs) |
|
|
102
|
+
| `--trait` | — | Phenotype column to benchmark against (required) |
|
|
103
|
+
| `--models` | `all` | `all`, or a comma-separated list of abbreviations, e.g. `GBLUP,RKHS,RF` |
|
|
104
|
+
| `--folds` | `5` | Number of cross-validation folds |
|
|
105
|
+
| `--repeats` | `1` | Number of times to repeat k-fold CV (uses `RepeatedKFold` when > 1) |
|
|
106
|
+
| `--maf` | `0.05` | Minimum minor allele frequency; markers below this are dropped |
|
|
107
|
+
| `--max-missing` | `0.2` | Maximum per-marker missingness fraction before a marker is dropped |
|
|
108
|
+
| `--impute` | `mean` | Missing-genotype imputation: `mean` or `median` |
|
|
109
|
+
| `--scale` | `center` | Genotype scaling: `center`, `standardize`, or `none` |
|
|
110
|
+
| `--output` | `genopick_output` | Output directory for the report, summary CSV, and plots |
|
|
111
|
+
| `--seed` | `42` | Random seed for cross-validation splits |
|
|
112
|
+
| `--format` | `auto` | Genotype format override: `auto`, `csv`, `tsv`, `hapmap`, `numeric` |
|
|
113
|
+
|
|
114
|
+
> **Note:** marker filtering (`--maf`, `--max-missing`), imputation and
|
|
115
|
+
> scaling are applied once to the full dataset before cross-validation, so
|
|
116
|
+
> test-fold samples contribute to allele frequencies, imputation values and
|
|
117
|
+
> marker means. This is common practice in genomic selection and the effect
|
|
118
|
+
> is usually small, but accuracies can be slightly optimistic, especially
|
|
119
|
+
> on small datasets.
|
|
120
|
+
|
|
121
|
+
### `genopick list-models`
|
|
122
|
+
|
|
123
|
+
Prints a table of all registered models and whether their dependencies are
|
|
124
|
+
installed.
|
|
125
|
+
|
|
126
|
+
### `genopick example`
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
genopick example [--output DIR]
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Copies the bundled example genotype/phenotype CSVs into `DIR` (defaults to
|
|
133
|
+
the current directory) and prints the `genopick run` command to benchmark
|
|
134
|
+
them.
|
|
135
|
+
|
|
136
|
+
## Models
|
|
137
|
+
|
|
138
|
+
| Abbreviation | Model | Notes |
|
|
139
|
+
|---|---|---|
|
|
140
|
+
| GBLUP | Genomic BLUP | BLUP with the genomic relationship matrix `G = ZZ'/p`; shrinkage (variance ratio) estimated by REML on each training fold |
|
|
141
|
+
| BL | Bayesian ARD (sparse) | **Experimental: tends to overfit** (slope < 1, negative r2 on the example data). `sklearn.linear_model.ARDRegression`: sparse Bayesian regression with a per-marker prior precision (automatic relevance determination). Not a Bayesian LASSO; the `BL` abbreviation is kept for compatibility |
|
|
142
|
+
| RKHS | RKHS (Gaussian Kernel) | Kernel BLUP with an RBF kernel; bandwidth and shrinkage chosen by REML on each training fold |
|
|
143
|
+
| RF | Random Forest | `sklearn.ensemble.RandomForestRegressor` (500 trees) |
|
|
144
|
+
| XGB | XGBoost | Requires `pip install genopick[full]` |
|
|
145
|
+
| LGBM | LightGBM | Requires `pip install genopick[full]` |
|
|
146
|
+
|
|
147
|
+
`BRR` is an alias for `GBLUP` (the same model, identical predictions): `--models BRR` runs GBLUP.
|
|
148
|
+
|
|
149
|
+
Every model implements the same two-method interface (`fit` / `predict`), so
|
|
150
|
+
adding a new one is a matter of subclassing `genopick.models.base.GSModel`.
|
|
151
|
+
|
|
152
|
+
## Metrics
|
|
153
|
+
|
|
154
|
+
Each fold reports `r` (Pearson correlation), `r2`, `rmse`, `mae`, `bias`,
|
|
155
|
+
`slope` (regression of observed on predicted should be ~1), `spearman`
|
|
156
|
+
(rank correlation), and `nrmse`. Breeders care most about **r** (prediction
|
|
157
|
+
accuracy) and **spearman** (does the model rank genotypes correctly for
|
|
158
|
+
selection?).
|
|
159
|
+
|
|
160
|
+
## Example Output
|
|
161
|
+
|
|
162
|
+
Results on the bundled example data, trait `yield`:
|
|
163
|
+
|
|
164
|
+
<!-- example-results:start (generated by scripts/update_docs_example.py; do not edit) -->
|
|
165
|
+
|
|
166
|
+
`genopick run example_geno.csv example_pheno.csv --trait yield --models all --folds 5 --seed 42` (means over the 5 folds; times depend on the machine):
|
|
167
|
+
|
|
168
|
+
| Model | r | Spearman | r2 | RMSE | Slope | Bias | Time (s) |
|
|
169
|
+
|---|---:|---:|---:|---:|---:|---:|---:|
|
|
170
|
+
| GBLUP | 0.466 | 0.442 | 0.186 | 0.799 | 1.02 | -0.006 | 0.1 |
|
|
171
|
+
| BL | 0.376 | 0.351 | -0.373 | 1.038 | 0.35 | -0.014 | 19.0 |
|
|
172
|
+
| RKHS | 0.463 | 0.437 | 0.182 | 0.801 | 1.02 | -0.005 | 0.7 |
|
|
173
|
+
| RF | 0.303 | 0.285 | 0.042 | 0.867 | 1.43 | 0.013 | 26.4 |
|
|
174
|
+
| XGB | 0.234 | 0.217 | -0.045 | 0.905 | 0.50 | 0.040 | 0.8 |
|
|
175
|
+
| LGBM | 0.313 | 0.287 | 0.037 | 0.869 | 0.69 | 0.046 | 0.9 |
|
|
176
|
+
|
|
177
|
+
<!-- example-results:end -->
|
|
178
|
+
|
|
179
|
+
Model comparison (mean r per model; error bars are ±1 SD across folds):
|
|
180
|
+
|
|
181
|
+

|
|
182
|
+
|
|
183
|
+
Predicted vs. observed phenotypes per model:
|
|
184
|
+
|
|
185
|
+

|
|
186
|
+
|
|
187
|
+
The full HTML report also includes a boxplot of per-fold accuracy (each fold
|
|
188
|
+
drawn as a dot), a calibration (slope) plot, a runtime comparison, and
|
|
189
|
+
per-model detail tables. Every plot has a one-line explanation.
|
|
190
|
+
|
|
191
|
+
## Reading the results
|
|
192
|
+
|
|
193
|
+
All metrics compare out-of-fold predictions with observed phenotypes and are
|
|
194
|
+
averaged over folds (and repeats).
|
|
195
|
+
|
|
196
|
+
- **r** (Pearson correlation): the usual "prediction accuracy" in genomic
|
|
197
|
+
selection. It measures how well predictions track the observed values,
|
|
198
|
+
ignoring scale and offset. Its ceiling is about `sqrt(h2)`, because the
|
|
199
|
+
environmental part of a phenotype cannot be predicted from markers.
|
|
200
|
+
- **Spearman**: correlation of ranks. This is what matters when you select
|
|
201
|
+
the top lines; it is usually close to r.
|
|
202
|
+
- **r2**: `1 - SS_residual / SS_total`, the share of phenotypic variance the
|
|
203
|
+
predictions explain **on their own scale**. It is not r squared. It is
|
|
204
|
+
negative when the predictions are worse than predicting the fold mean for
|
|
205
|
+
everyone: typically an over-fitted model whose predictions are too spread
|
|
206
|
+
out, even if r is decent (see BL in the table above).
|
|
207
|
+
- **RMSE**: root mean squared error, in the trait's units. Compare it with
|
|
208
|
+
the phenotypic SD: an RMSE equal to the SD means no useful prediction.
|
|
209
|
+
- **Slope**: slope of the regression of observed on predicted values, a
|
|
210
|
+
calibration check. About 1 is well calibrated. Below 1 means predictions
|
|
211
|
+
are too spread out (over-fitted, too little shrinkage); above 1 means they
|
|
212
|
+
are too compressed (too much shrinkage). For ranking, r matters more than
|
|
213
|
+
the slope.
|
|
214
|
+
- **Bias**: mean predicted minus mean observed. Close to 0 for any model
|
|
215
|
+
with an intercept under random cross-validation.
|
|
216
|
+
|
|
217
|
+
**Small datasets give noisy accuracy.** With a few hundred lines, r varies a
|
|
218
|
+
lot from fold to fold (the error bars above show one SD), so differences of a
|
|
219
|
+
few hundredths between models are usually not meaningful. Use more folds and
|
|
220
|
+
`--repeats`, and look at the per-fold spread in the report before ranking
|
|
221
|
+
models.
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
MIT
|
genopick-0.3.0/README.md
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# genopick
|
|
2
|
+
|
|
3
|
+
**Genomic Selection Model Benchmarking CLI for Plant Breeding**
|
|
4
|
+
|
|
5
|
+
[](https://github.com/josh45-source/genopick/actions/workflows/tests.yaml)
|
|
6
|
+
[](https://www.python.org/downloads/)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
genopick cross-validates genomic selection models on your genotype/phenotype
|
|
10
|
+
data and produces a comparison report with prediction accuracy, bias
|
|
11
|
+
diagnostics, and plots from a single command.
|
|
12
|
+
|
|
13
|
+
> genopick was called **gsbench** until 0.3.0. See the
|
|
14
|
+
> [CHANGELOG](https://github.com/josh45-source/genopick/blob/main/CHANGELOG.md)
|
|
15
|
+
> for how to migrate.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install genopick
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
With gradient-boosting models (XGBoost, LightGBM):
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install genopick[full]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
From source, for development:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
git clone https://github.com/josh45-source/genopick.git
|
|
33
|
+
cd genopick
|
|
34
|
+
pip install -e ".[dev]"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
genopick ships with a simulated example dataset so you can try it immediately:
|
|
40
|
+
400 breeding lines x 2000 SNPs with realistic linkage disequilibrium, and two
|
|
41
|
+
traits: `yield` (polygenic, h2 = 0.5) and `height` (a few moderate-effect QTL
|
|
42
|
+
plus a polygenic background, h2 = 0.6). It is generated by
|
|
43
|
+
[`scripts/simulate_example_data.py`](https://github.com/josh45-source/genopick/blob/main/scripts/simulate_example_data.py) with a
|
|
44
|
+
fixed seed.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Copy the example genotype/phenotype files to the current directory
|
|
48
|
+
genopick example
|
|
49
|
+
|
|
50
|
+
# Benchmark models on the example data
|
|
51
|
+
genopick run example_geno.csv example_pheno.csv --trait yield --models GBLUP,RKHS,RF --folds 5
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This writes `genopick_output/report.html` with the full comparison report,
|
|
55
|
+
`genopick_output/summary.csv`, and diagnostic plots under
|
|
56
|
+
`genopick_output/plots/`.
|
|
57
|
+
|
|
58
|
+
To try genopick on real data, follow the
|
|
59
|
+
[real-data tutorial](https://github.com/josh45-source/genopick/blob/main/docs/tutorial-real-data.md): it downloads and converts
|
|
60
|
+
the public CIMMYT wheat dataset (599 lines, 1279 DArT markers) from the BGLR
|
|
61
|
+
R package.
|
|
62
|
+
|
|
63
|
+
## CLI Reference
|
|
64
|
+
|
|
65
|
+
### `genopick run`
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
genopick run GENO PHENO --trait TRAIT [OPTIONS]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
| Argument / Option | Default | Description |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| `GENO` | — | Path to the genotype file (CSV/TSV, HapMap, or numeric matrix; format auto-detected). A numeric matrix has no sample IDs, so its rows are matched to the phenotype rows by order and the sample counts must be equal |
|
|
74
|
+
| `PHENO` | — | Path to the phenotype file (CSV/TSV, first column = sample IDs) |
|
|
75
|
+
| `--trait` | — | Phenotype column to benchmark against (required) |
|
|
76
|
+
| `--models` | `all` | `all`, or a comma-separated list of abbreviations, e.g. `GBLUP,RKHS,RF` |
|
|
77
|
+
| `--folds` | `5` | Number of cross-validation folds |
|
|
78
|
+
| `--repeats` | `1` | Number of times to repeat k-fold CV (uses `RepeatedKFold` when > 1) |
|
|
79
|
+
| `--maf` | `0.05` | Minimum minor allele frequency; markers below this are dropped |
|
|
80
|
+
| `--max-missing` | `0.2` | Maximum per-marker missingness fraction before a marker is dropped |
|
|
81
|
+
| `--impute` | `mean` | Missing-genotype imputation: `mean` or `median` |
|
|
82
|
+
| `--scale` | `center` | Genotype scaling: `center`, `standardize`, or `none` |
|
|
83
|
+
| `--output` | `genopick_output` | Output directory for the report, summary CSV, and plots |
|
|
84
|
+
| `--seed` | `42` | Random seed for cross-validation splits |
|
|
85
|
+
| `--format` | `auto` | Genotype format override: `auto`, `csv`, `tsv`, `hapmap`, `numeric` |
|
|
86
|
+
|
|
87
|
+
> **Note:** marker filtering (`--maf`, `--max-missing`), imputation and
|
|
88
|
+
> scaling are applied once to the full dataset before cross-validation, so
|
|
89
|
+
> test-fold samples contribute to allele frequencies, imputation values and
|
|
90
|
+
> marker means. This is common practice in genomic selection and the effect
|
|
91
|
+
> is usually small, but accuracies can be slightly optimistic, especially
|
|
92
|
+
> on small datasets.
|
|
93
|
+
|
|
94
|
+
### `genopick list-models`
|
|
95
|
+
|
|
96
|
+
Prints a table of all registered models and whether their dependencies are
|
|
97
|
+
installed.
|
|
98
|
+
|
|
99
|
+
### `genopick example`
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
genopick example [--output DIR]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Copies the bundled example genotype/phenotype CSVs into `DIR` (defaults to
|
|
106
|
+
the current directory) and prints the `genopick run` command to benchmark
|
|
107
|
+
them.
|
|
108
|
+
|
|
109
|
+
## Models
|
|
110
|
+
|
|
111
|
+
| Abbreviation | Model | Notes |
|
|
112
|
+
|---|---|---|
|
|
113
|
+
| GBLUP | Genomic BLUP | BLUP with the genomic relationship matrix `G = ZZ'/p`; shrinkage (variance ratio) estimated by REML on each training fold |
|
|
114
|
+
| BL | Bayesian ARD (sparse) | **Experimental: tends to overfit** (slope < 1, negative r2 on the example data). `sklearn.linear_model.ARDRegression`: sparse Bayesian regression with a per-marker prior precision (automatic relevance determination). Not a Bayesian LASSO; the `BL` abbreviation is kept for compatibility |
|
|
115
|
+
| RKHS | RKHS (Gaussian Kernel) | Kernel BLUP with an RBF kernel; bandwidth and shrinkage chosen by REML on each training fold |
|
|
116
|
+
| RF | Random Forest | `sklearn.ensemble.RandomForestRegressor` (500 trees) |
|
|
117
|
+
| XGB | XGBoost | Requires `pip install genopick[full]` |
|
|
118
|
+
| LGBM | LightGBM | Requires `pip install genopick[full]` |
|
|
119
|
+
|
|
120
|
+
`BRR` is an alias for `GBLUP` (the same model, identical predictions): `--models BRR` runs GBLUP.
|
|
121
|
+
|
|
122
|
+
Every model implements the same two-method interface (`fit` / `predict`), so
|
|
123
|
+
adding a new one is a matter of subclassing `genopick.models.base.GSModel`.
|
|
124
|
+
|
|
125
|
+
## Metrics
|
|
126
|
+
|
|
127
|
+
Each fold reports `r` (Pearson correlation), `r2`, `rmse`, `mae`, `bias`,
|
|
128
|
+
`slope` (regression of observed on predicted should be ~1), `spearman`
|
|
129
|
+
(rank correlation), and `nrmse`. Breeders care most about **r** (prediction
|
|
130
|
+
accuracy) and **spearman** (does the model rank genotypes correctly for
|
|
131
|
+
selection?).
|
|
132
|
+
|
|
133
|
+
## Example Output
|
|
134
|
+
|
|
135
|
+
Results on the bundled example data, trait `yield`:
|
|
136
|
+
|
|
137
|
+
<!-- example-results:start (generated by scripts/update_docs_example.py; do not edit) -->
|
|
138
|
+
|
|
139
|
+
`genopick run example_geno.csv example_pheno.csv --trait yield --models all --folds 5 --seed 42` (means over the 5 folds; times depend on the machine):
|
|
140
|
+
|
|
141
|
+
| Model | r | Spearman | r2 | RMSE | Slope | Bias | Time (s) |
|
|
142
|
+
|---|---:|---:|---:|---:|---:|---:|---:|
|
|
143
|
+
| GBLUP | 0.466 | 0.442 | 0.186 | 0.799 | 1.02 | -0.006 | 0.1 |
|
|
144
|
+
| BL | 0.376 | 0.351 | -0.373 | 1.038 | 0.35 | -0.014 | 19.0 |
|
|
145
|
+
| RKHS | 0.463 | 0.437 | 0.182 | 0.801 | 1.02 | -0.005 | 0.7 |
|
|
146
|
+
| RF | 0.303 | 0.285 | 0.042 | 0.867 | 1.43 | 0.013 | 26.4 |
|
|
147
|
+
| XGB | 0.234 | 0.217 | -0.045 | 0.905 | 0.50 | 0.040 | 0.8 |
|
|
148
|
+
| LGBM | 0.313 | 0.287 | 0.037 | 0.869 | 0.69 | 0.046 | 0.9 |
|
|
149
|
+
|
|
150
|
+
<!-- example-results:end -->
|
|
151
|
+
|
|
152
|
+
Model comparison (mean r per model; error bars are ±1 SD across folds):
|
|
153
|
+
|
|
154
|
+

|
|
155
|
+
|
|
156
|
+
Predicted vs. observed phenotypes per model:
|
|
157
|
+
|
|
158
|
+

|
|
159
|
+
|
|
160
|
+
The full HTML report also includes a boxplot of per-fold accuracy (each fold
|
|
161
|
+
drawn as a dot), a calibration (slope) plot, a runtime comparison, and
|
|
162
|
+
per-model detail tables. Every plot has a one-line explanation.
|
|
163
|
+
|
|
164
|
+
## Reading the results
|
|
165
|
+
|
|
166
|
+
All metrics compare out-of-fold predictions with observed phenotypes and are
|
|
167
|
+
averaged over folds (and repeats).
|
|
168
|
+
|
|
169
|
+
- **r** (Pearson correlation): the usual "prediction accuracy" in genomic
|
|
170
|
+
selection. It measures how well predictions track the observed values,
|
|
171
|
+
ignoring scale and offset. Its ceiling is about `sqrt(h2)`, because the
|
|
172
|
+
environmental part of a phenotype cannot be predicted from markers.
|
|
173
|
+
- **Spearman**: correlation of ranks. This is what matters when you select
|
|
174
|
+
the top lines; it is usually close to r.
|
|
175
|
+
- **r2**: `1 - SS_residual / SS_total`, the share of phenotypic variance the
|
|
176
|
+
predictions explain **on their own scale**. It is not r squared. It is
|
|
177
|
+
negative when the predictions are worse than predicting the fold mean for
|
|
178
|
+
everyone: typically an over-fitted model whose predictions are too spread
|
|
179
|
+
out, even if r is decent (see BL in the table above).
|
|
180
|
+
- **RMSE**: root mean squared error, in the trait's units. Compare it with
|
|
181
|
+
the phenotypic SD: an RMSE equal to the SD means no useful prediction.
|
|
182
|
+
- **Slope**: slope of the regression of observed on predicted values, a
|
|
183
|
+
calibration check. About 1 is well calibrated. Below 1 means predictions
|
|
184
|
+
are too spread out (over-fitted, too little shrinkage); above 1 means they
|
|
185
|
+
are too compressed (too much shrinkage). For ranking, r matters more than
|
|
186
|
+
the slope.
|
|
187
|
+
- **Bias**: mean predicted minus mean observed. Close to 0 for any model
|
|
188
|
+
with an intercept under random cross-validation.
|
|
189
|
+
|
|
190
|
+
**Small datasets give noisy accuracy.** With a few hundred lines, r varies a
|
|
191
|
+
lot from fold to fold (the error bars above show one SD), so differences of a
|
|
192
|
+
few hundredths between models are usually not meaningful. Use more folds and
|
|
193
|
+
`--repeats`, and look at the per-fold spread in the report before ranking
|
|
194
|
+
models.
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
MIT
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "genopick"
|
|
7
|
+
version = "0.3.0"
|
|
8
|
+
description = "Genomic Selection Model Benchmarking CLI for Plant Breeding"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Joash Joshua Ayo" },
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"numpy",
|
|
17
|
+
"pandas",
|
|
18
|
+
"scikit-learn",
|
|
19
|
+
"typer",
|
|
20
|
+
"rich",
|
|
21
|
+
"matplotlib>=3.9",
|
|
22
|
+
"jinja2",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.optional-dependencies]
|
|
26
|
+
full = [
|
|
27
|
+
"xgboost",
|
|
28
|
+
"lightgbm",
|
|
29
|
+
]
|
|
30
|
+
dev = [
|
|
31
|
+
"pytest",
|
|
32
|
+
"pytest-cov",
|
|
33
|
+
"ruff>=0.16,<0.18",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.scripts]
|
|
37
|
+
genopick = "genopick.cli:app"
|
|
38
|
+
# Deprecated alias, kept for one release after the rename from gsbench.
|
|
39
|
+
gsbench = "genopick.cli:gsbench_alias"
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://github.com/josh45-source/genopick"
|
|
43
|
+
Issues = "https://github.com/josh45-source/genopick/issues"
|
|
44
|
+
|
|
45
|
+
[tool.setuptools.packages.find]
|
|
46
|
+
where = ["src"]
|
|
47
|
+
|
|
48
|
+
[tool.setuptools.package-data]
|
|
49
|
+
genopick = ["templates/*.html", "data/*.csv"]
|
|
50
|
+
|
|
51
|
+
[tool.ruff]
|
|
52
|
+
line-length = 100
|
|
53
|
+
target-version = "py310"
|
|
54
|
+
|
|
55
|
+
[tool.ruff.lint]
|
|
56
|
+
select = ["E4", "E7", "E9", "F"]
|
|
57
|
+
|
|
58
|
+
[tool.pytest.ini_options]
|
|
59
|
+
testpaths = ["tests"]
|
genopick-0.3.0/setup.cfg
ADDED