# setting up the directory with exemplary data
dir.in <- system.file( "extdata", package = "Haplin" )
file.in <- file.path( dir.in, "data.dat" )
# reading data in
data.in <- genDataRead( file.in, file.out = "poo_exmpl_data_read", format = "haplin",
dir.out = tempdir( check = TRUE ), n.vars = 1, allele.sep = " ", col.sep = " ",
overwrite = TRUE )
# preprocessing the data
data.preproc <- genDataPreprocess( data.in, design = "triad",
file.out = "poo_exmpl_data_preproc", dir.out = tempdir( check = TRUE ), overwrite = TRUE )
# running haplin, calculating POO
res.POO <- haplin( data.preproc, markers = 2, poo = TRUE, response = "mult",
reference = 2, use.missing = TRUE )
res.POO
if (FALSE) {
# 1. Read the data:
my.haplin.data <- genDataRead( file.in = "HAPLIN.trialdata.txt", file.out =
"trial_data1", dir.out = ".", format = "haplin", n.vars = 0 )
# 2. Run pre-processing:
haplin.data.prep <- genDataPreprocess( data.in = my.haplin.data, format =
"haplin", design = "triad", file.out = "trial_data1_prep", dir.out = "." )
# 3. Analyze:
# Standard run:
haplin( haplin.data.prep )
# Specify path, estimate maternal effects:
haplin( haplin.data.prep, maternal = T )
# Specify path, use haplotype no. 2 as reference:
haplin( haplin.data.prep, reference = 2 )
# Remove more haplotypes from estimation by increasing the threshold
# to 5%:
haplin( haplin.data.prep, threshold = 0.05 )
# Estimate maternal effects, using the most frequent haplotype as reference.
# Use all data, including triads with missing data. Select
# markers 3, 4 and 8 from the supplied data.
haplin( haplin.data.prep, use.missing = T, maternal = T,
reference = "ref.cat", markers = c(3,4,8) )
# Note: in this version of haplin, the jackknife is
# no longer necessary since the standard errors are already corrected.
# Some examples showing how to save the haplin result and later
# recall plot and summary results:
# Same analysis as above, saving the result in the object "result.1":
result.1 <- haplin( haplin.data.prep, use.missing = T, maternal = T,
reference = "ref.cat", markers = c(3,4,8) )
# Replot the saved result (fetal effects):
plot( result.1 )
# Replot the saved result (maternal effects):
plot( result.1, plot.maternal = T )
# Print a very short summary of saved result:
result.1
# A full summary of saved result, with confidence intervals and
# p-values (the same as haplin prints when running):
summary( result.1 )
# Some examples when the data file contains two covariates,
# the second is the case-control variable:
# The following standard triad run is INCORRECT since it disregards
# case status:
haplin("data.dat", use.missing = T, n.vars = 2, design = "triad")
# Combined run on "hybrid" design, correctly using both case-parent
# triads and control-parent triads:
haplin( my.haplin.data, use.missing = T, n.vars = 2, ccvar = 2,
design = "cc.triad" )
# If parent columns are not in the file, a plain case-control
# run can be used:
haplin( my.haplin.data, use.missing = T, n.vars = 2, ccvar = 2,
design = "cc", response = "mult", reference = "ref.cat" )
# An example of how to produce a data file with all possible haplotypes
# identified for each triad, together with their probaility weights:
result.data <- haplin( my.haplin.data, use.missing = T,
markers = c(3,4,8), data.out = "prelim" )
# result.data will then contain the data file, with a vector of
# probabilities (freq) computed from the preliminary haplotype
# frequencies.
}
Run the code above in your browser using DataLab