Learn R Programming

pedtools (version 2.8.0)

as.ped: Conversions to ped objects

Description

Conversions to ped objects

Usage

as.ped(x, ...)

# S3 method for data.frame as.ped( x, famid_col = NA, id_col = NA, fid_col = NA, mid_col = NA, sex_col = NA, marker_col = NA, locusAttributes = NULL, missing = 0, sep = NULL, sexCodes = NULL, addMissingFounders = FALSE, validate = TRUE, verbose = TRUE, ... )

Value

A ped object or a list of such.

Arguments

x

Any object.

...

Not used.

famid_col

Index of family ID column. If NA, the program looks for a column named "famid" (ignoring case).

id_col

Index of individual ID column. If NA, the program looks for a column named "id" (ignoring case).

fid_col

Index of father ID column. If NA, the program looks for a column named "fid" (ignoring case).

mid_col

Index of mother ID column. If NA, the program looks for a column named "mid" (ignoring case).

sex_col

Index of column with gender codes (0 = unknown; 1 = male; 2 = female). If NA, the program looks for a column named "sex" (ignoring case). If this is not found, genders of parents are deduced from the data, leaving the remaining as unknown.

marker_col

Index vector indicating columns with marker alleles. If NA, all columns to the right of all pedigree columns are used. If sep (see below) is non-NULL, each column is interpreted as a genotype column and split into separate alleles with strsplit(..., split = sep, fixed = TRUE).

locusAttributes

Passed on to setMarkers() (see explanation there).

missing

Passed on to setMarkers() (see explanation there).

sep

Passed on to setMarkers() (see explanation there).

sexCodes

A list with optional entries "male", "female" and "unknown", indicating how non-default entries in the sex column should be interpreted. Default values: male = 1, female = 2, unknown = 0.

addMissingFounders

A logical. If TRUE, any parent not included in the id column is added as a founder of corresponding sex. By default, missing founders result in an error.

validate

A logical indicating if the pedigree structure should be validated.

verbose

A logical.

Examples

Run this code
df = data.frame(famid = c("S1", "S2"),
                id = c("A", "B"),
                fid = 0,
                mid = 0,
                sex = 1)

# gives a list of two singletons
as.ped(df)

# Trio
df1 = data.frame(id = 1:3, fid = c(0,0,1), mid = c(0,0,2), sex = c(1,2,1))
as.ped(df1)

# Disconnected example: Trio (1-3) + singleton (4)
df2 = data.frame(id = 1:4, fid = c(2,0,0,0), mid = c(3,0,0,0),
                M = c("1/2", "1/1", "2/2", "3/4"))
as.ped(df2)

# Two singletons
df3 = data.frame(id = 1:2, fid = 0, mid = 0, sex = 1)
as.ped(df3)

# Add missing parents as founders
df4 = data.frame(id = 1, fid = 2, mid = 3, sex = 1)
as.ped(df4, addMissingFounders = TRUE)

Run the code above in your browser using DataLab