ImputeRandom: Impute missing values

Description Usage Arguments Value Examples

View source: R/imputation.R

Description

ImputeRandom imputes missing values with the Q ancestry coeficient matrix and G ancestral frequencies estimates. Missing values are sampled with the estimated genotype frequencies (P = Q G^T).

ImputeRound imputes missing values with the Q ancestry coeficient matrix and G ancestral frequencies estimates. Missing values are computed as a round of estimated genotype frequencies (P = Q G^T).

Usage

1
2
3
ImputeRandom(tess3.res, masked.X)

ImputeRound(tess3.res, masked.X)

Arguments

tess3.res

tess3Main object with Q and G estimates.

masked.X

Genotype matrix with the missing values (NA values).

Value

the imputed genotype matrix.

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
library(tess3r)

n <- 100
K <- 3
ploidy <- 2
L <- 3001
data.list <- SampleGenoFromGenerativeModelTESS3(G = SampleUnifDirichletG(L, ploidy, K),
                                                Q = SampleUnifQ(n, K),
                                                coord = SampleNormalClusterCoord(n.by.pop = n, K = 1),
                                                ploidy = ploidy)
# mask data
set.seed(0)
masked.prop <- 0.1
masked.X <- data.list$X
masked.X[sample(1:(ncol(masked.X)*nrow(masked.X)), (ncol(masked.X)*nrow(masked.X)) * masked.prop)] <- NA


# run tess3
tess3.obj <- tess3(X = masked.X,
                   coord = data.list$coord,
                   K = 3,
                   ploidy = 2,
                   lambda = 1.0,
                   method = "projected.ls",
                   rep = 2)

imputed.X.random <- ImputeRandom(Gettess3res(tess3.obj,3), masked.X)
mean(data.list$X[is.na(masked.X)] != imputed.X.random[is.na(masked.X)]) # pourcentage of error

imputed.X.round <- ImputeRound(tess3.res = Gettess3res(tess3.obj,3), masked.X)
mean(data.list$X[is.na(masked.X)] != imputed.X.round[is.na(masked.X)]) # pourcentage of error

cayek/TESS3_encho_sen documentation built on July 3, 2017, 4:26 p.m.