[R] Help with pedigree() function in kinship2

Therneau, Terry M., Ph.D. therneau at mayo.edu
Wed May 13 15:00:52 CEST 2015


Your problem is that PatientID, FatherID, MotherID are factors.  The authors of kinship2 
(myself and Jason) simply never thought of someone doing this.  Yes, that is an oversight. 
  We will correct it by adding some more checks and balances.  For now, turn your id 
variables into character or numeric.

Terry Therneau


On 05/13/2015 05:00 AM, r-help-request at r-project.org wrote:
> Dear R-help,
>
> I am interested in plotting some pedigrees and came across the kinship2
> package. What follows is an example of the pedigrees I am working with
> Now, when running
>
> ## check package availability
> if(!require(kinship2)) install.packages('kinship2')
> require(kinship2)
>
>
> ## data to plot
> d <- structure(list(FamilyID = c("1", "1", "1", "1", "1", "1", "1",
> "1", "1"), PatientID = structure(c(2L, 3L, 5L, 11L, 12L, 15L,
> 16L, 17L, 6L), .Label = c(" 1", " 2", " 3", " 4", " 5", " 6",
> " 7", " 9", "10", "11", "13", "14", "18", "20", "23", "24", "25",
> "27", "28", "29", "30", "31", "33", "34", "35", "37", "38", "39",
> "41", "43", "45", "50", "62", "63", "64", "65", "66", "67", "85",
> "88"), class = "factor"), FatherID = structure(c(1L, 1L, 6L,
> 1L, 5L, 6L, 1L, 7L, 6L), .Label = c("0", "1", "10", "11", "13",
> "2", "23", "27", "28", "3", "33", "34", "35", "38", "5", "62",
> "64", "66", "9"), class = "factor"), MotherID = structure(c(1L,
> 1L, 7L, 1L, 14L, 7L, 1L, 5L, 7L), .Label = c("0", "10", "18",
> "2", "24", "29", "3", "30", "33", "34", "39", "4", "43", "5",
> "6", "63", "65", "9"), class = "factor"), Sex = structure(c(2L,
> 1L, 1L, 2L, 2L, 2L, 1L, 2L, 2L), .Label = c("Female", "Male"), class =
> "factor"),
>      AffectionStatus = structure(c(1L, 1L, 2L, 1L, 2L, 2L, 1L,
>      2L, 2L), .Label = c("1", "2"), class = "factor")), .Names =
> c("FamilyID",
> "PatientID", "FatherID", "MotherID", "Sex", "AffectionStatus"
> ), row.names = c(NA, 9L), class = "data.frame")
>
> ## plotting
> ped <- with(d, pedigree(PatientID, FatherID, MotherID, Sex,  affected =
> AffectionStatus, famid = FamilyID))
>
> ## Error in pedigree(PatientID, FatherID, MotherID, Sex, affected =
> AffectionStatus,  :
> ##                    Value of 'dadid' not found in the id list 1/0 1/0 1/2
> 1/0 1/2
>
> I get an error.  My sessionInfo() is at the end.  I was wondering if
> someone could help me to dissect what the cause of this error is and how it
> can be fixed.
>
> Thank you very much for your help.
>
> Best regards,
> Jorge Velez.-



More information about the R-help mailing list