Learn R Programming

paramlink (version 0.8-3)

merlin: MERLIN wrapper function

Description

This function requires MERLIN to be installed and correctly pointed to in the PATH environment variable. The required input files are automatically created (in the working directory) and deleted afterwards. The MERLIN command is executed via a call to system().

Usage

merlin(x, markers=seq_len(x$nMark), model=TRUE, theta=NULL, 
       options="", verbose=FALSE, generate.files=TRUE, 
       cleanup=generate.files, outputfile="")

Arguments

x
a linkdat object
markers
an integer vector indicating which markers to use (default: all).
model
a logical: If TRUE (and x$model is not NULL), the file "merlin.model" is created and "--model merlin.model" is included to the MERLIN command.
theta
a numeric with values between 0 and 0.5: The recombination value(s) for which the LOD score is computed. The values of theta are converted to centiMorgan positions using the Haldande map function and included in the MERLIN command using the
options
a character with additional options to the MERLIN command. See details.
verbose
a logical: Show MERLIN output and other information, or not.
generate.files
a logical. If TRUE, the files "merlin.ped", "merlin.dat", "merlin.map", "merlin.freq" and (if model=TRUE) "merlin.model" are created in the working directory.
cleanup
a logcical: Should the files be deleted automatically after the MERLIN run?
outputfile
a character. If this is given, the MERLIN output will be written to a file with this name.

Value

  • If model=TRUE, a linkres object. Otherwise a character containing the complete MERLIN output.

Details

For this function to work, MERLIN must be installed and the path to merlin.exe included in the PATH variable. The function is first and foremost a wrapper to the parametric linkage functionality of MERLIN. By default the following MERLIN command is run (via a call to system) after creating appropriate files in the current working directory: merlin -p merlin.ped -d merlin.dat -m merlin.map -f merlin.freq --model merlin.model The resulting multipoint LOD scores are extracted from the output and returned in R as a linkres object. Additional command parameters can be passed on using the options argument (this is simply pasted onto the MERLIN command, so dashes must be included). For example, to obtain singlepoint LOD scores instead of multipoint, set options="--singlepoint". (The singlepoint scores should agree with the results of lod(x), except in cases where some individuals have partial genotypes (see Examples).) If model=FALSE the --model merlin.model part is removed from the MERLIN command above. This is necessary for some calculations, e.g. likelihoods (see Examples).

References

http://www.sph.umich.edu/csg/abecasis/Merlin/

Examples

Run this code
data(toyped)
x = linkdat(toyped, model=1)
x

# MERLIN treats partial genotypes (i.e. one known and one unknown allele) as missing:
lod_merlin = merlin(x)
lod_partial = lod(x)
x = modifyMarker(x, marker=1, ids=1, genotype=0)
lod_missing = lod(x)
stopifnot(lod_merlin == round(lod_missing, 3))

# Likelihood computation by MERLIN:
merlin(x, model=F, options="--lik")

Run the code above in your browser using DataLab