Inference
optimize(deme_graph, inference_options, data, pts, maxiter=1000, perturb=0, verbose=0, uL=None, log=True, method='fmin', fit_ancestral_misid=False, misid_guess=None, output_stream=sys.stdout, output=None, overwrite=False)
Optimize demography given a deme graph of initial and fixed parameters and inference options that specify which parameters to fit, and bounds or constraints on those parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deme_graph
|
DemeGraph
|
A YAML file in |
required |
inference_options
|
str
|
File with inference options See (url) for how to set this up. |
required |
data
|
Spectrum
|
The SFS to fit, which must have pop_ids specified. Can either be a Spectrum object or the file path to the stored frequency spectrum. The populations in the SFS need to be present (with matching IDs) in the deme graph. |
required |
pts
|
list[int]
|
List of grid points to extrapolate. |
required |
maxiter
|
int
|
The maximum number of iterations to run optimization. Defaults to 1000. Note: maxiter does not seem to work with the Powell method! This appears to be a bug within scipy.optimize. |
1000
|
perturb
|
float
|
The perturbation amount of the initial parameters. Defaults to
zero, in which case we do not perturb the initial parameters in the input
demes YAML. If perturb is greater than zero, the initial parameters in the input
YAML are randomly perturbed by up to |
0
|
verbose
|
int
|
The frequency to print updates to |
0
|
uL
|
float
|
The mutuation rate scaled by number of callable sites, so that theta
is the compound parameter 4NeuL. If given, we optimize with |
None
|
log
|
bool
|
If True, optimize over log of the parameters. |
True
|
method
|
str
|
The optimization method. Available methods are "fmin", "powell", and "lbfgsb". |
'fmin'
|
fit_ancestral_misid
|
bool
|
If True, we fit the probability that the ancestral state of a given SNP is misidenitified, resulting in ancestral/derived labels being flipped. Note: this is only allowed with unfolded spectra. Defaults to False. |
False
|
misid_guess
|
float
|
Defaults to 0.01. |
None
|
output_stream
|
str or output stream
|
Defaults to standard output. Can be given an open file stream instead or other output stream. |
stdout
|
output
|
str
|
If given, the filename for the output best-fit model YAML. |
None
|
overwrite
|
bool
|
If True, overwrites any existing file with the same output name. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
param_names |
list[str]
|
List of parameter names |
xopt |
list[float]
|
The optimal parameters |
fopt |
float
|
The optimal log-likelihood |
Source code in dadi/Demes/Inference.py
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | |