Skip to contents

This script recodes population assignments and/or deletes populations from a DaRT genlight SNP file based on information provided in a csv population recode file.

Usage

gl.recode.pop(x, pop.recode, recalc = FALSE, mono.rm = FALSE, verbose = NULL)

Arguments

x

Name of the genlight object containing the SNP data [required].

pop.recode

Name of the csv file containing the population reassignments [required].

recalc

Recalculate the locus metadata statistics if any individuals are deleted in the filtering [default FALSE].

mono.rm

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].

Value

A genlight object with the recoded and reduced data.

Details

Individuals are assigned to populations based on the specimen metadata data file (csv) used with gl.read.dart(). Recoding can be used to amalgamate populations or to selectively delete or retain populations.

The population recode file contains a list of populations in the genlight object as the first column of the csv file, and the new population assignments in the second column of the csv file. The keyword Delete used as a new population assignment will result in the associated specimen being dropped from the dataset.

The script, having deleted populations, optionally identifies resultant monomorphic loci or loci with all values missing and deletes them (using gl.filter.monomorphs.r). The script also optionally recalculates the locus metadata as appropriate.

See also

gl.filter.monomorphs

gl.recode.pop

Author

Custodian: Arthur Georges – Post to https://groups.google.com/d/forum/dartr

Examples

# \donttest{
  mfile <- system.file('extdata', 'testset_pop_recode.csv', package='dartR')
  nPop(testset.gl)
#> [1] 30
  gl <- gl.recode.pop(testset.gl, pop.recode=mfile, verbose=3)
#> Starting gl.recode.pop 
#>   Processing genlight object with SNP data
#>   Reassigning entities to populations as per  /home/runner/work/_temp/Library/dartR/extdata/testset_pop_recode.csv 
#>   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: 250 
#>   Original No. of populations: 30 
#>     New No. of populations: 26 
#>   Note: Locus metrics not recalculated
#>   Note: Resultant monomorphic loci not deleted
#> Completed: gl.recode.pop 
#> 
 # }