Giter Site home page Giter Site logo

magnusdv / ribd Goto Github PK

View Code? Open in Web Editor NEW
6.0 4.0 1.0 851 KB

Computation of pedigree-based relatedness coefficients. Part of the ped suite packages for pedigree analysis in R

Home Page: https://magnusdv.github.io/pedsuite/

R 100.00%
relatedness kinship pedigree-analysis inbreeding-coefficient

ribd's People

Contributors

magnusdv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

dpcscience

ribd's Issues

twoLocusIBD

Documented but not exported?!:

ribd::twoLocusIBD
#> Error: 'twoLocusIBD' is not an exported object from 'namespace:ribd'

Created on 2019-04-05 by the reprex package (v0.2.1)

Shorter kinship lines

Implementation of shorter kinship lines, e.g. restricted to the triangle itself, when using ibdTriangle() would be great!

`twoLocusIdentity` fails for founders

x = pedtools::nuclearPed(1)
j2 = ribd::twoLocusIdentity(x, c(1,3), rho = 0) # OK, but
ribd::twoLocusIdentity(x, c(1,2), rho = 0)
#> Error in if (mem$isCompletelyInbred[a] && mem$isCompletelyInbred[b]) RES[2, : missing value where TRUE/FALSE needed

Created on 2019-11-14 by the reprex package (v0.3.0)

`twoLocusIdentity()` example suggested

Here's an example that runs nicely:

library(ribd, quietly = TRUE)
#> 
#> Attaching package: 'ribd'
#> The following object is masked from 'package:base':
#> 
#>     kappa
x1 = halfCousinPed(1)
j2.1 = twoLocusIdentity(x1, ids = leaves(x1), rho = 0.25)
x2 = halfCousinPed(0, removal = 2)
j2.2 = twoLocusIdentity(x2, ids = leaves(x2), rho = 0.25)
stopifnot(all(j2.1 == j2.2))

Created on 2019-09-01 by the reprex package (v0.3.0)

Comments on README

Nice update of README!

Change to ids in inbreeding(x, id = 9).

The command showInTriangle(kappaIBD(z, 7:8)) does not give the text (1/8, 1/8) in the last plot when I run it.

`ibd_inbreeding` and founders

I wonder if the inbreeding coefficient of individual 1 below should be 1:

library(ribd)
#> Loading required package: pedtools
x = nuclearPed(1)
founder_inbreeding(x, "1") = 1
ibd_inbreeding(x)
#> 1 2 3 
#> 0 0 0

Created on 2019-01-21 by the reprex package (v0.2.1)

kappaIbd() and inbred founder (grandparent-grandchild)

Why are not the IBD coefficients computed for a granparent-granchild relationship where the grandparent has an inbreeding coefficient f? I was thinking that even though the founder (grandparent) is inbreed, kappa still applies and the coefficients can be computed. No error that the grandparent and grandchild are inbred occurs, but the answer is (NA,NA,NA).

library(pedtools)
library(ribd)
#>
#> Attaching package: 'ribd'
#> The following object is masked from 'package:base':
#>
#> kappa
x = nuclearPed(1)
x = addChildren(x,father = 3)
#> Mother: Creating new individual with ID = 4
founderInbreeding(x,1) = 0.1
k = kappaIbd(x,ids = c(1,5))
k
#> [1] NA NA NA

`showInTriangle`

When I run the below commands from Lecture4, Norbis 2022, I get two extra points, one for the mean,
and one for the standard deviation.
I understand why when I read the documentation of showInTriangle ("an attempt is made to bind the elements row-wise"),
but perhaps it should be easier to avoid this error?!
With the current code, the last line below should be
showInTriangle(k$perSimulation)

library(ibdsim2, quietly = T)
x = nuclearPed(2)
s = ibdsim(x, N = 2, seed = 1729, verbose = F)
k = realisedKappa(s, ids = c(3, 4))
ribd::showInTriangle(k)

Created on 2022-07-07 by the reprex package (v2.0.1)

ibd_kappa and sibs with inbred, unrelated, parents

ibd_kappa suprises me below, not ibd_identity:

library(ribd, quietly = TRUE)
x = nuclearPed(2, father = "FA", mother = "MO",  children = c("B1", "B2"))
f1 = 0.1
f2 = 0.2
f = c(f1, f2)
founder_inbreeding(x, c("FA", "MO")) = f
ibd_kappa(x, ids = c("B1", "B2"))
#> Inbred individuals: B1, B2
#> The kappa coefficients are undefined for inbred individuals.
#> [1] NA NA NA

f00 = (1-f1)*(1-f2)
f10 = f1*(1-f2)
f01 = (1-f1)*f2
f11 = f1*f2

k0 = f00*0.25
k1 = f00*0.5+f10*0.5+f01*0.5
k2 = f00*0.25+f10*0.5+f01*0.5+f11
k = c(k0, k1, k2)
j = ibd_identity(x, ids= c("B1", "B2"))[9:7]
k-j
#> [1] -1.387779e-16  2.775558e-16  0.000000e+00

Created on 2019-01-22 by the reprex package (v0.2.1)

0 or NA?

I'm not sure I understand when 0 or NA-s are returned from
condensedIdentityX. Could one argue that the rowsums of the returned matix should
add to 1 (?) and that therefore 0 is more reasonable than NA-s in e.g.

library(ribd, quietly = TRUE)
#> 
#> Attaching package: 'ribd'
#> The following object is masked from 'package:base':
#> 
#>     kappa
x = nuclearPed(1)
condensedIdentityX(x, c(3,3)) 
#> [1]  1  0 NA NA NA NA NA NA NA

Created on 2019-03-23 by the reprex package (v0.2.1)

`constructPedigree` output

Should it be "... inbreeding 0.33 and 1" below as shown if y is plotted?

y = ribd::constructPedigree(kappa = c(0,1,2)/3)
#> Result:
#>   (Corner case with half-cousin degrees m = n = 0)
#>   Full siblings; founder inbreeding 0.33 and 0.33

Created on 2020-07-25 by the reprex package (v0.3.0)

NA-s and more

I've started trying ribd - great stuff!
When I run the following example in the man file

library(pedtools)
x = fullSibMating(2)
x_brothers = swapSex(x, 6)
ibd_identity_x(x_brothers, ids = 5:6)

I don't get the NA-s entries announced under Value in the documentation.
A simillar comment applies to male-female pairs.
Later: I think I managed to find a problem:

x = halfSibStack(2)
ibd_identity(x, ids = c(4,5))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.