Skip to content

Commit

Permalink
Rebuild for Julia 1.0, 1.1, and 1.2
Browse files Browse the repository at this point in the history
get loglikelihood calculation running

forgot to save on code re-locate causing function overwriting

Manifest

Sequence generation for a defined phylogenetic tree

update manifest

custom travis script

Nice registry functionality limited to >v1.1.0

remove Manifest?

remove Manifest?

update .gitignore - Manifest removed for dependency version flexibility needed for Julia-1.0 support

README update
  • Loading branch information
jangevaare committed Sep 19, 2019
1 parent 4da8ee1 commit 9fbcdd4
Show file tree
Hide file tree
Showing 22 changed files with 199 additions and 1,352 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
*.jl.mem
.ipynb_checkpoints
testfile.jl
.DS_Store
Manifest.toml
16 changes: 14 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@ os:
- linux
- osx
julia:
- 0.5
- 1.0
- 1.1
- 1.2
- nightly
notifications:
email: false
email: true
matrix:
allow_failures:
- julia: nightly
fast_finish: true
script:
- julia -e 'using Pkg;
if VERSION >= v"1.1.0";
Registry.add(Registry.RegistrySpec(url = "https://github.com/JuliaRegistries/General.git"));
Registry.add(Registry.RegistrySpec(url = "https://github.com/BioJulia/BioJuliaRegistry.git"));
Pkg.build(verbose = true);
else;
Pkg.build();
end;
Pkg.test(coverage=true)'
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Justin Angevaare

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 0 additions & 22 deletions LICENSE.md

This file was deleted.

19 changes: 19 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name = "PhyloModels"
uuid = "6465ae08-de3a-5dbe-bda8-3920f6a01ab7"
authors = ["Justin Angevaare <[email protected]>"]
version = "0.3.0"

[deps]
GeneticBitArrays = "5d6f8c34-7f74-4dab-a49b-48b3414fbfce"
PhyloTrees = "4c47b132-0681-5a5d-b498-3afcf53fd314"
SubstitutionModels = "8365b1bb-bd83-58ee-a267-f2965fc81c73"

[compat]
GeneticBitArrays = "≥ 0.2.1"
julia = "≥ 1.0.0"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
52 changes: 14 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,23 @@
# PhyloModels.jl

