editPed: Complete and Order a Pedigree

Description Usage Arguments Details Value Examples

View source: R/pedigree.R

Description

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

Usage

1
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
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  #(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([email protected], [email protected], [email protected])
# 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))

Example output

Loading required package: lme4
Loading required package: Matrix
   sire  dam label
4  <NA> <NA>     4
11    8 <NA>    11
5  <NA> <NA>     5
7     3    2     7
10    4    7    10
2  <NA> <NA>     2
12    1    9    12
13   10    9    13
8     5 <NA>     8
9     6    7     9
6     1    2     6
1  <NA> <NA>     1
3  <NA> <NA>     3
14    8   13    14
   label sire  dam gene
1      4 <NA> <NA>    0
3      5 <NA> <NA>    0
6      2 <NA> <NA>    0
12     1 <NA> <NA>    0
13     3 <NA> <NA>    0
4      7    3    2    1
9      8    5 <NA>    1
11     6    1    2    1
2     11    8 <NA>    2
5     10    4    7    2
10     9    6    7    2
7     12    1    9    3
8     13   10    9    3
14    14    8   13    4
   sire  dam label
7     8 <NA>    11
1  <NA> <NA>     5
8     1    9    12
9    10    9    13
3     3    2     7
4     5 <NA>     8
5     6    7     9
6     4    7    10
2     1    2     6
10    8   13    14
   label sire  dam gene
1      1 <NA> <NA>    0
2      2 <NA> <NA>    0
3      3 <NA> <NA>    0
4      4 <NA> <NA>    0
6      5 <NA> <NA>    0
9      7    3    2    1
10     8    5 <NA>    1
13     6    1    2    1
5     11    8 <NA>    2
11     9    6    7    2
12    10    4    7    2
7     12    1    9    3
8     13   10    9    3
14    14    8   13    4

pedigreemm documentation built on May 2, 2019, 1:07 p.m.