as.ped: Conversions to ped objects

View source: R/ped_convert.R

as.pedR Documentation

Conversions to ped objects

Description

Conversions to ped objects

Usage

as.ped(x, ...)

## S3 method for class '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,
  validate = TRUE,
  ...
)

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).

validate

A logical indicating if the pedigree structure should be validated.

Value

A ped object or a list of such.

Examples

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)


pedtools documentation built on Nov. 5, 2023, 5:06 p.m.