Learn R Programming

pbatR (version 0.6)

ped: Pedigree Object

Description

Creates, tests, reads, or writes objects of type ped or pedlist to be used with the pbat commands.

The ped class inherits the list structure, and is almost identical to the list object described to create it, only with some special reserved names.

The pedlist class inherits the data.frame structure, and is almost identical to the data.frame object described to create it, only with some special reserved names.

Usage

as.ped( x,
        idped="idped", idsub="idsub", idfath="idfath",
        idmoth="idmoth", sex="sex", affection="affection" )

as.pedlist( x, idped="idped", idsub="idsub", idfath="idfath", idmoth="idmoth", sex="sex", affection="affection" )

is.ped( obj );

is.pedlist( obj );

read.ped( filename, format="ped", lowercase=TRUE, ... )

write.ped( file, ped )

Arguments

x
An object of class ped, pedlist, data.frame, or list as described below.

If x is of class ped or pedlist, no other options are used. When x<

idped
String corresponding to column name for pedigree id.
idsub
String corresponding to column name for subject id.
idfath
String corresponding to column name for father id.
idmoth
String corresponding to column name for mother id.
sex
String corresponding to column name for sex.
affection
String corresponding to column name for affection status.
filename
Filename to open; does not need .phe extension.
format
Toggles the return structure, set to "ped" or "pedlist".
lowercase
When TRUE, enforces all headers to lowercase for convenience.
...
Options for read.table. Do not put in header=TRUE, as this will cause an error, as the header is automatically loaded. With the proper file formatting, this should
file
string representing filename, or a connection for file output
ped
an object of class ped or pedlist (see as.ped or as.pedlist)
obj
an object

Details

'read.phe' mild warning: This function might change the names of headers, so they may not correspond to what pbat is looking for if you call any of the pbat*files() commands (even if lowercase=FALSE, as some symbols might be modified by R naming conventions).

'read.phe' mild warning solution: For example, instead of using pbat.logrank.files(...), just use the suggested pbat.m(...) or pbat.obj(..) after loading in the '.phe' and '.ped' files.

References

http://www.biostat.harvard.edu/~clange/default.htm http://www.people.fas.harvard.edu/~tjhoffm/pbatR.html

See Also

read.ped, write.ped, as.pedlist

Examples

Run this code
# A highly artificial example with not enough subjects to be run;
#  however, it demonstrates how to put data in it.
x <- data.frame( idped =     c(1,1,1,1,1),
                 idsub =     c(1,2,3,4,5),
                 idfath =    c(4,4,4,0,0),
                 idmoth =    c(5,5,5,0,0),
                 sex =       c(1,2,1,1,2),
                 affection = c(1,0,0,1,0),
                 m1.a =      c(1,1,4,4,4),
                 m1.b =      c(2,3,2,2,3),
                 m2.a =      c(4,4,4,4,4),
                 m2.b =      c(1,1,1,4,1) )
x
myPed <- as.ped( x )          # Mark it with the class 'ped'
myPedlist <- as.pedlist( x )  # Instead mark it with 'pedlist'
myPed
myPedlist

# an alternate example of creating
names( x )[1:6] <- c( "mypedid", "subid", "fathid",
                      "mothid", "gender", "affection" );
x
myPed <- as.ped( x, idped="mypedid", idsub="subid", idfath="fathid",
                 idmoth="mothid", sex="gender" ) # affection need not be
                                                 #  specified here
myPed  # Note it's the same as before!

myPed <- as.ped( myPedlist )       # Easy conversion back
myPedlist <- as.pedlist( myPed )   #  and forth between formats.

Run the code above in your browser using DataLab