Learn R Programming

pedtools (version 0.9.0)

freqDatabase: Allele frequency database

Description

Extract or set marker allele frequencies using the 'allelic ladder' format

Usage

getFrequencyDatabase(x, markers = NULL)

setFrequencyDatabase(x, database, ...)

Arguments

x

A ped object, or a list of such

markers

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

database

Either a data.frame or a character file path. See details.

...

Optional arguments passed on to read.table()

Value

  • getFrequencyDatabase : a data.frame with allele labels as row names, and marker labels as column names

  • getFrequencyDatabase: a modified version of x

Details

These functions are essentially special cases of getLocusAttributes() and setLocusAttributes().

If database is a data.frame, it must have the allele labels as row names and marker names as column names.

If database is a file path, it is read with the command read.table(database, header = T, row.names = 1, as.is = T, check.names = F, ...)

See Also

setLocusAttributes(), setMarkers(), setAlleles()

Examples

Run this code
# NOT RUN {
loc1 = list(name = "m1", alleles = 3:4, afreq = c(.1, .9))
loc2 = list(name = "m2", alleles = c("1", "10.2", "3"))
x = setMarkers(singleton(1), locus = list(loc1, loc2))
db = getFrequencyDatabase(x)
db

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

# The database can also be read directly from file
tmp = tempfile()
write.table(db, tmp, row.names = TRUE, col.names = TRUE)

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

# }

Run the code above in your browser using DataLab