downsample_pairs: downsample the number of individuals sampled

View source: R/downsample_pairs.R

downsample_pairsR Documentation

downsample the number of individuals sampled

Description

This discards individuals from the sample, randomly, until the desired number of samples is achieved, then it returns only those pairs in which both members are part of the retained samples.

Usage

downsample_pairs(S, P, n)

Arguments

S

the tibble of samples with columns at least of ID and samp_years_list. Typically this will be what is returned in the samples component from slurp_spip().

P

the tibble of pairs. Typically this will be what has been returned from compile_related_pairs().

n

The desired number of individuals (or instances, really, see below) to retain in the sample.

Value

This returns a list with two components as follows:

  • ds_samples: A tibble like S except having randomly removed individuals so as to only have n left.

  • ds_pairs: A tibble like P except having removed any pairs that include individuals that were not retained in the sample.

Examples

# prepare some input
S <- three_pops_with_mig_slurped_results$samples
P <- compile_related_pairs(three_pops_with_mig_slurped_results$samples)
result <- downsample_pairs(S, P, n = 500)

# print the result
result

eriqande/CKMRpop documentation built on Jan. 25, 2024, 2:10 p.m.