mixture_draw: Separate a chosen proportion of a reference dataset into a...

Description Usage Arguments Value Examples

View source: R/utilities.R

Description

Takes a reference dataset and a set of population proportions, either at the collection or reporting unit level. Randomly samples individuals to satisfy these desired proportions, and splits them into a new "mixture" dataframe.

Usage

1
mixture_draw(D, rhos = NULL, omegas = NULL, N, min_remaining = 0)

Arguments

D

a two-column genetic dataframe with "indiv", "repunit", and "collection" columns

rhos

a vector of the desired reporting unit proportions in the mixture set; if not named, will be assumed to be ordered by order of appearance in the dataset

omegas

the desired collection proportions in the mixture set

N

the total size of the mixture set

min_remaining

the fraction of any collection in the reference dataset which must remain at the end of the draw

Value

mixture_draw returns a list of two data frames, "mixture" being the random sample taken, and "reference" being the remaining samples

Examples

1
2
rhos <- as.vector(gtools::rdirichlet(1, table(alewife$repunit)))
cross_val <- mixture_draw(D = alewife, rhos = rhos, N = 100, min_remaining = .005)

rubias documentation built on Feb. 10, 2022, 1:06 a.m.