Learn R Programming

pedtools (version 2.12.0)

as.data.frame.ped: Convert ped to data frame

Description

Convert a ped object (or a list of such) to a data frame. The first columns are id, fid, mid and sex, followed by genotype columns.

Usage

# S3 method for ped
as.data.frame(x, ..., markers, sep = "/", missing = "-")

# S3 method for pedList as.data.frame(x, ..., markers, sep = "/", missing = "-")

Value

A data frame with 4 + nMarkers(x) columns.

Arguments

x

A ped object or a list of such.

...

Further parameters.

markers

Vector of marker names or indices. By default, all markers are included.

sep

A single string to be used as allele separator in marker genotypes.

missing

A single string to be used for missing alleles.

Details

For lists of pedigrees, use as.data.frame.pedList() directly unless the list has class "pedList". The reason for this convention is to avoid conflicts with existing base::as.data.frame.list() method.

Note the difference between as.data.frame.ped() and as.matrix.ped(), which have different purposes. Conversion to a data frame is primarily intended for pretty printing. It uses correct labels for pedigree members and marker alleles, and pastes alleles to form nice-looking genotypes.

The matrix method, on the other hand, is a handy tool for manipulating the pedigree structure. It produces a numeric matrix, using the internal index labelling both for individuals and alleles, making it very fast. In addition, all necessary meta information (loop breakers, allele frequencies a.s.o) is kept as attributes, which makes it possible to recreate the original ped object.

See Also

as.matrix.ped()

Examples

Run this code
x = nuclearPed() |> addMarker(`3` = "1/2", name = "M")
as.data.frame(x)
as.data.frame(x, markers = NULL)

# Ped list with compatible markers
y = list(x, singleton("X")) |> harmoniseMarkers()
as.data.frame.pedList(y)

Run the code above in your browser using DataLab