data.import:

Usage Arguments Examples

Usage

1
data.import(ped, tped, gwas_id, gwas_p, pvalue = 0.05, id.select = ped[, 2])

Arguments

ped
tped
gwas_id
gwas_p
pvalue
id.select

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
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (ped, tped, gwas_id, gwas_p, pvalue = 0.05, id.select = ped[, 
    2]) 
{
    a.s <- ped[, c(2, 7:ncol(ped))]
    snp <- rep((as.character(tped[, 2])), each = 2)
    snp <- append(snp, "ID", after = 0)
    colnames(a.s) <- c(snp)
    gwas.select <- cbind(gwas_id, gwas_p)
    gwas.select <- as.data.frame(gwas.select)
    gwas.select$gwas_p <- as.numeric(as.character(gwas.select$gwas_p))
    p.select <- gwas.select[gwas.select$gwas_p < pvalue, ]
    snp.select <- p.select$gwas_id
    snps <- rep(snp.select, each = 2)
    snps <- append(as.character(snps), "ID", after = 0)
    a.snps <- a.s[, snps]
    rownames(a.snps) <- a.snps[, 1]
    input <- a.snps[, 2:ncol(a.snps)]
    ind <- data.frame(matrix(c((1:ncol(input)), rep(NA, 2 - ncol(input)%%2)), 
        byrow = F, nrow = 2))
    nonna <- ind[, sapply(ind, function(x) all(!is.na(x)))]
    genotype <- do.call(cbind, lapply(nonna, function(i) rowMeans(input[, 
        i])))
    x <- colnames(input[1:(ncol(input) - 1)])
    colnames(genotype) <- x[c(T, F)]
    genotype <- replace(genotype, genotype == 0, "NA")
    return(as.data.frame(genotype))
  }

victorcarmelo/WISH_beta documentation built on May 3, 2019, 6:11 p.m.