allele1to2: Convert genotype matrix from two different types

Description Usage Arguments Details Value Author(s) Examples

Description

(not supported for x-linked markers)

Usage

1
2
3
4
5
6
allele1to2(geno, marker.label = NULL, miss.val = NA)
allele2to1(geno, marker.label = NULL, miss.val = NA)
alleleRto1(geno, marker.label = NULL, miss.val = NA)
alleleRto2(geno, marker.label = NULL, miss.val = NA)
allele1toR(geno, marker.label = NULL, miss.val = c(-1, NA))
allele2toR(geno, marker.label = NULL, miss.val = NA)

Arguments

geno

(m,n)-genotype matrix

m=number of individuals

type 1 and R: n=number of snps

type 2: n=2*number of snps

marker.label

Vector of labels for marker, If a marker name is "SNP", its columns will be "SNP.1" and "SNP.2"

miss.val

Vector of specified missing values.

Details

3 different types of genotype matrices:

Type 1 : 1-column genotype matrix : minor allele count (0,1,2)

Type 2 : 2-column genotype matrix : each marker has a pair of two columns (1/1, 1/2, 2/2)

Type R : 1-column genotype matrix : code (1 = 1/1, 3 = 1/2, 2 = 2/2)

Value

converted genotype matrix

Author(s)

Sven Knueppel

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 ## [A] allele1to2
 N <- 10
 ns <- 4
 (geno <- matrix(sample(c(NA, 0:2), N * ns, replace = TRUE), nc = ns))
 allele1to2(geno)

 ## [B] allele2to1
 (geno <- matrix(c(0, 0, 1, 1, 2, 1, 1, 2,
                   1, 1, 2, 2, 2, 2, 1, 2,
                   0, 0, 1, 1, 2, 1, 0, 0), nc = 4, byrow = TRUE))
 allele2to1(geno)

 ## [C] alleleRto1
 N <- 10
 ns <- 4
 (geno <- matrix(sample(c(NA, 1:3), N * ns, replace = TRUE), nc = ns))
 alleleRto1(geno)

 ## [D] alleleRto2
 N <- 10
 ns <- 4
 (geno <- matrix(sample(c(0, 1:3), N * ns, replace = TRUE), nc = ns))
 alleleRto2(geno)

 ## [E] allele1toR
 N <- 10
 ns <- 4
 (geno <- matrix(sample(c(NA, 0:2), N * ns, replace = TRUE), nc = ns))
 allele1toR(geno)

 ## [F] allele2toR
 (geno <- matrix(c(0, 0, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 2, 1, 2, 
                   0, 0, 1, 1, 2, 1, 0, 0),
     nc = 4, byrow = TRUE))
 allele2toR (geno)

Example output

Loading required package: survival
      [,1] [,2] [,3] [,4]
 [1,]    1    1   NA    1
 [2,]    1   NA    1    2
 [3,]   NA    1   NA    0
 [4,]    0    0    2    2
 [5,]    1    0    0    2
 [6,]   NA    2    0   NA
 [7,]    0    0    0    0
 [8,]    2   NA    0   NA
 [9,]   NA    0    1    0
[10,]    1   NA   NA    0
      S1.a1 S1.a2 S2.a1 S2.a2 S3.a1 S3.a2 S4.a1 S4.a2
 [1,]     2     1     2     1    NA    NA     2     1
 [2,]     2     1    NA    NA     2     1     2     2
 [3,]    NA    NA     2     1    NA    NA     1     1
 [4,]     1     1     1     1     2     2     2     2
 [5,]     2     1     1     1     1     1     2     2
 [6,]    NA    NA     2     2     1     1    NA    NA
 [7,]     1     1     1     1     1     1     1     1
 [8,]     2     2    NA    NA     1     1    NA    NA
 [9,]    NA    NA     1     1     2     1     1     1
[10,]     2     1    NA    NA    NA    NA     1     1
     [,1] [,2] [,3] [,4]
[1,]    0    0    1    1
[2,]    2    1    1    2
[3,]    1    1    2    2
[4,]    2    2    1    2
[5,]    0    0    1    1
[6,]    2    1    0    0
     S1 S2
[1,] NA  0
[2,]  1  1
[3,]  0  2
[4,]  2  1
[5,] NA  0
[6,]  1 NA
      [,1] [,2] [,3] [,4]
 [1,]    3    2    2    2
 [2,]    1   NA    1    1
 [3,]   NA   NA    2   NA
 [4,]    1    3    3    3
 [5,]   NA    1    3    3
 [6,]    2   NA   NA    3
 [7,]    3    3    3    2
 [8,]    1    2    1    2
 [9,]    2    3   NA    2
[10,]    3    1    3   NA
      S1 S2 S3 S4
 [1,]  1  2  2  2
 [2,]  0 NA  0  0
 [3,] NA NA  2 NA
 [4,]  0  1  1  1
 [5,] NA  0  1  1
 [6,]  2 NA NA  1
 [7,]  1  1  1  2
 [8,]  0  2  0  2
 [9,]  2  1 NA  2
[10,]  1  0  1 NA
      [,1] [,2] [,3] [,4]
 [1,]    2    0    3    3
 [2,]    2    1    3    1
 [3,]    2    2    2    0
 [4,]    2    3    3    2
 [5,]    1    1    3    0
 [6,]    3    0    1    1
 [7,]    0    2    1    3
 [8,]    3    2    0    2
 [9,]    0    2    1    2
[10,]    1    0    2    2
      S1.a1 S1.a2 S2.a1 S2.a2 S3.a1 S3.a2 S4.a1 S4.a2
 [1,]     2     2    NA    NA     2     1     2     1
 [2,]     2     2     1     1     2     1     1     1
 [3,]     2     2     2     2     2     2    NA    NA
 [4,]     2     2     2     1     2     1     2     2
 [5,]     1     1     1     1     2     1    NA    NA
 [6,]     2     1    NA    NA     1     1     1     1
 [7,]    NA    NA     2     2     1     1     2     1
 [8,]     2     1     2     2    NA    NA     2     2
 [9,]    NA    NA     2     2     1     1     2     2
[10,]     1     1    NA    NA     2     2     2     2
      [,1] [,2] [,3] [,4]
 [1,]   NA    1    1    2
 [2,]   NA    1   NA    1
 [3,]   NA    2    1    0
 [4,]   NA    2    2    2
 [5,]   NA    2    2    0
 [6,]    0    1    0    1
 [7,]    2    0    1    0
 [8,]    1    1    2   NA
 [9,]    2   NA    1    2
[10,]    0    1    2    0
      S1 S2 S3 S4
 [1,]  0  3  3  2
 [2,]  0  3  0  3
 [3,]  0  2  3  1
 [4,]  0  2  2  2
 [5,]  0  2  2  1
 [6,]  1  3  1  3
 [7,]  2  1  3  1
 [8,]  3  3  2  0
 [9,]  2  0  3  2
[10,]  1  3  2  1
     [,1] [,2] [,3] [,4]
[1,]    0    0    1    1
[2,]    2    1    1    2
[3,]    1    1    2    2
[4,]    2    2    1    2
[5,]    0    0    1    1
[6,]    2    1    0    0
     S1  S2 
[1,] "0" "1"
[2,] "3" "3"
[3,] "1" "2"
[4,] "2" "3"
[5,] "0" "1"
[6,] "3" "0"

HapEstXXR documentation built on May 1, 2019, 10:54 p.m.