magnusdv / ribd Goto Github PK
View Code? Open in Web Editor NEWComputation of pedigree-based relatedness coefficients. Part of the ped suite packages for pedigree analysis in R
Home Page: https://magnusdv.github.io/pedsuite/
Computation of pedigree-based relatedness coefficients. Part of the ped suite packages for pedigree analysis in R
Home Page: https://magnusdv.github.io/pedsuite/
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)
library(ribd)
#> Loading required package: pedtools
x = list(singleton(1), singleton(1))
inbreeding(x)
#> 1 1
#> 0 -1
kinship(x)
#> 1 1
#> 1 0.5 0
#> 1 0.0 0
Created on 2023-08-18 with reprex v2.0.2
library(ribd)
library(pedtools)
x = halfSibStack(2)
ibd_identity(x, ids = c(4,5))
#> Error in `[<-`(`*tmp*`, i, i, i, value = (1 + 3 * fi)/4): subscript out of bounds
(Copied from magnusdv/forrel#3 (comment))
Implementation of shorter kinship lines, e.g. restricted to the triangle itself, when using ibdTriangle() would be great!
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)
Generate error?:
ribd::detailed2condensed(rep(1,15))
#> [1] 1 1 2 1 2 1 2 4 1
Created on 2022-04-19 by the reprex package (v2.0.1)
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)
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.
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)
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
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
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)
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)
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)
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))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.