tracts.core.optimize_cob#

optimize_cob(p0, bins, Ls, data, nsamp, model_func, outofbounds_fun=None, cutoff=0, verbose_screen=0, flush_delay=1, maxiter=None, func_args=None, reset_counter=True)#

Optimizes model parameters using the COBYLA method. Valid only for autosomal data. Admixture is modelled with the Monoecious model.

Parameters:
  • p0 (list) – An array of initial parameters to start the optimization.

  • bins (Union[Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[bool | int | float | complex | str | bytes]]) – A point grid on where the tract length distribution has to be evaluated.

  • Ls (Union[Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[bool | int | float | complex | str | bytes]]) – The lengths of the chromosomes present in data.

  • data (list[ndarray]) – Spectrum with data.

  • model_func (callable) – A function that takes a parameter array and returns a dictionary of migration matrices for each population.

  • outofbounds_fun (callable) – A function that takes a parameter array and returns a violation score indicating how much the parameters violate the bounds.

  • cutoff (int) – The number of bins to drop at the beginning of the array. This could be achieved with masks.

  • verbose_screen (int) – If greater than zero, prints optimization status every verbose iterations.

  • flush_delay (float) – Standard output will be flushed once every flush_delay minutes. This is useful to avoid overloading I/O on clusters.

  • maxiter (int) – Maximum iterations to run for.

  • func_args (list) – List of additional arguments to model_func. It is assumed that model_func’s first argument is an array of parameters to optimize.

  • reset_counter (bool) – Resets the iteration counter to zero. Set to False to continue iteration count (e.g., if optimization continues from previous point).

Return type:

ndarray