View source: R/gl.randomize.snps.r
| gl.randomize.snps | R Documentation |
This function samples half of the loci at random and, in the sampled loci, swaps the coding of the two homozygotes: 0 becomes 2 and 2 becomes 0. Heterozygotes (1) and missing values are unchanged. The allele labels of the sampled loci are reversed to match, so the object still describes the same genotypes; only which allele is counted changes.
gl.randomize.snps(
x,
plot.display = TRUE,
plot.theme = theme_dartR(),
plot.colors = NULL,
plot.file = NULL,
plot.dir = NULL,
verbose = NULL
)
x |
Name of the genlight object containing the SNP data [required]. |
plot.display |
If TRUE, resultant plots are displayed in the plot window [default TRUE]. |
plot.theme |
Theme for the plot. See Details for options [default theme_dartR()]. |
plot.colors |
Vector of four color names passed to
|
plot.file |
Name for the RDS binary file to save (base name only, exclude extension) [default NULL] |
plot.dir |
Directory in which to save the plot file [default as specified by the global working directory or tempdir()] |
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]. |
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. Only SNP data are accepted. FBM-backed objects are recoded in a copy of their backing file, so the input object is not modified. If plot.display = 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. The combined plot is saved only when plot.file is specified.
Returns a genlight object with half of the loci re-coded and their
allele labels (loc.all) reversed; the REF and ALT read counts and the
0/0 and 1/1 likelihoods in other$geno.metrics (see
gl.read.vcf) are swapped with them. Locus metric flags are
reset, as the
allele-frequency metrics no longer match the recoded genotypes.
Author(s): Luis Mijangos. Custodian: Luis Mijangos – Post to https://groups.google.com/d/forum/dartr
if (isTRUE(getOption("dartR_fbm"))) testset.gl <- gl.gen2fbm(testset.gl)
gl <- gl.filter.monomorphs(testset.gl)
res <- gl.randomize.snps(gl,verbose = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.