Removes all but the specified populations from a genlight object
Source:R/gl.keep.pop.r
gl.keep.pop.Rd
Individuals are assigned to populations based on the specimen metadata data file (csv) used with gl.read.dart().
The script, having deleted the specified 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 statistics made redundant by the deletion of individuals from the dataset.
The script returns a genlight object with the new population assignments and the recalculated locus metadata.
#' See more about data manipulation in the [tutorial](http://georges.biomatix.org/storage/app/media/uploaded-files/tutorial4dartrdatamanipulation22-dec-21-3.pdf).
Arguments
- x
Name of the genlight object containing the SNP or presence/absence (SilicoDArT) data [required].
- pop.list
A list of populations to be kept [required].
- as.pop
Assign another metric to represent population [default NULL].
- recalc
Recalculate the locus metadata statistics [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]
See also
gl.drop.pop
to drop rather than keep specified populations
Author
Custodian: Arthur Georges – Post to https://groups.google.com/d/forum/dartr
Examples
# SNP data
gl2 <- gl.keep.pop(testset.gl, pop.list=c('EmsubRopeMata', 'EmvicVictJasp'))
#> Starting gl.keep.pop
#> Processing genlight object with SNP data
#> Checking for presence of nominated populations
#> Retaining only populations EmsubRopeMata, EmvicVictJasp
#> Warning: Resultant dataset may contain monomorphic loci
#> Locus metrics not recalculated
#> Completed: gl.keep.pop
#>
gl2 <- gl.keep.pop(testset.gl, pop.list=c('EmsubRopeMata', 'EmvicVictJasp'),
mono.rm=TRUE,recalc=TRUE)
#> Starting gl.keep.pop
#> Processing genlight object with SNP data
#> Checking for presence of nominated populations
#> Retaining only populations EmsubRopeMata, EmvicVictJasp
#> Deleting monomorphic loc
#> Recalculating locus metrics
#> Completed: gl.keep.pop
#>
gl2 <- gl.keep.pop(testset.gl, pop.list=c('Female'),as.pop='sex')
#> Starting gl.keep.pop
#> Processing genlight object with SNP data
#> Temporarily setting population assignments to sex as specified by the as.pop parameter
#> Checking for presence of nominated populations
#> Retaining only populations Female
#> Warning: Resultant dataset may contain monomorphic loci
#> Locus metrics not recalculated
#> Resetting population assignments to initial state
#> Completed: gl.keep.pop
#>
# Tag P/A data
gs2 <- gl.keep.pop(testset.gs, pop.list=c('EmsubRopeMata','EmvicVictJasp'))
#> Starting gl.keep.pop
#> Processing genlight object with Presence/Absence (SilicoDArT) data
#> Checking for presence of nominated populations
#> Retaining only populations EmsubRopeMata, EmvicVictJasp
#> Locus metrics not recalculated
#> Completed: gl.keep.pop
#>