gl.subsample.loc: Subsample loci from a genlight object

View source: R/gl.subsample.loc.r

gl.subsample.locR Documentation

Subsample loci from a genlight object

Description

A function to subsample loci in a genlight object, at random (with or without replacement) or by information content.

Usage

gl.subsample.loc(
  x,
  n,
  replace = TRUE,
  error.check = TRUE,
  method = "random",
  mono.rm = FALSE,
  verbose = NULL
)

Arguments

x

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

n

Number of loci to include in the subsample [required].

replace

If TRUE, sampling is with replacement; ignored when method = "pic" [default TRUE]

error.check

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

method

Method: "random", in which case the loci are sampled at random; or "pic", in which case the top n loci ranked on information content are chosen. Information content is AvgPIC for SNP data and PIC for presence/absence (SilicoDArT) data, recalculated first if the stored values are out of date [default "random"].

mono.rm

Delete monomorphic loci before sampling [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]

Details

Retain a subset of loci at random, with or without replacement, or the n most informative loci. Parameter n must be less than or equal to nLoc(x) (after monomorphic loci are removed, if mono.rm = TRUE).

Set error.check = FALSE for speedy execution in simulations

Value

Returns the subsampled genlight object

Author(s)

Author(s): Bernd Gruber, Luis Mijangos. Custodian: Bernd Gruber (Post to https://groups.google.com/d/forum/dartr)

See Also

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

Examples

if (isTRUE(getOption("dartR_fbm"))) testset.gl <- gl.gen2fbm(testset.gl)
gl2 <- gl.subsample.loc(testset.gl, n=50, replace=TRUE, verbose=3)
gl3 <- gl.subsample.loc(testset.gl, n=50, method="pic", verbose=3)

dartR.base documentation built on Nov. 18, 2026, 9:06 a.m.