# NOT RUN {
# 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
0, 0, 1, # a somewhat "rare" variant
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, FALSE, TRUE)
)
# the "rare" variant gets marked as "fixed" if we set `maf_min` to its frequency
stopifnot(
fixed_loci(X, maf_min = 1/6) == c(TRUE, TRUE, FALSE, FALSE, TRUE, TRUE)
)
# }
Run the code above in your browser using DataLab