gl.sample {dartR.base} | R Documentation |
Samples individuals from populations
Description
A function to subsample individuals in a genlight object
Usage
gl.sample(
x,
nsample = min(table(pop(x))),
replace = TRUE,
onepop = FALSE,
verbose = NULL
)
Arguments
x |
genlight object containing SNP/silicodart genotypes |
nsample |
the number of individuals that should be sampled |
replace |
a switch to sample by replacement (default). |
onepop |
switch to ignore population settings of the genlight object and sample from all individuals disregarding the population definition. [default FALSE]. |
verbose |
set verbosity |
Details
This is convenience function to facilitate a bootstrap approach
This function is often used to support a bootstrap approach in dartR. For a bootstrap approach it is often desirable to sample a defined number of individuals for each of the populations in a genlight object and then calculate a certain quantity for that subset (redo a 1000 times)
Value
returns a genlight object with nsample samples from each populations.
Author(s)
Bernd Gruber (Post to https://groups.google.com/d/forum/dartr)
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.sim.genotypes()
,
gl.sort()
,
gl.subsample.ind()
,
gl.subsample.loc()
Examples
#bootstrap for 2 possums populations to check effect of sample size on fixed alleles
gl.set.verbosity(0)
pp <- possums.gl[c(1:30,91:120),]
nrep <- 1:10
nss <- seq(1,10,2)
res <- expand.grid(nrep=nrep, nss=nss)
for (i in 1:nrow(res)) {
dummy <- gl.sample(pp, nsample=res$nss[i], replace=TRUE)
dummy <- gl.compliance.check(dummy)
pas <- gl.report.pa(dummy, plot.display= FALSE)
res$fixed[i] <- pas$fixed[1]
}
boxplot(fixed ~ nss, data=res)