Skip to contents

Individuals are assigned to populations based on the individual/sample/specimen metrics file (csv) used with gl.read.dart().

One might want to define the population structure in accordance with another classification, such as using an individual metric (e.g. sex, male or female). This script discards the current population assignments and replaces them with new population assignments defined by a specified individual metric.

The script returns a genlight object with the new population assignments. Note that the original population assignments are lost.

Usage

gl.reassign.pop(x, as.pop, verbose = NULL)

Arguments

x

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

as.pop

Specify the name of the individual metric to set as the pop variable [required].

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 reassigned populations.

Author

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

Examples

# SNP data
   popNames(testset.gl)
#>  [1] "EmmacBrisWive"    "EmmacBurdMist"    "EmmacBurnBara"    "EmmacClarJack"   
#>  [5] "EmmacClarYate"    "EmmacCoopAvin"    "EmmacCoopCully"   "EmmacCoopEulb"   
#>  [9] "EmmacFitzAllig"   "EmmacJohnWari"    "EmmacMaclGeor"    "EmmacMaryBoru"   
#> [13] "EmmacMaryPetr"    "EmmacMDBBowm"     "EmmacMDBCond"     "EmmacMDBCudg"    
#> [17] "EmmacMDBForb"     "EmmacMDBGwyd"     "EmmacMDBMaci"     "EmmacMDBMurrMung"
#> [21] "EmmacMDBSanf"     "EmmacNormJack"    "EmmacNormLeic"    "EmmacNormSalt"   
#> [25] "EmmacRichCasi"    "EmmacRoss"        "EmmacRussEube"    "EmmacTweeUki"    
#> [29] "EmsubRopeMata"    "EmvicVictJasp"   
   gl <- gl.reassign.pop(testset.gl, as.pop='sex',verbose=3)
#> Starting gl.reassign.pop 
#>   Processing genlight object with SNP data
#>   Setting population assignments to individual metric sex 
#>   Summary of recoded dataset
#>     No. of loci: 255 
#>     No. of individuals: 250 
#>     No. of populations:  3 
#> Completed: gl.reassign.pop 
#> 
   popNames(gl)
#> [1] "Female"  "Male"    "Unknown"
# Tag P/A data
   popNames(testset.gs)
#>  [1] "EmmacBrisWive"    "EmmacBurdMist"    "EmmacBurnBara"    "EmmacClarJack"   
#>  [5] "EmmacClarYate"    "EmmacCoopAvin"    "EmmacCoopCully"   "EmmacCoopEulb"   
#>  [9] "EmmacFitzAllig"   "EmmacJohnWari"    "EmmacMaclGeor"    "EmmacMaryBoru"   
#> [13] "EmmacMaryPetr"    "EmmacMDBBowm"     "EmmacMDBCond"     "EmmacMDBCudg"    
#> [17] "EmmacMDBForb"     "EmmacMDBGwyd"     "EmmacMDBMaci"     "EmmacMDBMurrMung"
#> [21] "EmmacMDBSanf"     "EmmacNormJack"    "EmmacNormLeic"    "EmmacNormSalt"   
#> [25] "EmmacRichCasi"    "EmmacRussEube"    "EmmacTweeUki"     "EmsubRopeMata"   
#> [29] "EmvicVictJasp"   
   gs <- gl.reassign.pop(testset.gs, as.pop='sex',verbose=3)
#> Starting gl.reassign.pop 
#>   Processing genlight object with Presence/Absence (SilicoDArT) data
#>   Setting population assignments to individual metric sex 
#>   Summary of recoded dataset
#>     No. of loci: 255 
#>     No. of individuals: 218 
#>     No. of populations:  3 
#> Completed: gl.reassign.pop 
#> 
   popNames(gs)
#> [1] "Female"  "Male"    "Unknown"