R Under development (unstable) (2025-09-02 r88773 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > require(kinship2) Loading required package: kinship2 Loading required package: Matrix Loading required package: quadprog Warning: kinship2 package is deprecated for R <= 4.5; switch functionality to Pedixplorer from BioConductor> > twindat <- c(1,3,4,2, + 2,0,0,1, + 3,8,7,1, + 4,6,5,2, + 5,0,0,2, + 6,0,0,1, + 7,0,0,2, + 8,0,0,1, + 100,3,4,1, + 101,3,4,2, + 102,3,4,2, + 103,3,4,2, + 104,3,4,2, + 105,3,4,2, + 106,3,4,2, + 107,0,0,1, + 108,0,0,1, + 201,2,1,1, + 202,2,1,1, + 203,2,1,1, + 204,2,1,1, + 205,107,102,1, + 206,108,103,2) > twindat <- matrix(twindat, ncol=4, byrow=T) > dimnames(twindat) <- list(NULL, c('id', 'dadid', 'momid', 'sex')) > twindat <- data.frame(twindat) > > relate=data.frame(id1=c(101,102,101,104,203), id2=c(102,103,103,105,204), + code=c(1,1,1,2,1)) > # > # Renumber everyone as 1,2,....; makes the all.equal checks easier > indx <- sort(unique(unlist(twindat[,1:3]))) > twindat$id <- match(twindat$id, indx) -1 > twindat$dadid <- match(twindat$dadid, indx) -1 > twindat$momid <- match(twindat$momid, indx) -1 > relate$id1 <- match(relate$id1, indx) -1 > relate$id2 <- match(relate$id2, indx) -1 > > # Build the pedigree and kinship > tped <- with(twindat, pedigree(id, dadid, momid, sex, + relation=relate)) > kmat <- kinship(tped) > > truth <- matrix(c(5,6, 0, + 5,4, .25, #parent child + 10,11,.5, # mz twins + 22,12, .25, # aunt, mz with mother + 22, 13, .125, # aunt, dz + 13, 14, .25, # dz twins + 20, 21, .5, # mz twins + 19, 16, 0 , # marry in uncle + 19, 11, .125, # aunt who is a twin + 19, 3, .125), #grandmother + byrow=T, ncol=3) > > all.equal(kmat[truth[,1:2]], truth[,3]) [1] TRUE > > proc.time() user system elapsed 0.84 0.07 0.87