Skip to content

Commit

Permalink
compat updates, doc fix
Browse files Browse the repository at this point in the history
- plot fix in doc (#166)
- compat: BioSequences v3 (#167), CSV 0.10 (#169), julia v1.7 (new RNG, fix tests)
  thanks CompatHelper and github-actions!

tests fails bc failure to resolve package dependencies, with FASTX, BioSequences & BioSymbols
  • Loading branch information
github-actions[bot] authored Feb 19, 2022
1 parent a8155c8 commit 999cc92
Show file tree
Hide file tree
Showing 18 changed files with 179 additions and 412 deletions.
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PhyloNetworks"
uuid = "33ad39ac-ed31-50eb-9b15-43d0656eaa72"
license = "MIT"
version = "0.14.2"
version = "0.14.3"

[deps]
BioSequences = "7e6ae17a-c86d-528c-b3b9-7f778a29fe59"
Expand All @@ -26,9 +26,9 @@ StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d"

[compat]
BioSequences = "2.0"
BioSequences = "2.0, 3"
BioSymbols = "4.0, 5"
CSV = "0.4, 0.5, 0.6, 0.7, 0.8, 0.9"
CSV = "0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.10"
Combinatorics = "0.7, 1.0"
DataFrames = "0.21, 0.22, 1.0"
DataStructures = "0.9, 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18"
Expand All @@ -40,7 +40,7 @@ StaticArrays = "0.8.3, 0.9, 0.10, 0.11, 0.12, 1.0"
StatsBase = "0.26, 0.27, 0.28, 0.29, 0.30, 0.31, 0.32, 0.33"
StatsFuns = "0.7, 0.8, 0.9"
StatsModels = "0.6"
julia = "1.1, 1.2, 1.3, 1.4, 1.5, 1.6"
julia = "1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
6 changes: 2 additions & 4 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterMarkdown = "997ab1e6-3595-5248-9280-8efb232c3433"
# will be added by the CI platform as being developed:
# PhyloNetworks = "33ad39ac-ed31-50eb-9b15-43d0656eaa72"
# will be added to track master version in make.jl:
# PhyloPlots = "c0d5b6db-e3fc-52bc-a87d-1d050989ed3b"
PhyloNetworks = "33ad39ac-ed31-50eb-9b15-43d0656eaa72"
PhyloPlots = "c0d5b6db-e3fc-52bc-a87d-1d050989ed3b"
RCall = "6f49c342-dc21-5d91-9882-a32aef131414"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
Expand Down
5 changes: 3 additions & 2 deletions docs/src/man/snaq_plot.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,10 @@ such that the score is 0 if the network fits the data perfectly).
The lower the better. We can plot these scores across hybrid values:
```@example snaqplot
scores = [net0.loglik, net1.loglik, net2.loglik, net3.loglik]
hmax = collect(0:3)
R"svg(name('snaqplot_scores_heuristic.svg'), width=4, height=3)" # hide
R"par"(mar=[2.5,2.5,.5,.5], mgp=[1.4,.4,0], tck=-0.02); # hide
R"plot"(scores, type="b", ylab="network score", xlab="hmax", col="blue");
R"par"(mar=[2.5,2.5,.5,.5], mgp=[1.4,.4,0], tck=-0.02, las=1, lab=[3,5,7]); # hide
R"plot"(hmax, scores, type="b", ylab="network score", xlab="hmax", col="blue");
R"dev.off()"; # hide
nothing # hide
```
Expand Down
4 changes: 2 additions & 2 deletions src/addHybrid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ julia> net = readTopology("((S1,(((S2,(S3)#H1),(#H1,S4)))#H2),(#H2,S5));");
julia> using Random
julia> Random.seed!(75);
julia> Random.seed!(170);
julia> PhyloNetworks.addhybridedge!(net, true, true)
(PhyloNetworks.Node:
Expand All @@ -51,7 +51,7 @@ julia> PhyloNetworks.addhybridedge!(net, true, true)
, PhyloNetworks.Edge:
number:17
length:0.01
minor hybrid edge with gamma=0.32946795808423734
minor hybrid edge with gamma=0.32771460911632916
attached to 2 node(s) (parent first): 8 9
)
Expand Down
2 changes: 1 addition & 1 deletion src/moves_semidirected.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ julia> str_network = "(((S8,S9),(((((S1,S2,S3),S4),(S5)#H1),(#H1,(S6,S7))))#H2),
julia> net = readTopology(str_network);
julia> using Random; Random.seed!(321);
julia> using Random; Random.seed!(3);
julia> undoinfo = nni!(net, net.edge[3], true, true); # true's to avoid hybrid ladders and 3-cycles
Expand Down
4 changes: 2 additions & 2 deletions src/substitutionModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ Binary Trait Substitution Model:
rate 0→1 α=1.0
rate 1→0 β=2.0
julia> using Random; Random.seed!(12345);
julia> using Random; Random.seed!(13);
julia> randomTrait(m1, 0.2, [1,2,1,2,2])
5-element Vector{Int64}:
Expand Down Expand Up @@ -554,7 +554,7 @@ julia> m1 = BinaryTraitSubstitutionModel(1.0, 2.0, ["low","high"]);
julia> net = readTopology("(((A:4.0,(B:1.0)#H1:1.1::0.9):0.5,(C:0.6,#H1:1.0::0.1):1.0):3.0,D:5.0);");
julia> using Random; Random.seed!(235);
julia> using Random; Random.seed!(95);
julia> trait, lab = randomTrait(m1, net)
([1 2 … 1 1], ["-2", "D", "-3", "-6", "C", "-4", "H1", "B", "A"])
Expand Down
150 changes: 48 additions & 102 deletions src/traits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,10 @@ julia> sim = simulate(net, params); # simulate a dataset with shifts
julia> using DataFrames # to handle data frames
julia> dat = DataFrame(trait = sim[:Tips], tipNames = sim.M.tipNames)
julia> dat = DataFrame(trait = sim[:Tips], tipNames = sim.M.tipNames);
julia> dat = DataFrame(trait = [13.391976856737717, 9.55741491696386, 7.17703734817448, 7.889062527849697],
tipNames = ["A","B","C","D"]) # hard-coded, to be independent of random number generator
4×2 DataFrame
Row │ trait tipNames
│ Float64 String
Expand Down Expand Up @@ -602,7 +605,10 @@ julia> using Random; Random.seed!(2468); # sets the seed for reproducibility
julia> sim = simulate(net, params); # simulate a dataset with shifts
julia> dat = DataFrame(trait = sim[:Tips], tipNames = sim.M.tipNames)
julia> dat = DataFrame(trait = sim[:Tips], tipNames = sim.M.tipNames);
julia> dat = DataFrame(trait = [10.391976856737717, 9.55741491696386, 10.17703734817448, 12.689062527849698],
tipNames = ["A","B","C","D"]) # hard-code values for more reproducibility
4×2 DataFrame
Row │ trait tipNames
│ Float64 String
Expand Down Expand Up @@ -1090,7 +1096,7 @@ See examples below for accessing expectations and simulated trait values.
# Examples
## Univariate
```jldoctest
julia> phy = readTopology(joinpath(dirname(pathof(PhyloNetworks)), "..", "examples", "carnivores_tree.txt"));
julia> phy = readTopology("(A:2.5,((U:1,#H1:0.5::0.4):1,(C:1,(D:0.5)#H1:0.5::0.6):1):0.5);");
julia> par = ParamsBM(1, 0.1) # BM with expectation 1 and variance 0.1.
ParamsBM:
Expand All @@ -1103,104 +1109,47 @@ julia> using Random; Random.seed!(17920921); # for reproducibility
julia> sim = simulate(phy, par) # Simulate on the tree.
TraitSimulation:
Trait simulation results on a network with 16 tips, using a BM model, with parameters:
Trait simulation results on a network with 4 tips, using a BM model, with parameters:
mu: 1
Sigma2: 0.1
julia> traits = sim[:Tips] # Extract simulated values at the tips.
16-element Vector{Float64}:
2.17618427971927
1.0330846124205684
3.048979175536912
3.0379560744947876
2.189704751299587
4.031588898597555
4.647725850651446
-0.8772851731182523
4.625121065244063
-0.5111667949991542
1.3560351170535228
-0.10311152349323893
-2.088472913751017
2.6399137689702723
2.8051193818084057
3.1910928691142915
4-element Vector{Float64}:
0.9664650558470932
0.4104321932336118
0.2796524923704289
0.7306692819731366
julia> sim.M.tipNames # name of tips, in the same order as values above
16-element Vector{String}:
"Prionodontidae"
"Felidae"
"Viverridae"
"Herpestidae"
"Eupleridae"
"Hyaenidae"
"Nandiniidae"
"Canidae"
"Ursidae"
"Odobenidae"
"Otariidae"
"Phocidae"
"Mephitidae"
"Ailuridae"
"Mustelidae"
"Procyonidae"
4-element Vector{String}:
"A"
"U"
"C"
"D"
julia> traits = sim[:InternalNodes] # Extract simulated values at internal nodes. Order: as in sim.M.internalNodeNumbers
15-element Vector{Float64}:
1.1754592873593104
2.0953234045227083
2.4026760531649423
1.8143470622283222
1.5958834784477616
2.5535578380290103
0.14811474751515852
1.2168428692963675
3.169431736805764
2.906447201806521
2.8191520015241545
2.280632978157822
2.5212485416800425
2.4579867601968663
5-element Vector{Float64}:
0.5200361297500204
0.8088890626285765
0.9187604100796469
0.711921371091375
1.0
julia> traits = sim[:All] # simulated values at all nodes, ordered as in sim.M.nodeNumbersTopOrder
31-element Vector{Float64}:
9-element Vector{Float64}:
1.0
2.4579867601968663
2.5212485416800425
2.280632978157822
2.8191520015241545
2.906447201806521
3.169431736805764
3.1910928691142915
2.8051193818084057
2.6399137689702723
2.4026760531649423
4.031588898597555
2.0953234045227083
2.189704751299587
3.0379560744947876
3.048979175536912
1.1754592873593104
1.0330846124205684
2.17618427971927
0.711921371091375
0.9187604100796469
0.2796524923704289
0.5200361297500204
0.8088890626285765
0.7306692819731366
0.4104321932336118
0.9664650558470932
julia> traits = sim[:Tips, :Exp] # Extract expected values at the tips (also works for sim[:All, :Exp] and sim[:InternalNodes, :Exp]).
16-element Vector{Float64}:
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
4-element Vector{Float64}:
1.0
1.0
1.0
Expand All @@ -1209,7 +1158,7 @@ julia> traits = sim[:Tips, :Exp] # Extract expected values at the tips (also wor
## Multivariate
```jldoctest
julia> phy = readTopology(joinpath(dirname(pathof(PhyloNetworks)), "..", "examples", "carnivores_tree.txt"));
julia> phy = readTopology("(A:2.5,((B:1,#H1:0.5::0.4):1,(C:1,(V:0.5)#H1:0.5::0.6):1):0.5);");
julia> par = ParamsMultiBM([1.0, 2.0], [1.0 0.5; 0.5 1.0]) # BM with expectation [1.0, 2.0] and variance [1.0 0.5; 0.5 1.0].
ParamsMultiBM:
Expand All @@ -1219,32 +1168,29 @@ Sigma: [1.0 0.5; 0.5 1.0]
julia> using Random; Random.seed!(17920921); # for reproducibility
julia> sim = simulate(phy, par) # Simulate on the tree.
julia> sim = simulate(phy, par) # simulate on the phylogeny
TraitSimulation:
Trait simulation results on a network with 16 tips, using a MBD model, with parameters:
Trait simulation results on a network with 4 tips, using a MBD model, with parameters:
mu: [1.0, 2.0]
Sigma: [1.0 0.5; 0.5 1.0]
julia> traits = sim[:Tips] # Extract simulated values at the tips (each column contains the simulated traits for one node).
16 Matrix{Float64}:
5.39465 7.223 1.88036 -5.10491 … -3.86504 0.133704 -2.44564
7.29184 7.59947 -1.89206 -0.960013 3.86822 3.23285 1.93376
4 Matrix{Float64}:
2.99232 -0.548734 -1.79191 -0.773613
4.09575 0.712958 0.71848 2.00343
julia> traits = sim[:InternalNodes] # simulated values at internal nodes. order: same as in sim.M.internalNodeNumbers
15 Matrix{Float64}:
4.42499 -0.364198 0.71666 3.76669 … 4.57552 4.29265 5.61056 1.0
6.24238 2.97237 0.698006 2.40122 5.92623 5.13753 4.5268 2.0
5 Matrix{Float64}:
-0.260794 -1.61135 -1.93202 0.0890154 1.0
1.46998 1.28614 0.409032 1.94505 2.0
julia> traits = sim[:All] # simulated values at all nodes, ordered as in sim.M.nodeNumbersTopOrder
2×31 Matrix{Float64}:
1.0 5.61056 4.29265 4.57552 … 1.88036 4.42499 7.223 5.39465
2.0 4.5268 5.13753 5.92623 -1.89206 6.24238 7.59947 7.29184
julia> traits = sim[:All]; # 2×9 Matrix: values at all nodes, ordered as in sim.M.nodeNumbersTopOrder
julia> sim[:Tips, :Exp] # Extract expected values (also works for sim[:All, :Exp] and sim[:InternalNodes, :Exp])
16 Matrix{Float64}:
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 … 1.0 1.0 1.0 1.0 1.0 1.0 1.0
2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0
4 Matrix{Float64}:
1.0 1.0 1.0 1.0
2.0 2.0 2.0 2.0
```
"""
function simulate(net::HybridNetwork,
Expand Down
Loading

0 comments on commit 999cc92

Please sign in to comment.