Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

freqDatabase

Allele frequency database


Description

Functions for reading, setting and extracting allele frequency databases, in either "list" format or "allelic ladder" format.

Usage

getFreqDatabase(x, markers = NULL, format = c("list", "ladder"))

setFreqDatabase(x, database, format = c("list", "ladder"), ...)

readFreqDatabase(filename, format = c("list", "ladder"), ...)

writeFreqDatabase(x, filename, markers = NULL, format = c("list", "ladder"))

setFrequencyDatabase(...)

getFrequencyDatabase(...)

readFrequencyDatabase(...)

writeFrequencyDatabase(...)

Arguments

x

A ped object, or a list of such.

markers

A character vector (with marker names) or a numeric vector (with marker indices).

format

Either "list" or "ladder".

database

Either a list or matrix/data frame with allele frequencies, or a file path (to be passed on to readFreqDatabase()).

...

Optional arguments passed on to read.table().

filename

The path to a text file containing allele frequencies either in "list" or "allelic ladder" format.

Details

A frequency database in "list" format is a list of numeric vectors; each vector named with the allele labels, and the list itself named with the marker names.

Text files containing frequencies in "list" format should look as follows, where "marker1" and "marker2" are marker names, and "a1","a2",... are allele labels (which may be characters or numeric, but will always be converted to characters):

marker1
a1 0.2
a2 0.5
a3 0.3

marker2
a1 0.9
a2 0.1

A database in "allelic ladder" format is rectangular, i.e., a numeric matrix (or data frame), with allele labels as row names and markers as column names. NA entries correspond to unobserved alleles.

Value

  • getFreqDatabase: either a list (if format = "list") or a data frame (if format = "ladder")

  • readFreqDatabase: a list (also if format = "ladder") of named numeric vectors

  • setFreqDatabase: a modified version of x

See Also

Examples

loc1 = list(name = "m1", afreq = c(a = .1, b = .9))
loc2 = list(name = "m2", afreq = c("1" = .2, "10.2" = .3, "3" = .5))
x = setMarkers(singleton(1), locus = list(loc1, loc2))
db = getFreqDatabase(x)
db

y = setFreqDatabase(x, database = db)
stopifnot(identical(x, y))

# The database can also be read directly from file
tmp = tempfile()
write("m1\na 0.1\nb 0.9\n\nm2\n1 0.2\n3 0.5\n10.2 0.3", tmp)

z = setFreqDatabase(x, database = tmp)
stopifnot(all.equal(x, z))

pedtools

Creating and Working with Pedigrees and Marker Data

v0.9.7
GPL-3
Authors
Magnus Dehli Vigeland [aut, cre] (<https://orcid.org/0000-0002-9134-4962>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.