recode_snps: Recode genotypic data

Description Usage Arguments Value Examples

View source: R/genotype_coding.R

Description

recode_snps recodes the elements of a SNP-matrix

Usage

1
2
recode_snps(x, major, minor, major_coding, minor_coding, het_coding,
  missing_value, na_coding)

Arguments

x

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

major

Character vector with names of major genotype at each locus.

minor

Character vector with names of minor genotype at each locus.

major_coding

Scalar specifying how to recode the major genotype.

minor_coding

Scalar specifying how to recode the minor genotype.

het_coding

Scalar specifying how to recode heterozygous loci.

missing_value

Scalar specifying how missing values are encoded in x.

na_coding

Scalar specifying how to recode missing values.

Value

A matrix with the same dimensions as x but with recoded SNP genotypes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
 # First, determine the major and minor allele at each locus of SNP-genotypes
 geno_lst <- compute_maf(marker_character, output = "geno_list",
                         missing_value = "??", maf_threshold = 0)
 major <- geno_lst[["major_genotype"]]
 minor <- geno_lst[["minor_genotype"]]

 # Recode the major allele as '2', the minor allele as '0' and heterozygotes
 # as '0'.
 recode_snps(marker_character, major = major, minor = minor,
             major_coding = 2, minor_coding = 0, het_coding = 1,
             missing_value = "??", na_coding = NA_real_)

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