tracts.driver_utils._reorder_ancestry_proportions#
- _reorder_ancestry_proportions(old_ancestor_labels, new_ancestor_labels, autosome_proportions, allosome_proportions)#
Permutes observed ancestry proportions computed under
old_ancestor_labelsso that they line up withnew_ancestor_labelsinstead. Used when the implicit population changes during boundary re-optimization: this reordersdemographic_model.population_indices(the implicit population is always placed last; seeParametrizedDemography(SexBiased).load_from_YAML), so any previously-computed proportions must be realigned to match wherever they are reused afterwards, whether for display or to fix parameters by ancestry proportion.- Parameters:
old_ancestor_labels (
list[str]) – The population order thatautosome_proportions/allosome_proportionswere computed in (i.e. theancestor_labelsoriginally passed toget_ancestry_proportions).new_ancestor_labels (
list[str]) – The population order to realign to.autosome_proportions (
ndarray) – Observed autosomal ancestry proportions, inold_ancestor_labelsorder.allosome_proportions (
ndarray|list) – Observed allosomal ancestry proportions, inold_ancestor_labelsorder, or[]if allosomes are not modelled.
- Returns:
(autosome_proportions, allosome_proportions)reordered to matchnew_ancestor_labels. Returned unchanged if the two label orders are already identical.- Return type:
tuple[np.ndarray, np.ndarray | list]