gl.edit.recode.pop {dartR.base} | R Documentation |
Creates or edits and applies a population re-assignment table
Description
A function to edit population assignments in a dartR genlight object, or to create a reassignment table taking the population assignments from a genlight object, or to edit existing population assignments in a pop.recode.table. The amended recode table is then applied to the genlight object.
Usage
gl.edit.recode.pop(
x,
pop.recode = NULL,
out.recode.file = NULL,
outpath = NULL,
recalc = FALSE,
mono.rm = FALSE,
verbose = NULL
)
Arguments
x |
Name of the genlight object [required]. |
pop.recode |
Path to recode file [default NULL]. |
out.recode.file |
Name of the file to output the new individual labels [default NULL]. |
outpath |
Directory to save the plot RDS files [default as specified by the global working directory or tempdir()] |
recalc |
If TRUE, recalculate the locus metadata statistics [default TRUE]. |
mono.rm |
If TRUE, remove monomorphic loci [default TRUE]. |
verbose |
Verbosity: 0, silent or fatal errors; 1, begin and end; 2, progress but not results; 3, progress and results summary; 5, full report [default 2 or as specified using gl.set.verbosity]. @details Genlight objects assign specimens to populations based on information in the ind.metadata file provided when the genlight object is first generated. Often one wishes to subset the data by deleting populations or to amalgamate populations. This can be done with a pop.recode table with two columns. The first column is the population assignment in the genlight object, the second column provides the new assignment. This function will input an existing reassignment table for editing and optionally save it as a new table, or if the name of an input table is not supplied, will generate a table using the population assignments in the parent genlight object. It will then apply the recodings to the genlight object. When caution needs to be exercised because of the potential for breaking the 'chain of evidence' associated with the samples, recoding individuals using a recode table (csv) can provide a durable record of the changes. For SNP genotype data, the function, having deleted populations, optionally identifies resultant monomorphic loci or loci with all values missing and deletes them. The script also optionally recalculates the locus metadata as appropriate. The optional deletion of monomorphic loci and the optional recalculation of locus statistics is not available for Tag P/A data (SilicoDArT). Use outpath=getwd() when calling this function to direct output files to your working directory. The function returns a dartR genlight object with the new population assignments and the recalculated locus metadata. |
Value
A genlight object with the revised population assignments
Author(s)
Custodian: Arthur Georges – Post to https://groups.google.com/d/forum/dartr
See Also
gl.recode.pop
, gl.drop.pop
,
gl.keep.pop
, gl.merge.pop
,
gl.reassign.pop
Other data manipulation:
gl.define.pop()
,
gl.drop.ind()
,
gl.drop.loc()
,
gl.drop.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.ind()
,
gl.subsample.loc()
Examples
#this is an interactive example
if(interactive()){
gl <- gl.edit.recode.pop(testset.gl)
gs <- gl.edit.recode.pop(testset.gs)
}
# See also -------------------