signaturescience / skater

SKATE R Utilities
https://signaturescience.github.io/skater/
Other
9 stars 5 forks source link

Potential issue with ped2kinpair #17

Closed genignored closed 3 years ago

genignored commented 3 years ago

I think there's an issue with the ped2kinpair() function in skater.

the pedigree looks like so:

>kinship2::as.data.frame.pedigree(testPed)
                  id             dadid             momid    sex affected
1  testped1_g1-b1-s1                 0                 0 female        1
2  testped1_g1-b1-i1                 0                 0   male        1
3  testped1_g2-b1-s1                 0                 0   male        1
4  testped1_g2-b1-i1 testped1_g1-b1-i1 testped1_g1-b1-s1 female        1
5  testped1_g2-b1-i2 testped1_g1-b1-i1 testped1_g1-b1-s1   male        1

But when I run it through the function, we get relationships that don't make sense:

> skater::ped2kinpair(testPed)
# A tibble: 15 x 3
   id1               id2                   k
   <chr>             <chr>             <dbl>
 1 testped1_g1-b1-s1 testped1_g1-b1-s1  0.5 
 2 testped1_g1-b1-i1 testped1_g1-b1-s1  0   
 3 testped1_g1-b1-s1 testped1_g2-b1-s1  0   
 4 testped1_g1-b1-s1 testped1_g2-b1-i1  0.25
 5 testped1_g1-b1-s1 testped1_g2-b1-i2  0.25
 6 testped1_g1-b1-i1 testped1_g1-b1-i1  0.5 
 7 testped1_g1-b1-i1 testped1_g2-b1-s1  0   
 8 testped1_g1-b1-i1 testped1_g2-b1-i1  0.25
 9 testped1_g1-b1-i1 testped1_g2-b1-i2  0.25
10 testped1_g2-b1-s1 testped1_g2-b1-s1  0.5 
11 testped1_g2-b1-i1 testped1_g2-b1-s1  0   
12 testped1_g2-b1-i2 testped1_g2-b1-s1  0   
13 testped1_g2-b1-i1 testped1_g2-b1-i1  0.5 
14 testped1_g2-b1-i1 testped1_g2-b1-i2  0.25
15 testped1_g2-b1-i2 testped1_g2-b1-i2  0.5 

g1_b1-s1 to g1_b1-s1 should be 1, if it displays at all, g1_b1-s1 to g1_b1-i1 should be 0

Thoughts?

stephenturner commented 3 years ago

I'm not seeing the issue. The second line above shows g1-b1-i- and g1-b1-s1 have kinship coefficient 0, as they should, given that they're not related in the fam file.

 2 testped1_g1-b1-i1 testped1_g1-b1-s1  0   

g1-b1-s1 to itself is 0.5, as it should be. Monozygotic twins have a kinship coefficient of 0.5. You actually have a kinship coefficient of 0.5 to yourself.

Remember, the kinship coefficient is defined as the probability that two alleles drawn at random from a pair of individuals are IBD. So, given two alleles, M and D, you could draw MM (IBD) MD (not IBD), DM (not IBD) DD (IBD). = 0.5.

Closing - @genignored please reopen if I've missed something obvious!