replace_na_with_major_genotype: Replace Missing Marker Genotypes

Description Usage Arguments Value Examples

View source: R/replace_na_with_major_genotype.R

Description

replace_na_with_major_genotype replaces missing values with the most frequent genotype at each marker locus.

Usage

1
replace_na_with_major_genotype(dat, missing_value, major_genotype)

Arguments

dat

A matrix. Genotype names are stored in rows whereas marker names are stored in columns.

missing_value

Specify the encoding of missing genotypes.

major_genotype

Vector with the major allele at each locus.

Value

A matrix of the same type as dat but with missing values replaced by the major genotype at the corresponding locus.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
 # Load a matrix with SNP genotypes encoded as numeric values
 data(marker_numeric)

 # Compute the major genotype at each locus.
 major_genotype <- sspredr::compute_maf(marker_numeric, output = "geno_list",
                                        missing = NA_real_,
                                        maf_threshold = 0)[["major_genotype"]]

 # Replace all missing genotypes with the major allele.
 replace_na_with_major_genotype(marker_numeric, missing_value = NA_real_,
                                major_genotype = major_genotype)

mwesthues/sspredr documentation built on May 23, 2019, 10:56 a.m.