Recodes individual (=specimen = sample) labels in a genlight object
Source:R/gl.recode.ind.r
gl.recode.ind.Rd
This script recodes individual labels and/or deletes individuals from a DaRT genlight SNP file based on a lookup table provided as a csv file.
Arguments
- x
Name of the genlight object containing SNP genotypes [required].
- ind.recode
Name of the csv file containing the individual relabelling [required].
- recalc
If TRUE, recalculate the locus metadata statistics if any individuals are deleted in the filtering [default FALSE].
- mono.rm
If TRUE, remove monomorphic loci [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 2 or as specified using gl.set.verbosity].
Details
Renaming individuals may be required when there have been errors in labelling arising in the process from sample to DArT files. There may be occasions where renaming individuals is required for preparation of figures. 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 clear record of the changes.
The script, having deleted individuals, optionally identifies resultant monomorphic loci or loci with all values missing and deletes them (using gl.filter.monomorphs.r). The script also optionally recalculates statistics made incorrect by the deletion of individuals from the dataset.
The script returns a genlight object with the new individual labels, the monomorphic loci optionally removed and the optionally recalculated locus metadata.
See also
gl.filter.monomorphs
for filtering monomorphs,
gl.recalc.metrics
for recalculating locus metrics,
gl.recode.pop
for recoding populations
Author
Custodian: Arthur Georges – Post to https://groups.google.com/d/forum/dartr
Examples
file <- system.file('extdata','testset_ind_recode.csv', package='dartR')
gl <- gl.recode.ind(testset.gl, ind.recode=file, verbose=3)
#> Starting gl.recode.ind
#> Processing genlight object with SNP data
#> Relabelling individuals (=specimens) as per /home/runner/work/_temp/Library/dartR/extdata/testset_ind_recode.csv
#> Reading lookup table
#> Applying the recoding
#> Deleting individuals/samples flagged for deletion
#> Dropping
#> Delete
#> A total of 1 individuals dropped
#> Warning: Listed individual delete not present in the dataset -- ignored
#> Warning: Resultant dataset may contain monomorphic loci
#> Locus metrics not recalculated
#> Summary of recoded dataset
#> Original No. of loci: 255
#> New No. of loci: 255
#> Original No. of individuals: 250
#> New No. of individuals: 249
#> Original No. of populations: 30
#> New No. of populations: 30
#> Note: Locus metrics not recalculated
#> Note: Resultant monomorphic loci not deleted
#> Completed: gl.recode.ind
#>