deepdraw-opt 0.1.1__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.
Files changed (101) hide show
  1. deepdraw_opt-0.1.1/.gitignore +135 -0
  2. deepdraw_opt-0.1.1/LICENSE +21 -0
  3. deepdraw_opt-0.1.1/PKG-INFO +268 -0
  4. deepdraw_opt-0.1.1/README.md +231 -0
  5. deepdraw_opt-0.1.1/benchmarks/README.md +102 -0
  6. deepdraw_opt-0.1.1/benchmarks/__init__.py +1 -0
  7. deepdraw_opt-0.1.1/benchmarks/aggregate_summaries.py +305 -0
  8. deepdraw_opt-0.1.1/benchmarks/conf/config.yaml +94 -0
  9. deepdraw_opt-0.1.1/benchmarks/conf/launcher_settings/submitit_local.yaml +3 -0
  10. deepdraw_opt-0.1.1/benchmarks/conf/launcher_settings/submitit_slurm.yaml +6 -0
  11. deepdraw_opt-0.1.1/benchmarks/conf/seed_mode/array.yaml +12 -0
  12. deepdraw_opt-0.1.1/benchmarks/conf/seed_mode/inline.yaml +2 -0
  13. deepdraw_opt-0.1.1/benchmarks/noise_simulation.py +871 -0
  14. deepdraw_opt-0.1.1/benchmarks/report_failed_jobs.py +209 -0
  15. deepdraw_opt-0.1.1/benchmarks/run_active_learning.py +316 -0
  16. deepdraw_opt-0.1.1/benchmarks/run_config.py +200 -0
  17. deepdraw_opt-0.1.1/benchmarks/utils/__init__.py +1 -0
  18. deepdraw_opt-0.1.1/benchmarks/utils/config_utils.py +309 -0
  19. deepdraw_opt-0.1.1/benchmarks/utils/seed_jobs.py +88 -0
  20. deepdraw_opt-0.1.1/benchmarks/utils/seed_runner.py +35 -0
  21. deepdraw_opt-0.1.1/benchmarks/utils/slurm_utils.py +74 -0
  22. deepdraw_opt-0.1.1/benchmarks/utils/sweep_utils.py +22 -0
  23. deepdraw_opt-0.1.1/core/README.md +14 -0
  24. deepdraw_opt-0.1.1/core/__init__.py +23 -0
  25. deepdraw_opt-0.1.1/core/botorch_models.py +305 -0
  26. deepdraw_opt-0.1.1/core/data_loader.py +175 -0
  27. deepdraw_opt-0.1.1/core/experiment.py +491 -0
  28. deepdraw_opt-0.1.1/core/initial_selection_strategies.py +669 -0
  29. deepdraw_opt-0.1.1/core/metrics_calculator.py +170 -0
  30. deepdraw_opt-0.1.1/core/predictor_trainer.py +243 -0
  31. deepdraw_opt-0.1.1/core/query_strategies.py +517 -0
  32. deepdraw_opt-0.1.1/core/round_tracker.py +168 -0
  33. deepdraw_opt-0.1.1/core/stable_rbf_kernel.py +34 -0
  34. deepdraw_opt-0.1.1/core/stopping.py +201 -0
  35. deepdraw_opt-0.1.1/core/uncertainty.py +135 -0
  36. deepdraw_opt-0.1.1/deepdraw/__init__.py +15 -0
  37. deepdraw_opt-0.1.1/deepdraw/cli.py +321 -0
  38. deepdraw_opt-0.1.1/deepdraw/conf/__init__.py +1 -0
  39. deepdraw_opt-0.1.1/deepdraw/conf/initial_selection_strategy/core_set.yaml +4 -0
  40. deepdraw_opt-0.1.1/deepdraw/conf/initial_selection_strategy/density_core_set.yaml +6 -0
  41. deepdraw_opt-0.1.1/deepdraw/conf/initial_selection_strategy/kmeans.yaml +3 -0
  42. deepdraw_opt-0.1.1/deepdraw/conf/initial_selection_strategy/probcover.yaml +13 -0
  43. deepdraw_opt-0.1.1/deepdraw/conf/initial_selection_strategy/probcover_cosine.yaml +13 -0
  44. deepdraw_opt-0.1.1/deepdraw/conf/initial_selection_strategy/random.yaml +3 -0
  45. deepdraw_opt-0.1.1/deepdraw/conf/initial_selection_strategy/typiclust.yaml +9 -0
  46. deepdraw_opt-0.1.1/deepdraw/conf/predictor/botorch_gp.yaml +7 -0
  47. deepdraw_opt-0.1.1/deepdraw/conf/predictor/botorch_linear_gp.yaml +7 -0
  48. deepdraw_opt-0.1.1/deepdraw/conf/predictor/botorch_rf_ensemble.yaml +11 -0
  49. deepdraw_opt-0.1.1/deepdraw/conf/predictor/gradboost_regressor.yaml +3 -0
  50. deepdraw_opt-0.1.1/deepdraw/conf/query_strategy/botorch_gibbon.yaml +7 -0
  51. deepdraw_opt-0.1.1/deepdraw/conf/query_strategy/botorch_log_ei.yaml +4 -0
  52. deepdraw_opt-0.1.1/deepdraw/conf/query_strategy/botorch_log_pi.yaml +4 -0
  53. deepdraw_opt-0.1.1/deepdraw/conf/query_strategy/botorch_mes.yaml +7 -0
  54. deepdraw_opt-0.1.1/deepdraw/conf/query_strategy/botorch_pes.yaml +7 -0
  55. deepdraw_opt-0.1.1/deepdraw/conf/query_strategy/botorch_qlog_ei.yaml +4 -0
  56. deepdraw_opt-0.1.1/deepdraw/conf/query_strategy/botorch_qlog_nei.yaml +4 -0
  57. deepdraw_opt-0.1.1/deepdraw/conf/query_strategy/botorch_ucb.yaml +5 -0
  58. deepdraw_opt-0.1.1/deepdraw/conf/query_strategy/predstdhybrid.yaml +3 -0
  59. deepdraw_opt-0.1.1/deepdraw/conf/query_strategy/random.yaml +2 -0
  60. deepdraw_opt-0.1.1/deepdraw/conf/query_strategy/topk.yaml +1 -0
  61. deepdraw_opt-0.1.1/deepdraw/conf/transforms/log_standardize.yaml +12 -0
  62. deepdraw_opt-0.1.1/deepdraw/conf/transforms/none.yaml +2 -0
  63. deepdraw_opt-0.1.1/deepdraw/conf/transforms/standardize.yaml +5 -0
  64. deepdraw_opt-0.1.1/deepdraw/embeddings/__init__.py +5 -0
  65. deepdraw_opt-0.1.1/deepdraw/embeddings/alphagenome.py +726 -0
  66. deepdraw_opt-0.1.1/deepdraw/embeddings/pca.py +431 -0
  67. deepdraw_opt-0.1.1/deepdraw/workflow.py +1069 -0
  68. deepdraw_opt-0.1.1/envs/alphagenome/pyproject.toml +28 -0
  69. deepdraw_opt-0.1.1/envs/alphagenome/uv.lock +2280 -0
  70. deepdraw_opt-0.1.1/examples/deepdraw_dummy/README.md +55 -0
  71. deepdraw_opt-0.1.1/examples/deepdraw_dummy/design_pool.csv +61 -0
  72. deepdraw_opt-0.1.1/examples/deepdraw_dummy/embeddings.npz +0 -0
  73. deepdraw_opt-0.1.1/examples/deepdraw_dummy/make_dummy_inputs.py +72 -0
  74. deepdraw_opt-0.1.1/examples/deepdraw_dummy/measurements.csv +13 -0
  75. deepdraw_opt-0.1.1/pyproject.toml +150 -0
  76. deepdraw_opt-0.1.1/test/test_active_learning.py +275 -0
  77. deepdraw_opt-0.1.1/test/test_aggregate_summaries.py +45 -0
  78. deepdraw_opt-0.1.1/test/test_alphagenome_embeddings.py +148 -0
  79. deepdraw_opt-0.1.1/test/test_botorch_models.py +131 -0
  80. deepdraw_opt-0.1.1/test/test_config_utils.py +222 -0
  81. deepdraw_opt-0.1.1/test/test_data_loader.py +162 -0
  82. deepdraw_opt-0.1.1/test/test_deepdraw_cli.py +182 -0
  83. deepdraw_opt-0.1.1/test/test_deepdraw_workflow.py +648 -0
  84. deepdraw_opt-0.1.1/test/test_embedding_pca.py +60 -0
  85. deepdraw_opt-0.1.1/test/test_experiment_integration.py +525 -0
  86. deepdraw_opt-0.1.1/test/test_initial_selection_strategies.py +368 -0
  87. deepdraw_opt-0.1.1/test/test_noise_simulation.py +551 -0
  88. deepdraw_opt-0.1.1/test/test_output_path_config.py +98 -0
  89. deepdraw_opt-0.1.1/test/test_predictor_trainer.py +92 -0
  90. deepdraw_opt-0.1.1/test/test_query_strategies.py +408 -0
  91. deepdraw_opt-0.1.1/test/test_report_failed_jobs.py +82 -0
  92. deepdraw_opt-0.1.1/test/test_round_tracker.py +180 -0
  93. deepdraw_opt-0.1.1/test/test_run_config.py +275 -0
  94. deepdraw_opt-0.1.1/test/test_seed_jobs.py +141 -0
  95. deepdraw_opt-0.1.1/test/test_seed_runner.py +29 -0
  96. deepdraw_opt-0.1.1/test/test_slurm_utils.py +96 -0
  97. deepdraw_opt-0.1.1/test/test_stable_rbf_kernel.py +61 -0
  98. deepdraw_opt-0.1.1/test/test_stopping_rules.py +397 -0
  99. deepdraw_opt-0.1.1/test/test_sweep_utils.py +42 -0
  100. deepdraw_opt-0.1.1/test/test_uncertainty.py +153 -0
  101. deepdraw_opt-0.1.1/uv.lock +2079 -0
