Learn R Programming

dartR.base (version 1.0.5)

gl.subsample.ind: Subsample individuals from a genlight object

Description

A function to subsample individuals at random in a genlight object with and without replacement.

Usage

gl.subsample.ind(
  x,
  n = NULL,
  replace = TRUE,
  by.pop = TRUE,
  error.check = TRUE,
  mono.rm = FALSE,
  verbose = NULL
)

Value

Returns the subsampled genlight object

Arguments

x

Name of the genlight object containing the SNP or presence/absence (SilicoDArT) data [required].

n

Number of individuals to include in the subsample [default NULL]

replace

If TRUE, sampling is with replacement [default TRUE]

by.pop

If FALSE, ignore population settings when subsampling; if TRUE, subsample each population to n individuals [default TRUE].

error.check

If TRUE, will undertake error checks on input paramaters [default TRUE]

mono.rm

If TRUE and error.check is TRUE, monomorphic loci arising from the deletion of individuals will be filtered from the resultant genlight object [default FALSE]

verbose

Verbosity: 0, silent or fatal errors; 1, begin and end; 2, progress log; 3, progress and results summary; 5, full report [default NULL, unless specified using gl.set.verbosity]

Author

Custodian: Bernd Gruber (Post to https://groups.google.com/d/forum/dartr)

Details

Retain a subset of individuals at random, with or without replacement. If subsampling globally, n must be less than or equal to nInd(x). If subsampling by population, then n must be less than the minimum sample size for any population.

Set error.check = FALSE for speedy execution in simulations

See Also

Other data manipulation: gl.define.pop(), gl.drop.ind(), gl.drop.loc(), gl.drop.pop(), gl.edit.recode.pop(), gl.impute(), gl.join(), gl.keep.ind(), gl.keep.loc(), gl.keep.pop(), gl.make.recode.ind(), gl.merge.pop(), gl.reassign.pop(), gl.recode.ind(), gl.recode.pop(), gl.rename.pop(), gl.sample(), gl.sim.genotypes(), gl.sort(), gl.subsample.loc()

Examples

Run this code
gl <- gl.subsample.ind(testset.gl, n=30, by.pop=FALSE, replace=TRUE)
gl <- gl.subsample.ind(platypus.gl, n=10, by.pop=TRUE, replace=TRUE)

Run the code above in your browser using DataLab