This function adjusts the barcode vectors stored in a saved simulation state so that the population level allele frequency (PLAF) matches a user supplied target. The adjustment is applied to each of the supported barcode containers individually (human strain barcodes, infection realisations, and male and female mosquito oocyst barcodes) as well as to the combined set of barcodes across all containers.

update_saved_state_barcode_plaf(saved_state, target_plaf, seed = NULL)

Arguments

saved_state

A list representing the saved simulation state returned by [saveRDS()] on the final element of a `run_sim()` output.

target_plaf

Numeric vector giving the desired PLAF for each locus.

seed

Optional integer to set the random number generator state before modifying barcodes. This is useful to obtain reproducible adjustments.

Value

The input `saved_state` with barcode vectors modified in place so that their PLAF equals `target_plaf` (within numerical tolerance).