MetaPhylo.jl
is Julia package for dealing with phylogenetic trees.
This package is in the early stage of development and probably has many bugs (especially around Newick format). Bug reports and any suggestions are welcomeπ!
MetaPhylo.jl
is inspired by MetaGraphs.jl and implemented with Graphs.jl and AbstractTrees.jl.
julia> import Pkg; Pkg.add("MetaPhylo");
julia> using MetaPhylo
julia> tree = parse_newick("((A:0.1,B:0.2)100:0.3,((C:0.4,D:0.5)77:0.6,E:0.7)98:0.8,F:0.9);", MetaPhylo.Tree{Int, UnRooted, ReRootable})
MetaPhylo.Tree with 6 leaves.
Rooted: false
Rerootable: true
julia> print_tree(tree)
1: [root]
ββ 2: [value:100.0, length:0.3]
β ββ 3: [length:0.1] label:"A"
β ββ 4: [length:0.2] label:"B"
ββ 5: [value:98.0, length:0.8]
β ββ 6: [value:77.0, length:0.6]
β β ββ 7: [length:0.4] label:"C"
β β ββ 8: [length:0.5] label:"D"
β ββ 9: [length:0.7] label:"E"
ββ 10: [length:0.9] label:"F"
julia> tree[3]
Dict{Symbol, Any} with 1 entry:
:label => "A"
julia> tree[5,6]
Dict{Symbol, Any} with 2 entries:
:value => 77.0
:length => 0.6
julia> findnodes(tree, :label => isequal("A"))
1-element Vector{Int64}:
3
julia> findbranches(tree, :value => x -> x β₯ 90)
1-element Vector{Graphs.SimpleGraphs.SimpleEdge{Int64}}:
Edge 1 => 2
Edge 1 => 5
julia> @time big_tree = Newick.File("/path/to/big_tree") |> MetaPhylo.Tree{Int, UnRooted, ReRootable}
3.394991 seconds (23.63 M allocations: 1.180 GiB, 32.24% gc time)
MetaPhylo.Tree with 54327 leaves.
Rooted: false
Rerootable: true
julia> freeze(big_tree)
MetaPhylo.StaticTree with 54327 leaves.
Rooted: false
branch_data: NamedTuple{(:length,), Tuple{Float64}}
node_data: NamedTuple{(), Tuple{}}