[![Latest Release](https://img.shields.io/github/release/jangevaare/PhyloModels.jl.svg)](https://github.com/jangevaare/PhyloModels.jl/releases/latest)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/jangevaare/PhyloModels.jl/blob/master/LICENSE)
[![Build Status](https://travis-ci.org/jangevaare/PhyloModels.jl.svg?branch=master)](https://travis-ci.org/jangevaare/PhyloModels.jl)

PhyloModels.jl is a package for performing phylogenetic simulation and inference in Julia. This package is no longer being developed or maintained in favour of [BioJulia/SubstitutionModels.jl](https://github.com/BioJulia/SubstitutionModels.jl) and related bioinformatics packages in the [BioJulia](https://github.com/BioJulia) Ecosystem.


### Simulation
Genetic sequences can be simulated from phylogenetic trees by defining a root sequence, site rates, and a nucleotide substitution model. The following nucleotide substitution models are currently available: `JC69`, `K80`, `F81`, `F84`, `HKY85`, `TN93`, and `GTR`.


### Inference
The log likelihood of phylogenetic trees can be calculated when genetic sequences have been observed at all leaves, and a nucleotide substitution model has been specified by using the `loglikelihood` function. Below is an example from *Molecular Evolution: A Statistical Approach*
PhyloModels.jl is a package for performing genetic sequence simulation from specified phylogenetic trees (using [PhyloTrees.jl](https://github.com/jangevaare/PhyloTrees.jl) for phylogenetic tree specification, and [SubstitutionModels.jl](https://github.com/BioJulia/SubstitutionModels.jl) for nucleic acid substitution model specification), and for loglikelihood calculation of phylogenetic trees using Felsenstein's tree pruning algorithm¹.

> using PhyloTrees, PhyloModels
>
> # Build tree
> tree = Tree()
> addnodes!(tree, 9)
> addbranch!(tree, 9, 6, 0.1)
> addbranch!(tree, 9, 8, 0.1)
> addbranch!(tree, 6, 7, 0.1)
> addbranch!(tree, 6, 3, 0.2)
> addbranch!(tree, 7, 1, 0.2)
> addbranch!(tree, 7, 2, 0.2)
> addbranch!(tree, 8, 4, 0.2)
> addbranch!(tree, 8, 5, 0.2)
¹ Felsenstein, J. (1981). Evolutionary trees from DNA sequences: a maximum likelihood approach. *Journal of molecular evolution, 17*(6), 368-376.

Phylogenetic tree with 9 nodes and 8 branches
## Installation

> # Set state of leaf nodes
> node_data = Dict{Int64, Sequence}()
> node_data[1] = Sequence("T")
> node_data[2] = Sequence("C")
> node_data[3] = Sequence("A")
> node_data[4] = Sequence("C")
> node_data[5] = Sequence("C")
>
> # Parametrize substitution model
> model = K80([2.])
Julia 1.0.x, 1.1.x, and 1.2.x are currently supported. The current release can be installed
from the Julia REPL:

Kimura 1980 substitution model
```julia
pkg> add PhyloModels
```

> # Calculate log likelihood
> loglikelihood(tree, model, node_data)
The development version (master branch) can be installed as:

-7.5814075725577
```julia
pkg> add PhyloModels#master
```
3 changes: 0 additions & 3 deletions REQUIRE

This file was deleted.

35 changes: 0 additions & 35 deletions appveyor.yml

This file was deleted.

78 changes: 21 additions & 57 deletions src/PhyloModels.jl
Original file line number Diff line number Diff line change
@@ -1,67 +1,31 @@
__precompile__()

module PhyloModels

# Dependencies
using
PhyloTrees,
Distributions
using PhyloTrees,
SubstitutionModels,
GeneticBitArrays

import SubstitutionModels.
import Base.rand

# Methods expanded
import
Base.show,
Base.push!,
Base.append!,
Base.length,
Base.getindex,
Base.rand,
Base.copy,
Base.deleteat!,
StatsBase.loglikelihood
# Re-export all of PhyloTrees, SubstitutionModels, and GeneticBitArrays
for name in names(PhyloTrees)
@eval export $(name)
end

export
# Sequences
Sequence,
for name in names(SubstitutionModels)
@eval export $(name)
end

# Substitution Models
SubstitutionModel,
SubstitutionModelPrior,
JC69,
K80,
F81,
F84,
HKY85,
TN93,
GTR,
JC69Prior,
K80Prior,
F81Prior,
F84Prior,
HKY85Prior,
TN93Prior,
GTRPrior,
Q,
P,
logprior,
for name in names(GeneticBitArrays)
@eval export $(name)
end

# Simulation
simulate,
simulate!,
const NodeDNA = Dict{Int64, DNASeq}
const NodeRNA = Dict{Int64, RNASeq}

# Loglikelihoods
loglikelihood
include("loglikelihood.jl")
include("simulate.jl")

# Package files
include("sequences.jl")
include("substitution_models/abstract.jl")
include("substitution_models/jc69.jl")
include("substitution_models/k80.jl")
include("substitution_models/f81.jl")
include("substitution_models/f84.jl")
include("substitution_models/hky85.jl")
include("substitution_models/tn93.jl")
include("substitution_models/gtr.jl")
include("simulation.jl")
include("loglikelihoods.jl")
export NodeDNA, NodeRNA, siimulate!, simulate, rand, loglikelihood

end # module
21 changes: 7 additions & 14 deletions src/loglikelihoods.jl → src/loglikelihood.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
"""
loglikelihood(tree::Tree,
mod::SubstitutionModel,
node_data::Dict{Int64, Sequence},
output_calculations::Bool=false)
Calculates the log likelihood of a tree with sequences observed at all leaves
"""
function loglikelihood(tree::Tree,
mod::SubstitutionModel,
node_data::Dict{Int64, Sequence},
output_calculations::Bool=false)
mod::T,
node_data::N;
output_calculations::Bool=false) where {T <: NASM, N <: Union{NodeDNA, NodeRNA}}
# Error checking
if !all(map(x -> x in keys(node_data), findleaves(tree)))
error("Some leaves are missing sequence data")
Expand All @@ -19,11 +11,12 @@ function loglikelihood(tree::Tree,

# Create a Dict to store likelihood calculations
calculations = Dict{Int64, Array{Float64, 2}}()

# Find node visit order for postorder traversal
visit_order = postorder(tree)
for i in visit_order
if isleaf(tree, i)
calculations[i] = node_data[i].nucleotides
calculations[i] = node_data[i].data
else
branches = tree.nodes[i].out
for j in branches
Expand All @@ -39,8 +32,8 @@ function loglikelihood(tree::Tree,
end
end
if output_calculations
return sum(log.(mod.π' * calculations[visit_order[end]])), calculations, visit_order
return sum(log.((mod)' * calculations[visit_order[end]])), calculations, visit_order
else
return sum(log.(mod.π' * calculations[visit_order[end]]))
return sum(log.((mod)' * calculations[visit_order[end]]))
end
end
Loading

2 comments on commit 9fbcdd4

@jangevaare
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/3681

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.0 -m "<description of version>" 9fbcdd441257b4692a6e030d3c7dbe5064003763
git push origin v0.3.0

Please sign in to comment.