Giter Site home page Giter Site logo

arzwa / beluga.jl Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 2.0 4.13 MB

Statistical analysis of gene family evolution using phylogenetic birth-death processes and WGD inference using rjMCMC

License: GNU Lesser General Public License v2.1

Julia 100.00%
gene-family evolution phylogenetics reversible-jump-mcmc bayesian-inference bioinformatics

beluga.jl's Introduction

Copyright (C) 2020 Arthur Zwaenepoel

VIB/UGent center for plant systems biology - Bioinformatics & evolutionary genomics group

Beluga

Dependencies

Beluga requires unregistered dependencies, to install Beluga, fire up a julia session, hit ] and add the following:

(v1.3) pkg> add https://github.com/arzwa/NewickTree.jl#beluga
(v1.3) pkg> add https://github.com/arzwa/AdaptiveMCMC.jl
(v1.3) pkg> add https://github.com/arzwa/Beluga.jl

Usage

Please refer to the documentation for more detailed usage examples.

using Beluga, CSV, DataFrames, Parameters

# get some data
tree = readline("example/9dicots/9dicots.nw")
df = CSV.read("example/9dicots/9dicots-f01-25.csv")

# construct model and profile
λ, μ, η = 1.0, 0.92, 0.66
model, profile = DLWGD(tree, df, λ, μ, η)  

# compute log-likelihood
l = logpdf!(model, profile)

# get model parameters as vector = [λ1, ..., μ1, ..., q1, ..., η])
v = asvector(model)

# construct new model based on the old one and a new parameter vector
x = rand(length(v))
model = model(x)

# compute log likelihood again
l = logpdf!(model, profile)

# change parameters at node 5
Beluga.update!(model[5], (λ=1.5, μ=1.2))

# change η parameter at root
Beluga.update!(model[1], , 0.91)

# recompute likelihood efficiently starting from node 5
l = logpdf!(model[5], profile)

# gradient
g = gradient(model, profile)

# add a WGD node above node 6 at a distance 0.01 with q=0.25
addwgd!(model, model[6], 0.01, 0.25)
Beluga.extend!(profile, 6);

# compute the log-likelihood, now for the model with the WGD
logpdf!(model, profile)

# simulate a random phylogenetic profile under the model
rand(model)

# simulate a data set of 100 profiles
rand(model, 100)

# independent rates prior (check & adapt default settings!)
prior = IRRevJumpPrior(Tl=treelength(model))
logpdf(prior, model)

# sample random model from prior
@unpack model, Σ = rand(prior, model)

# reversible jump chain
model, profile = DLWGD(tree, df, λ, μ, η)  
chain = RevJumpChain(data=profile, model=model, prior=prior)

# run chain (fixed dimension - no reversible jump)
init!(chain)
mcmc!(chain, 100, show=1)

# run chain (variable dimensions - with reversible jump)
rjmcmc!(chain, 100, show=1)

Notes:

  • Gradients require NaN-safe mode enabled in ForwardDiff: The following should work for most people:
sed -i 's/NANSAFE_MODE_ENABLED = false/NANSAFE_MODE_ENABLED = true/g' ~/.julia/packages/ForwardDiff/*/src/prelude.jl

Citation

Beluga.jl is developed by Arthur Zwaenepoel at the VIB/UGent center for plant systems biology (bioinformatics and evolutionary genomics group). A preprint on the reversible-jump sampler for WGD inference implemented in this library can be found at BioRXiv.

@article {zwaenepoel2020,
	author = {Zwaenepoel, Arthur and Van de Peer, Yves},
	title = {Model-based detection of whole-genome duplications in a phylogeny},
	elocation-id = {2020.01.24.917997},
	year = {2020},
	doi = {10.1101/2020.01.24.917997},
	publisher = {Cold Spring Harbor Laboratory},
	URL = {https://www.biorxiv.org/content/early/2020/01/25/2020.01.24.917997},
	eprint = {https://www.biorxiv.org/content/early/2020/01/25/2020.01.24.917997.full.pdf},
	journal = {bioRxiv}
}

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.