recodeBiallele: Takes a biallelic SNP vector and converts to 0,1,2 coding

Description Usage Arguments Value Author(s) Examples

Description

Looks for AA,GG,CC,TT sets major to 0 (most frequently found basepair), minor to 2 (second most frequently found bp), het to 1 (e.g. AG, AC, AT, ...), anything else to NA

Usage

1

Arguments

x

Vector of values to be converted.

Value

Returns a vector of same length as input with translated values.

Author(s)

Greg Ziegler

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
  recodeBiallele(c("AA","GG","GG","GG","GG","AA"))
  
  ## The function is currently defined as
function(x){
  x <- as.character(x)
  freqs <- names(sort(table(x[x 
  major <- freqs[1]
  if(length(freqs)>1){
    minor <- freqs[2]
  }else{
    minor <- "np"
  }
  
  x[which(x==major)] <-0
  x[which(x==minor)] <-2
  x[which(x 
  x[which(!(x==1|x==0|x==2))]   <- NA
  #x[which(!(x==2|x==0))]   <- NA
  #x[which(x=="N")] <- NA
  return(x)
}

gziegler/ionomicsUtils documentation built on June 20, 2019, 8:04 p.m.