Learn R Programming

dartR (version 2.0.4)

gl.random.snp: Randomly changes the allocation of 0's and 2's in a genlight object

Description

This function samples randomly half of the SNPs and re-codes, in the sampled SNP's, 0's by 2's.

Usage

gl.random.snp(x, plot.out = TRUE, save2tmp = FALSE, verbose = NULL)

Arguments

x

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

plot.out

Specify if a plot is to be produced [default TRUE].

save2tmp

If TRUE, saves any ggplots to the session temporary directory (tempdir) [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 NULL, unless specified using gl.set.verbosity].

Value

Returns a genlight object with half of the loci re-coded.

Details

DArT calls the most common allele as the reference allele. In a genlight object, homozygous for the reference allele are coded with a '0' and homozygous for the alternative allele are coded with a '2'. This causes some distortions in visuals from time to time.

If plot.out = TRUE, two smear plots (pre-randomisation and post-randomisation) are presented using a random subset of individuals (10) and loci (100) to provide an overview of the changes.

Resultant ggplots are saved to the session's temporary directory.

Examples

Run this code
# NOT RUN {
res <- gl.random.snp(platypus.gl[1:10,1:10],verbose = 5)

# }

Run the code above in your browser using DataLab