editPed {pedigreemm}R Documentation

Complete and Order a Pedigree

Description

This function helps to prepare a pedigree to generate a pedigree object

Usage

editPed(sire, dam, label, verbose)

Arguments

sire

a vector (with some NA entries) with the father IDs

dam

similarly as sire for the “mother” of each entry. The vector must be of the same length than the one for the sire

label

a vector with the subjects id. Giving a unique ID for the corresponding entry. The length as sire and dam should be the same

verbose

logical entry inquiring whether to print line that the program is evaluating. The default is FALSE.

Details

The function takes a vector of sires, another for dams and a final one for subjects all of the same length, convert them to character. If there are dams or sires not declared as subjects the function generates them. Finally, it orders the pedigree. The output can be used to build a pedigree object ped

Value

A data frame with strings as characters. All subjects are in the label column, and all subjects will appear in this column before appering as sires or dams.

Examples

  #(1)
  pede<-data.frame(sire=as.character(c(NA,NA,NA,NA,NA,1,3,5,6,4,8,1,10,8)),
             dam= as.character(c(NA,NA,NA,NA,NA,2,2,NA,7,7,NA,9,9,13)),
             label=as.character(1:14))
   #scrambled original pedigree:
   (pede<- pede[sample(replace=FALSE, 1:14),]  )
   (pede<- editPed(sire=pede$sire, dam= pede$dam, label=pede$label)) 
   ped<- with(pede, pedigree(label=label, sire=sire, dam=dam))
#################################################################################################
   #(2) With missing labels
   pede<-data.frame(sire=as.character(c(NA,1,3,5,6,4,8,1,10,8)),
             dam= as.character(c(NA,2,2,NA,7,7,NA,9,9,13)),
             label=as.character(5:14))
   #scrambled original pedigree:
   (pede<- pede[sample(replace=FALSE, 1:10),]  )
   (pede<- editPed(sire=pede$sire, dam= pede$dam, label=pede$label)) 
   ped<- with(pede, pedigree(label=label, sire=sire, dam=dam))

#################################################################################################
   #(2) A larger pedigree
 #Useing pedCows pedigree
# str(pedCows)
# pede<-data.frame(id=pedCows@label, sire=pedCows@sire, dam=pedCows@dam)
# pede<-pede[sample(1:nrow(pede),replace=FALSE),]
# pede<- editPed(sire=pede$sire, dam=pede$dam, label=pede$id)
# ped<- with(pede, pedigree(label=label, sire=sire, dam=dam))

[Package pedigreemm version 0.3-4 Index]