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> # > # Test some twins data from Curtis Oswold > # > 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) > > ## set up a fraternal twin set, and a set of triplets with kids from > ## their marriages to test kinship coeff > relate=data.frame(id1=c(101,102,104,203), id2=c(102,103,105,204), code=c(1,1,2,1)) > > tped <- with(twindat, pedigree(id, dadid, momid, sex, + relation=relate)) > > > ## plot(tped) > > ## should show kinship coeff of 0.5 for where MZ twins are > ## ids: 102-103 and 203-204 > kinmat <- kinship(tped) > > kinmat[c(10:16,19:23),c(10:16,19:23)] 101 102 103 104 105 106 107 202 203 204 205 206 101 0.500 0.500 0.500 0.250 0.250 0.250 0.00 0.1250 0.1250 0.1250 0.2500 0.2500 102 0.500 0.500 0.500 0.250 0.250 0.250 0.00 0.1250 0.1250 0.1250 0.2500 0.2500 103 0.500 0.500 0.500 0.250 0.250 0.250 0.00 0.1250 0.1250 0.1250 0.2500 0.2500 104 0.250 0.250 0.250 0.500 0.250 0.250 0.00 0.1250 0.1250 0.1250 0.1250 0.1250 105 0.250 0.250 0.250 0.250 0.500 0.250 0.00 0.1250 0.1250 0.1250 0.1250 0.1250 106 0.250 0.250 0.250 0.250 0.250 0.500 0.00 0.1250 0.1250 0.1250 0.1250 0.1250 107 0.000 0.000 0.000 0.000 0.000 0.000 0.50 0.0000 0.0000 0.0000 0.2500 0.0000 202 0.125 0.125 0.125 0.125 0.125 0.125 0.00 0.5000 0.2500 0.2500 0.0625 0.0625 203 0.125 0.125 0.125 0.125 0.125 0.125 0.00 0.2500 0.5000 0.5000 0.0625 0.0625 204 0.125 0.125 0.125 0.125 0.125 0.125 0.00 0.2500 0.5000 0.5000 0.0625 0.0625 205 0.250 0.250 0.250 0.125 0.125 0.125 0.25 0.0625 0.0625 0.0625 0.5000 0.1250 206 0.250 0.250 0.250 0.125 0.125 0.125 0.00 0.0625 0.0625 0.0625 0.1250 0.5000 > > > > > ## simple test case for kinship of MZ twins from Claus Ekstrom, 9/2012 > mydata <- data.frame(id=1:4, dadid=c(NA, NA, 1, 1), + momid=c(NA, NA, 2, 2), sex=c("male", "female", "male", "male"), + famid=c(1,1,1,1)) > relation <- data.frame(id1=c(3), id2=c(4), famid=c(1), code=c(1)) > > x <- pedigree(id=mydata$id, dadid=mydata$dadid, momid=mydata$momid, sex=mydata$sex, relation=relation) > > #plot(x) > > kinout <- kinship(x) > kinship2:::kinship.pedigree(x) 1 2 3 4 1 0.50 0.00 0.25 0.25 2 0.00 0.50 0.25 0.25 3 0.25 0.25 0.50 0.50 4 0.25 0.25 0.50 0.50 > > > proc.time() user system elapsed 0.84 0.07 0.89