@@ -0,0 +1,135 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual Environment
24
+ venv/
25
+ env/
26
+ ENV/
27
+ .env
28
+ .venv
29
+ .venv*/
30
+ env.bak/
31
+ venv.bak/
32
+
33
+ # IDE
34
+ .idea/
35
+ .vscode/
36
+ *.swp
37
+ *.swo
38
+ .DS_Store
39
+
40
+ # Jupyter Notebook
41
+ .ipynb_checkpoints
42
+ *.ipynb
43
+
44
+ # Testing
45
+ .coverage
46
+ htmlcov/
47
+ .pytest_cache/
48
+ .tox/
49
+
50
+ # Distribution
51
+ *.tar.gz
52
+ *.zip
53
+
54
+ # los and databases
55
+ *.log
56
+ *.sqlite
57
+ *.db
58
+ *.csv
59
+ !examples/deepdraw_dummy/design_pool.csv
60
+ !examples/deepdraw_dummy/measurements.csv
61
+ *.pdf
62
+ *.png
63
+ *.err
64
+ *.out
65
+
66
+ # Model files and data
67
+ *.h5
68
+ *.pkl
69
+ *.model
70
+ *.pth
71
+ *.7z
72
+ *.safetensors
73
+ multirun/*
74
+ data/*
75
+ data_new/*
76
+ !data/scripts/*
77
+ models/
78
+ checkpoints/
79
+ results/
80
+ results_*/
81
+ runs/
82
+ deepdraw_run/
83
+ wandb/
84
+ data_assembly/
85
+ data_analyze/
86
+
87
+ # Environment management
88
+ .python-version
89
+ poetry.lock
90
+ .ruff_cache/
91
+
92
+ # Documentation
93
+ docs/_build/
94
+ site/
95
+
96
+ # Misc
97
+ .DS_Store
98
+ .env.local
99
+ .env.development.local
100
+ .env.test.local
101
+ .env.production.local
102
+ # run_experiments.py
103
+ setting.json
104
+
105
+ # dir
106
+ data_new_deprecated/
107
+
108
+ # logs
109
+ logs
110
+ multirun
111
+ outputs
112
+ logs_experiments
113
+ log_test/*
114
+ logs_test/*
115
+ slurm_logs/
116
+
117
+
118
+ # hidden directories
119
+ .*
120
+
121
+ # Local assistant settings and instructions
122
+ .codex/
123
+ .claude/
124
+ AGENTS.md
125
+ CLAUDE.md
126
+
127
+ # local data
128
+ **/test_local.yaml
129
+ **/local_166k.yaml
130
+ /benchmarks/datasets/
131
+
132
+ # Local-only analysis / figure-generation scripts (notebooks, sensitivity-analysis
133
+ # helpers, etc.). Anything dropped under this folder stays out of git.
134
+ benchmarks/utils/analysis/
135
+ /utils/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Cell Ethology Lab and contributors
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.
@@ -0,0 +1,268 @@
1
+ Metadata-Version: 2.5
2
+ Name: deepdraw-opt
3
+ Version: 0.1.1
4
+ Summary: Active learning for genetic circuit design
5
+ Project-URL: Homepage, https://github.com/cellethology/deepdraw
6
+ Project-URL: Repository, https://github.com/cellethology/deepdraw.git
7
+ Project-URL: Issues, https://github.com/cellethology/deepdraw/issues
8
+ Author-email: Cell Ethology Lab <jerry@westlake.edu.cn>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: active-learning,circuit-design,dna-sequences,machine-learning
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
19
+ Requires-Python: >=3.10
20
+ Requires-Dist: botorch>=0.16.1
21
+ Requires-Dist: gpytorch>=1.14.2
22
+ Requires-Dist: hydra-core>=1.3.2
23
+ Requires-Dist: numpy>=1.21.0
24
+ Requires-Dist: omegaconf>=2.3.0
25
+ Requires-Dist: pandas>=1.3.0
26
+ Requires-Dist: scikit-learn<1.8,>=1.6.1
27
+ Requires-Dist: scipy>=1.6.0
28
+ Requires-Dist: torch>=2.0.1
29
+ Provides-Extra: analysis
30
+ Requires-Dist: openpyxl>=3.1.5; extra == 'analysis'
31
+ Requires-Dist: pyyaml>=6.0.2; extra == 'analysis'
32
+ Requires-Dist: tqdm<=4.66.5; extra == 'analysis'
33
+ Provides-Extra: cluster
34
+ Requires-Dist: hydra-submitit-launcher>=1.2.0; extra == 'cluster'
35
+ Requires-Dist: submitit>=1.5.3; extra == 'cluster'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # Deepdraw
39
+
40
+ [![CI](https://github.com/cellethology/deepdraw/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/cellethology/deepdraw/actions/workflows/pre-commit.yml)
41
+ [![Coverage](https://img.shields.io/codecov/c/github/cellethology/deepdraw?logo=codecov)](https://codecov.io/gh/cellethology/deepdraw)
42
+
43
+ Deepdraw selects batches of genetic circuits to measure using sequence embeddings and accumulated experimental results. Its default search combines ProbCover initial selection, Gaussian-process prediction, and maximum-value entropy search (MES).
44
+
45
+ The active-learning loop runs on CPU. AlphaGenome embedding generation has a separate optional environment. For retrospective evaluation on fully measured datasets, see [benchmarks](https://github.com/cellethology/deepdraw/blob/main/benchmarks/README.md).
46
+
47
+ ## Install
48
+
49
+ Install with Python 3.10 or later:
50
+
51
+ ```bash
52
+ python -m pip install deepdraw-opt
53
+ deepdraw --help
54
+ ```
55
+
56
+ The package name is `deepdraw-opt`; the command and Python import are `deepdraw`.
57
+
58
+ For the bundled example, optional AlphaGenome environment, and development, install Git and [uv](https://docs.astral.sh/uv/), then clone the repository:
59
+
60
+ ```bash
61
+ git clone https://github.com/cellethology/deepdraw.git
62
+ cd deepdraw
63
+ uv sync --python 3.10
64
+ uv run deepdraw --help
65
+ ```
66
+
67
+ The commands below use `uv run` from the repository root. With a PyPI installation, invoke `deepdraw` directly instead of `uv run deepdraw`.
68
+
69
+ ## Try the dummy example
70
+
71
+ The example includes 60 designs, synthetic embeddings, and measurements matching the default first batch. It requires no model download.
72
+
73
+ ```bash
74
+ uv run deepdraw init \
75
+ --pool-csv examples/deepdraw_dummy/design_pool.csv \
76
+ --embeddings examples/deepdraw_dummy/embeddings.npz \
77
+ --sequence-column sequence \
78
+ --id-column variant_id \
79
+ --stopping-rule threshold \
80
+ --phenotype-threshold 19
81
+
82
+ uv run deepdraw suggest \
83
+ --run-dir deepdraw_run \
84
+ --measurements examples/deepdraw_dummy/measurements.csv \
85
+ --label-column Expression
86
+ ```
87
+
88
+ These commands write `deepdraw_run/round_000_to_measure.csv` and `round_001_to_measure.csv`. See the [example README](https://github.com/cellethology/deepdraw/blob/main/examples/deepdraw_dummy/README.md) to simulate another measurement update and exercise stopping.
89
+
90
+ ## Use your own data
91
+
92
+ ### 1. Prepare the design pool and embeddings
93
+
94
+ Create `designs.csv` with one row per candidate, a unique ID, and its DNA sequence:
95
+
96
+ ```csv
97
+ variant_id,sequence
98
+ variant_001,ATGCGTACGTTAGCGA
99
+ variant_002,ATGCGTACGATAGCAA
100
+ variant_003,ATGCGTACGCTAGCTA
101
+ ```
102
+
103
+ Provide an NPZ containing:
104
+
105
+ | Array | Contents |
106
+ | --- | --- |
107
+ | `embeddings` | A numeric array of shape `(number_of_designs, number_of_features)`. |
108
+ | `ids` | Design IDs matching the CSV's ID column, one per embedding row. |
109
+
110
+ `sample_ids` is also accepted as the ID-array name. Zero-based pool row indices are supported; an NPZ without IDs must follow the CSV's row order exactly. Keep the pool and embeddings at their original paths while continuing a run.
111
+
112
+ You can use embeddings from another model or generate them with the [AlphaGenome workflow below](#generate-alphagenome-embeddings).
113
+
114
+ ### 2. Select the first batch
115
+
116
+ ```bash
117
+ uv run deepdraw init \
118
+ --pool-csv designs.csv \
119
+ --embeddings embeddings.npz \
120
+ --sequence-column sequence \
121
+ --id-column variant_id \
122
+ --output-dir runs/my_project \
123
+ --stopping-rule threshold \
124
+ --phenotype-threshold 10
125
+ ```
126
+
127
+ Choose a phenotype cutoff appropriate for your experiment. Deepdraw maximizes the supplied score.
128
+
129
+ The run directory contains:
130
+
131
+ ```text
132
+ runs/my_project/
133
+ ├── deepdraw_state.json
134
+ ├── round_000_to_measure.csv
135
+ ├── latest_recommendations.csv
136
+ └── selection_history.csv
137
+ ```
138
+
139
+ Measure the designs in `round_000_to_measure.csv`. Recommendation files retain the original pool columns; `selection_history.csv` also records `deepdraw_round`.
140
+
141
+ ### 3. Add measurements and request the next batch
142
+
143
+ Create a cumulative `measurements.csv` containing design IDs and one measured score per design:
144
+
145
+ ```csv
146
+ variant_id,Expression
147
+ variant_001,1.42
148
+ variant_002,3.87
149
+ variant_003,5.11
150
+ ```
151
+
152
+ Use the IDs actually recommended for your run. Include every previously recommended design; additional measured designs from the pool can also be included.
153
+
154
+ ```bash
155
+ uv run deepdraw suggest \
156
+ --run-dir runs/my_project \
157
+ --measurements measurements.csv \
158
+ --label-column Expression
159
+ ```
160
+
161
+ Deepdraw trains on the measured designs and writes `round_001_to_measure.csv`. Measure that batch, append its scores to the same cumulative file, and repeat `suggest` for later rounds. Measured designs are excluded from new batches.
162
+
163
+ When a stopping rule fires, the command reports the reason and writes no new batch. Use a new `--output-dir` when starting another run.
164
+
165
+ ## Search settings and stopping
166
+
167
+ The CLI selects the recommended search settings automatically. Algorithm flags are optional overrides:
168
+
169
+ | Flag | Default | Alternatives |
170
+ | --- | --- | --- |
171
+ | `--starting-batch-size`, `--batch-size` | `12` | Any positive integer; capped by available designs. |
172
+ | `--seed` | `0` | An integer from `0` to `4294967295`. |
173
+ | `--initial-selection-strategy` | `probcover` | `core_set`, `density_core_set`, `kmeans`, `probcover_cosine`, `typiclust`, `random`. |
174
+ | `--predictor` | `gp` | `linear_gp`, `gradboost_regressor`, `rf_ensemble`. |
175
+ | `--query-strategy` | `mes` | `topk`, `predstdhybrid`, `ucb`, `pes`, `gibbon`, `log_pi`, `log_ei`, `qlog_nei`, `qlog_ei`, `random`. |
176
+ | `--feature-transforms` | `standardize` | `none`. |
177
+ | `--target-transforms` | `log_standardize` | `none`. |
178
+ | `--stopping-rule` | `none` | `threshold`, `ei`. |
179
+
180
+ `probcover` uses Euclidean distance; `probcover_cosine` uses cosine distance.
181
+
182
+ Gradient boosting supports `topk`, `predstdhybrid`, and `random`. The random-forest ensemble also supports `ucb`, `log_pi`, `log_ei`, `qlog_nei`, and `qlog_ei`. The entropy queries `mes`, `pes`, and `gibbon` require `gp` or `linear_gp`.
183
+
184
+ The default target transform applies `log(1 + score)` followed by standardization. Use `--target-transforms none` for scores that cannot be log-transformed.
185
+
186
+ Fixed-threshold stopping, used above, stops when a measured score meets or exceeds `--phenotype-threshold`. For an adaptive EI example using the bundled data:
187
+
188
+ ```bash
189
+ uv run deepdraw init \
190
+ --pool-csv examples/deepdraw_dummy/design_pool.csv \
191
+ --embeddings examples/deepdraw_dummy/embeddings.npz \
192
+ --sequence-column sequence \
193
+ --id-column variant_id \
194
+ --output-dir runs/dummy_ei \
195
+ --stopping-rule ei \
196
+ --epsilon 0.01
197
+
198
+ uv run deepdraw suggest \
199
+ --run-dir runs/dummy_ei \
200
+ --measurements examples/deepdraw_dummy/measurements.csv \
201
+ --label-column Expression
202
+ ```
203
+
204
+ After each measured batch, `suggest` stops if maximum expected improvement over the unmeasured pool is at most epsilon. With the default target transform, epsilon is in `log(1 + score)` units before standardization. The value above is for the dummy example; choose it for your objective. EI stopping reuses a compatible fitted GP or fits a separate GP when another predictor is selected.
205
+
206
+ Omitting the stopping options disables threshold and EI stopping. All runs finish when no unmeasured designs remain. Use `--log-level WARNING` for quieter output.
207
+
208
+ ## Generate AlphaGenome embeddings
209
+
210
+ Skip this section if you already have embeddings. The isolated environment uses Python 3.11:
211
+
212
+ ```bash
213
+ uv sync --project envs/alphagenome --python 3.11
214
+ ```
215
+
216
+ Accept access to `google/alphagenome-all-folds` on Hugging Face, then authenticate:
217
+
218
+ ```bash
219
+ uv run --project envs/alphagenome hf auth login
220
+ ```
221
+
222
+ An `HF_TOKEN` environment variable is also supported. The embedding environment supports CUDA GPUs on Linux and CPU execution; use CPU on macOS. Start with a batch size of 1.
223
+
224
+ ```bash
225
+ uv run --project envs/alphagenome deepdraw embed-alphagenome \
226
+ --pool-csv designs.csv \
227
+ --sequence-column sequence \
228
+ --id-column variant_id \
229
+ --output embeddings_alphagenome_raw.npz \
230
+ --model-version all_folds \
231
+ --resolution 1 \
232
+ --species human \
233
+ --pooling mean \
234
+ --batch-size 1
235
+
236
+ uv run deepdraw pca \
237
+ --input embeddings_alphagenome_raw.npz \
238
+ --output embeddings.npz \
239
+ --selection-method kneedle
240
+ ```
241
+
242
+ Use the resulting `embeddings.npz` with `deepdraw init`. PCA runs in the main Deepdraw environment.
243
+
244
+ ## Repository layout and development
245
+
246
+ | Directory | Contents |
247
+ | --- | --- |
248
+ | [deepdraw/](https://github.com/cellethology/deepdraw/tree/main/deepdraw) | CLI, experimental workflow, embedding tools, and shared presets. |
249
+ | [core/](https://github.com/cellethology/deepdraw/blob/main/core/README.md) | Models, selection strategies, training, and stopping rules. |
250
+ | [examples/deepdraw_dummy/](https://github.com/cellethology/deepdraw/blob/main/examples/deepdraw_dummy/README.md) | Runnable example with synthetic data. |
251
+ | [benchmarks/](https://github.com/cellethology/deepdraw/blob/main/benchmarks/README.md) | Retrospective evaluation, noise simulation, and Hydra/Slurm tools. |
252
+ | [envs/alphagenome/](https://github.com/cellethology/deepdraw/tree/main/envs/alphagenome) | Optional AlphaGenome environment. |
253
+ | [test/](https://github.com/cellethology/deepdraw/tree/main/test) | Unit and workflow tests. |
254
+
255
+ Install development dependencies and run the tests:
256
+
257
+ ```bash
258
+ uv run --group dev pytest
259
+ ```
260
+
261
+ Command-specific help:
262
+
263
+ ```bash
264
+ uv run deepdraw init --help
265
+ uv run deepdraw suggest --help
266
+ uv run deepdraw pca --help
267
+ uv run --project envs/alphagenome deepdraw embed-alphagenome --help
268
+ ```
@@ -0,0 +1,231 @@
1
+ # Deepdraw
2
+
3
+ [![CI](https://github.com/cellethology/deepdraw/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/cellethology/deepdraw/actions/workflows/pre-commit.yml)
4
+ [![Coverage](https://img.shields.io/codecov/c/github/cellethology/deepdraw?logo=codecov)](https://codecov.io/gh/cellethology/deepdraw)
5
+
6
+ Deepdraw selects batches of genetic circuits to measure using sequence embeddings and accumulated experimental results. Its default search combines ProbCover initial selection, Gaussian-process prediction, and maximum-value entropy search (MES).
7
+
8
+ The active-learning loop runs on CPU. AlphaGenome embedding generation has a separate optional environment. For retrospective evaluation on fully measured datasets, see [benchmarks](https://github.com/cellethology/deepdraw/blob/main/benchmarks/README.md).
9
+
10
+ ## Install
11
+
12
+ Install with Python 3.10 or later:
13
+
14
+ ```bash
15
+ python -m pip install deepdraw-opt
16
+ deepdraw --help
17
+ ```
18
+
19
+ The package name is `deepdraw-opt`; the command and Python import are `deepdraw`.
20
+
21
+ For the bundled example, optional AlphaGenome environment, and development, install Git and [uv](https://docs.astral.sh/uv/), then clone the repository:
22
+
23
+ ```bash
24
+ git clone https://github.com/cellethology/deepdraw.git
25
+ cd deepdraw
26
+ uv sync --python 3.10
27
+ uv run deepdraw --help
28
+ ```
29
+
30
+ The commands below use `uv run` from the repository root. With a PyPI installation, invoke `deepdraw` directly instead of `uv run deepdraw`.
31
+
32
+ ## Try the dummy example
33
+
34
+ The example includes 60 designs, synthetic embeddings, and measurements matching the default first batch. It requires no model download.
35
+
36
+ ```bash
37
+ uv run deepdraw init \
38
+ --pool-csv examples/deepdraw_dummy/design_pool.csv \
39
+ --embeddings examples/deepdraw_dummy/embeddings.npz \
40
+ --sequence-column sequence \
41
+ --id-column variant_id \
42
+ --stopping-rule threshold \
43
+ --phenotype-threshold 19
44
+
45
+ uv run deepdraw suggest \
46
+ --run-dir deepdraw_run \
47
+ --measurements examples/deepdraw_dummy/measurements.csv \
48
+ --label-column Expression
49
+ ```
50
+
51
+ These commands write `deepdraw_run/round_000_to_measure.csv` and `round_001_to_measure.csv`. See the [example README](https://github.com/cellethology/deepdraw/blob/main/examples/deepdraw_dummy/README.md) to simulate another measurement update and exercise stopping.
52
+
53
+ ## Use your own data
54
+
55
+ ### 1. Prepare the design pool and embeddings
56
+
57
+ Create `designs.csv` with one row per candidate, a unique ID, and its DNA sequence:
58
+
59
+ ```csv
60
+ variant_id,sequence
61
+ variant_001,ATGCGTACGTTAGCGA
62
+ variant_002,ATGCGTACGATAGCAA
63
+ variant_003,ATGCGTACGCTAGCTA
64
+ ```
65
+
66
+ Provide an NPZ containing:
67
+
68
+ | Array | Contents |
69
+ | --- | --- |
70
+ | `embeddings` | A numeric array of shape `(number_of_designs, number_of_features)`. |
71
+ | `ids` | Design IDs matching the CSV's ID column, one per embedding row. |
72
+
73
+ `sample_ids` is also accepted as the ID-array name. Zero-based pool row indices are supported; an NPZ without IDs must follow the CSV's row order exactly. Keep the pool and embeddings at their original paths while continuing a run.
74
+
75
+ You can use embeddings from another model or generate them with the [AlphaGenome workflow below](#generate-alphagenome-embeddings).
76
+
77
+ ### 2. Select the first batch
78
+
79
+ ```bash
80
+ uv run deepdraw init \
81
+ --pool-csv designs.csv \
82
+ --embeddings embeddings.npz \
83
+ --sequence-column sequence \
84
+ --id-column variant_id \
85
+ --output-dir runs/my_project \
86
+ --stopping-rule threshold \
87
+ --phenotype-threshold 10
88
+ ```
89
+
90
+ Choose a phenotype cutoff appropriate for your experiment. Deepdraw maximizes the supplied score.
91
+
92
+ The run directory contains:
93
+
94
+ ```text
95
+ runs/my_project/
96
+ ├── deepdraw_state.json
97
+ ├── round_000_to_measure.csv
98
+ ├── latest_recommendations.csv
99
+ └── selection_history.csv
100
+ ```
101
+
102
+ Measure the designs in `round_000_to_measure.csv`. Recommendation files retain the original pool columns; `selection_history.csv` also records `deepdraw_round`.
103
+
104
+ ### 3. Add measurements and request the next batch
105
+
106
+ Create a cumulative `measurements.csv` containing design IDs and one measured score per design:
107
+
108
+ ```csv
109
+ variant_id,Expression
110
+ variant_001,1.42
111
+ variant_002,3.87
112
+ variant_003,5.11
113
+ ```
114
+
115
+ Use the IDs actually recommended for your run. Include every previously recommended design; additional measured designs from the pool can also be included.
116
+
117
+ ```bash
118
+ uv run deepdraw suggest \
119
+ --run-dir runs/my_project \
120
+ --measurements measurements.csv \
121
+ --label-column Expression
122
+ ```
123
+
124
+ Deepdraw trains on the measured designs and writes `round_001_to_measure.csv`. Measure that batch, append its scores to the same cumulative file, and repeat `suggest` for later rounds. Measured designs are excluded from new batches.
125
+
126
+ When a stopping rule fires, the command reports the reason and writes no new batch. Use a new `--output-dir` when starting another run.
127
+
128
+ ## Search settings and stopping
129
+
130
+ The CLI selects the recommended search settings automatically. Algorithm flags are optional overrides:
131
+
132
+ | Flag | Default | Alternatives |
133
+ | --- | --- | --- |
134
+ | `--starting-batch-size`, `--batch-size` | `12` | Any positive integer; capped by available designs. |
135
+ | `--seed` | `0` | An integer from `0` to `4294967295`. |
136
+ | `--initial-selection-strategy` | `probcover` | `core_set`, `density_core_set`, `kmeans`, `probcover_cosine`, `typiclust`, `random`. |
137
+ | `--predictor` | `gp` | `linear_gp`, `gradboost_regressor`, `rf_ensemble`. |
138
+ | `--query-strategy` | `mes` | `topk`, `predstdhybrid`, `ucb`, `pes`, `gibbon`, `log_pi`, `log_ei`, `qlog_nei`, `qlog_ei`, `random`. |
139
+ | `--feature-transforms` | `standardize` | `none`. |
140
+ | `--target-transforms` | `log_standardize` | `none`. |
141
+ | `--stopping-rule` | `none` | `threshold`, `ei`. |
142
+
143
+ `probcover` uses Euclidean distance; `probcover_cosine` uses cosine distance.
144
+
145
+ Gradient boosting supports `topk`, `predstdhybrid`, and `random`. The random-forest ensemble also supports `ucb`, `log_pi`, `log_ei`, `qlog_nei`, and `qlog_ei`. The entropy queries `mes`, `pes`, and `gibbon` require `gp` or `linear_gp`.
146
+
147
+ The default target transform applies `log(1 + score)` followed by standardization. Use `--target-transforms none` for scores that cannot be log-transformed.
148
+
149
+ Fixed-threshold stopping, used above, stops when a measured score meets or exceeds `--phenotype-threshold`. For an adaptive EI example using the bundled data:
150
+
151
+ ```bash
152
+ uv run deepdraw init \
153
+ --pool-csv examples/deepdraw_dummy/design_pool.csv \
154
+ --embeddings examples/deepdraw_dummy/embeddings.npz \
155
+ --sequence-column sequence \
156
+ --id-column variant_id \
157
+ --output-dir runs/dummy_ei \
158
+ --stopping-rule ei \
159
+ --epsilon 0.01
160
+
161
+ uv run deepdraw suggest \
162
+ --run-dir runs/dummy_ei \
163
+ --measurements examples/deepdraw_dummy/measurements.csv \
164
+ --label-column Expression
165
+ ```
166
+
167
+ After each measured batch, `suggest` stops if maximum expected improvement over the unmeasured pool is at most epsilon. With the default target transform, epsilon is in `log(1 + score)` units before standardization. The value above is for the dummy example; choose it for your objective. EI stopping reuses a compatible fitted GP or fits a separate GP when another predictor is selected.
168
+
169
+ Omitting the stopping options disables threshold and EI stopping. All runs finish when no unmeasured designs remain. Use `--log-level WARNING` for quieter output.
170
+
171
+ ## Generate AlphaGenome embeddings
172
+
173
+ Skip this section if you already have embeddings. The isolated environment uses Python 3.11:
174
+
175
+ ```bash
176
+ uv sync --project envs/alphagenome --python 3.11
177
+ ```
178
+
179
+ Accept access to `google/alphagenome-all-folds` on Hugging Face, then authenticate:
180
+
181
+ ```bash
182
+ uv run --project envs/alphagenome hf auth login
183
+ ```
184
+
185
+ An `HF_TOKEN` environment variable is also supported. The embedding environment supports CUDA GPUs on Linux and CPU execution; use CPU on macOS. Start with a batch size of 1.
186
+
187
+ ```bash
188
+ uv run --project envs/alphagenome deepdraw embed-alphagenome \
189
+ --pool-csv designs.csv \
190
+ --sequence-column sequence \
191
+ --id-column variant_id \
192
+ --output embeddings_alphagenome_raw.npz \
193
+ --model-version all_folds \
194
+ --resolution 1 \
195
+ --species human \
196
+ --pooling mean \
197
+ --batch-size 1
198
+
199
+ uv run deepdraw pca \
200
+ --input embeddings_alphagenome_raw.npz \
201
+ --output embeddings.npz \
202
+ --selection-method kneedle
203
+ ```
204
+
205
+ Use the resulting `embeddings.npz` with `deepdraw init`. PCA runs in the main Deepdraw environment.
206
+
207
+ ## Repository layout and development
208
+
209
+ | Directory | Contents |
210
+ | --- | --- |
211
+ | [deepdraw/](https://github.com/cellethology/deepdraw/tree/main/deepdraw) | CLI, experimental workflow, embedding tools, and shared presets. |
212
+ | [core/](https://github.com/cellethology/deepdraw/blob/main/core/README.md) | Models, selection strategies, training, and stopping rules. |
213
+ | [examples/deepdraw_dummy/](https://github.com/cellethology/deepdraw/blob/main/examples/deepdraw_dummy/README.md) | Runnable example with synthetic data. |
214
+ | [benchmarks/](https://github.com/cellethology/deepdraw/blob/main/benchmarks/README.md) | Retrospective evaluation, noise simulation, and Hydra/Slurm tools. |
215
+ | [envs/alphagenome/](https://github.com/cellethology/deepdraw/tree/main/envs/alphagenome) | Optional AlphaGenome environment. |
216
+ | [test/](https://github.com/cellethology/deepdraw/tree/main/test) | Unit and workflow tests. |
217
+
218
+ Install development dependencies and run the tests:
219
+
220
+ ```bash
221
+ uv run --group dev pytest
222
+ ```
223
+
224
+ Command-specific help:
225
+
226
+ ```bash
227
+ uv run deepdraw init --help
228
+ uv run deepdraw suggest --help
229
+ uv run deepdraw pca --help
230
+ uv run --project envs/alphagenome deepdraw embed-alphagenome --help
231
+ ```