Coder Social home page Coder Social logo

segregatr's Introduction

segregatr

CRAN status

The goal of segregatr is to provide segregation analysis for clinical variant classification. For a real-case diagnostic application of the package, see Ratajska et al (2023). The use of segregation analysis in interpretation of sequence variants in SMAD3.

Installation

You can install segregatr from CRAN as follows:

install.packages("segregatr")

Alternatively, obtain the latest development version from GitHub:

devtools::install_github("magnusdv/segregatr")

Example

library(segregatr)

The family below shows four brothers, all affected with a rare dominant disease with 90% penetrance and phenocopy rate 1%. The parents have unknown affection status. All four brothers are shown to carry a candidate variant.

We will use segregatr to analyse the co-segregation of the variant and the disease in this pedigree. Specifically we want to compute the full-likelihood Bayes factor (FLB), quantifying the evidence that the variant is pathogenic.

To create the pedigree we use the nuclearPed() function from the pedtools package, which is automatically loaded together with segregatr.

x = nuclearPed(4)

Then we run the FLB() function, filling in the necessary data:

FLB(x, carriers = 3:6, affected = 3:6, unknown = 1:2,
    freq = 0.0001, penetrances = c(0.01, 0.9, 0.9), proband = 3)
#> [1] 7.732161

The resulting FLB score amounts to suggestive evidence for pathogenicity, according to the thresholds suggested by Jarvik and Browning (2016).

segregatr's People

Contributors

chrcarrizosa avatar magnusdv avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

chrcarrizosa

segregatr's Issues

Liability classes in looped pedigrees

library(segregatr)
#> Loading required package: pedtools

y = cousinPed(1, child = T)

FLB(y, 
    homozygous = 9,
    aff = 9, 
    freq = 0.0001,
    proband = 9,
    penetrances = c(0.01, 0.01, 0.99), 
    liability = rep(1, 9),
    plot = TRUE)
#> Error: Liability classes are not yet implemented when `x` has loops

Created on 2024-01-31 with reprex v2.1.0

FLB fails (instead of NaN) when input is impossible

library(segregatr, quietly = T)

x = nuclearPed(2)
FLB(x, carriers = 2:4, aff = 2:4, freq = 0.0001, proband = 3,
    penetrances = c(1, 1, 1), plot = T)
#> Error in tcrossprod(x, y): requires numeric/complex matrix/vector arguments

Here is another impossible case which is handled better (no error; result = NaN):

FLB(x, carriers = 2:4, aff = 2:4, freq = 0.0001, proband = 3,
    penetrances = c(0, 0, 0))
#> [1] NaN

Created on 2024-02-19 with reprex v2.1.0

First issue

Great app! I realise that this is an early version. I guess I would like to be the first to post an issue. The 'load example' is a nice feature. I was wondering: Can I make changes and get into the red area of strong 'Evidence of pathogenity' (change penetrances,... )? It may be evident that I don't know this application of Bayes factors

FLB and `cex`

library(segregatr)
#> Loading required package: pedtools
x = cousinPed(degree = 1)
x = swapSex(x, c(3,8))
#> Changing sex of spouses as well: 4
x = relabel(x, "asPlot")
windows()
FLB(x,
    affected = 7:8,
    unknown = 4:5,
    carriers = 7:8,
    freq = 0.001,
    proband = 7,
    penetrances = c(0.05, 0.7, 0.7),
    plot = TRUE)
#> Error in plot.xy(xy.coords(x, y), type = type, ...): invalid 'cex' value

plot = FALSE gives Error: Unknown proband: 7

Created on 2020-09-12 by the reprex package (v0.3.0)

FLB, plotSegregation and pedigrees with loops

library(pedtools)
library(segregatr)

The BF cannot be computed in this example with loops, although the pedigree is still correctly displayed:

p0 = cousinPed(degree = 1) |>
  swapSex(ids = 8) |>
  addChildren(father = 7, mother = 8)
FLB(x = p0, freq = 0.001, penetrances = c(0,1,1),
    affected = c(3,7,9), unknown = 1,
    carriers = c(7,9), noncarriers = c(4,8),
    proband = 9, plot = TRUE)
#> Error in if (link == 0) return(sum(likel)): argument is of length zero

After breaking the loops,FLB() returns NA, and markers are incorrectly positioned:

p1 = breakLoops(p0)
#> Loop breakers: 3
#> No further loops to break
FLB(x = p1, freq = 0.001, penetrances = c(0,1,1),
    affected = c(3,7,9), unknown = 1,
    carriers = c(7,9), noncarriers = c(4,8),
    proband = 9, plot = TRUE)

#> [1] NaN

By specifying the new individual โ€˜=3โ€™ a numeric result is obtained, but the problem with the markers remains:

FLB(x = p1, freq = 0.001, penetrances = c(0,1,1),
    affected = c(3,7,9,'=3'), unknown = 1,
    carriers = c(7,9), noncarriers = c(4,8),
    proband = 9, plot = TRUE)

#> [1] 5.01503

The value of the BF is at least different from a pedigree where 3 and =3 are different individuals:

p2 = nuclearPed(nch = 2, sex = 1) |>
  addChildren(fa = 4, sex = 2) |>
  addChildren(mo = 6, sex = 1) |>
  addParents(id = 7)
#> Mother: Creating new individual with ID = 5
#> Father: Creating new individual with ID = 7
#> Father: Creating new individual with ID = 9
#> Mother: Creating new individual with ID = 10
FLB(x = p2, freq = 0.001, penetrances = c(0,1,1),
    affected = c(3,7,8,9), unknown = 1,
    carriers = c(7,8), noncarriers = c(6,10),
    proband = 8, plot = TRUE)

#> [1] 4.012024

Also note that the markers are again incorrectly plotted, even though there were no loops in this case.

Created on 2021-12-22 by the reprex package (v2.0.1.9000)

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.