biodem.s2g.pipeline
biodem.s2g.pipeline
The pipeline for converting SNPs to genome blocks representations.
SNP2GBFit
Source code in src\biodem\s2g\pipeline.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
__init__(log_dir, log_name, litdata_dir, which_outer_testset, which_inner_valset, regression, dense_layer_dims, snp_onehot_bits=const.default.snp_onehot_bits, devices=const.default.devices, accelerator=const.default.accelerator, n_jobs=const.default.n_jobs, learning_rate=const.default.lr, patience=const.default.patience, max_epochs=const.default.max_epochs, min_epochs=const.default.min_epochs, batch_size=const.default.batch_size)
SNP-to-genome-block model training with hyperparameter optimization.
Source code in src\biodem\s2g\pipeline.py
hparams_fit(learning_rate, patience, max_epochs, min_epochs, batch_size, dense_layer_dims)
Generate a dictionary of hyperparameters for SNP2GB model training.
Source code in src\biodem\s2g\pipeline.py
manual_fit()
Train SNP2GB model with manually set hyperparameters.
objective(trial)
Objective function for SNP2GB model hyperparameter optimization.
Source code in src\biodem\s2g\pipeline.py
optimize(n_trials=const.default.n_trials, storage=const.default.optuna_db, gc_after_trial=True)
Hyperparameters optimization for SNP2GB model.
Source code in src\biodem\s2g\pipeline.py
snp2gb_fit(hparams, devices, accelerator)
Train SNP2GB model with given hyperparameters.
Source code in src\biodem\s2g\pipeline.py
SNP2GBFitPipe
Source code in src\biodem\s2g\pipeline.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
__init__(litdata_dir, list_ncv, log_dir, regression, devices=const.default.devices, accelerator=const.default.accelerator, n_jobs=const.default.n_jobs, n_trials=const.default.n_trials, dense_layer_dims=None, snp_onehot_bits=const.default.snp_onehot_bits)
SNP2GB model training pipeline.
Hyperparameters are optimized for each fold in nested cross-validation.
The best model for each fold is used to convert SNPs to genome blocks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
litdata_dir
|
str
|
Path to the directory containing the nested cross-validation data. |
required |
list_ncv
|
List[List[int]]
|
List of nested cross-validation folds. e.g., |
required |
log_dir
|
str
|
Path to the directory for saving the training logs and models' checkpoints. |
required |
regression
|
bool
|
Whether the task is regression or classification. |
required |
devices
|
Union[List[int], str, int]
|
Devices for training. |
devices
|
accelerator
|
str
|
Accelerator for training. |
accelerator
|
n_jobs
|
int
|
Number of jobs for parallel hyperparameter optimization. |
n_jobs
|
n_trials
|
Optional[int]
|
Number of trials for hyperparameter optimization. |
n_trials
|
dense_layer_dims
|
Optional[List[int]]
|
List of hidden dimensions for the dense layers. |
None
|
snp_onehot_bits
|
int
|
Length of the one-hot representation for SNPs. |
snp_onehot_bits
|
Source code in src\biodem\s2g\pipeline.py
train_pipeline()
Train SNP2GB model for each fold in nested cross-validation.
Source code in src\biodem\s2g\pipeline.py
SNP2GBTransPipe
Source code in src\biodem\s2g\pipeline.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
|
__init__(dir_log, dir_output, overwrite_collected_log=False)
The pipeline to transform SNP features to genome block features.
- Collect trained models for each fold in nested cross-validation.
- Transform SNP features to genome block features.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir_log
|
str
|
The log directory of the SNP2GB models. |
required |
dir_output
|
str
|
The output directory. |
required |
overwrite_collected_log
|
bool
|
Whether to overwrite existing collected log.
Default: |
False
|
Source code in src\biodem\s2g\pipeline.py
collect_models()
Collect fitted models for each fold in nested cross-validation.
Source code in src\biodem\s2g\pipeline.py
convert_snp(dir_litdata, list_ncv=None, snp_onehot_bits=const.default.snp_onehot_bits, accelerator=const.default.accelerator, batch_size=const.default.batch_size, n_workers=const.default.n_workers)
Convert SNPs to genome blocks features using the best model for each fold in nested cross-validation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir_litdata
|
str
|
The directory containing nested cross-validation data for S2G. |
required |
list_ncv
|
Optional[List[List[int]]]
|
The list of outer-inner folds to use.
Default: |
None
|
snp_onehot_bits
|
int
|
The number of bits for one-hot representation of SNPs.
Default: |
snp_onehot_bits
|
accelerator
|
str
|
The accelerator to use.
Default: |
accelerator
|
batch_size
|
int
|
The batch size to use.
Default: |
batch_size
|
n_workers
|
int
|
The number of workers to use for dataloader.
Default: |
n_workers
|
Source code in src\biodem\s2g\pipeline.py
execute_s2g(dir_litdata, path_gtype_pkl, path_pretrained_model, dir_log_predict=os.getcwd(), snp_onehot_bits=const.default.snp_onehot_bits, batch_size=const.default.batch_size, accelerator=const.default.accelerator)
Run the SNP2GB model for independent test / prediction.