Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

fixed_loci

Identify fixed loci


Description

A locus is "fixed" if the non-missing sub-vector contains all 0's or all 2's (the locus is completely homozygous for one allele or completely homozygous for the other allele). This function tests each locus, returning a vector that is TRUE for each fixed locus, FALSE otherwise. Loci with only missing elements (NA) are treated as fixed. Below m is the number of loci, and n is the number of individuals.

Usage

fixed_loci(X)

Arguments

X

The m-by-n genotype matrix

Value

A length-m boolean vector where the i element is TRUE if locus i is fixed or completely missing, FALSE otherwise.

Examples

# here's a toy genotype matrix
X <- matrix(
       data = c(
              2, 2, NA,  # fixed locus (with one missing element)
              0, NA, 0,  # another fixed locus, for opposite allele
              1, 1, 1,   # NOT fixed (heterozygotes are not considered fixed)
              0, 1, 2,   # a completely variable locus
              NA, NA, NA # completely missing locus (will be treated as fixed)
             ),
       ncol = 3, byrow = TRUE)

# test that we get the desired values
stopifnot(
  fixed_loci(X) == c(TRUE, TRUE, FALSE, FALSE, TRUE)
)

bnpsd

Simulate Genotypes from the BN-PSD Admixture Model

v1.2.3
GPL-3
Authors
Alejandro Ochoa [aut, cre] (<https://orcid.org/0000-0003-4928-3403>), John D. Storey [aut] (<https://orcid.org/0000-0001-5992-402X>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.