Skip to content

Commit 42f2c18

Browse files
cecileanecrsl4
andauthored
removedegree2nodes! : option to keep the root (JuliaPhylo#181)
also: CITATION.bib that works with PkgCite, citation() now using it. Co-authored-by: Claudia Solis-Lemus <[email protected]>
1 parent 2cf465b commit 42f2c18

File tree

6 files changed

+90
-43
lines changed

6 files changed

+90
-43
lines changed

CITATION.bib

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
% reference for the software itself
2+
@article{2017SolislemusBastideAne_PhyloNetworks,
3+
author = {Sol{\'\i}s-Lemus, Claudia and Bastide, Paul and An{\'e}, C{\'e}cile},
4+
title = {PhyloNetworks: A Package for Phylogenetic Networks},
5+
journal = {Molecular Biology and Evolution},
6+
year = {2017},
7+
volume = {34},
8+
number = {12},
9+
pages = {3292-3298},
10+
doi = {10.1093/molbev/msx235},
11+
}
12+
13+
% paper on the SNaQ method
14+
@article{2016SolislemusAne_SNaQ,
15+
author = {Sol{\'\i}s-Lemus, Claudia and An{\'e}, C{\'e}cile},
16+
title = {Inferring Phylogenetic Networks with Maximum Pseudolikelihood under Incomplete Lineage Sorting},
17+
journal = {PLOS Genetics},
18+
year = {2016},
19+
volume = {12},
20+
number = {3},
21+
pages = {1-21},
22+
doi = {10.1371/journal.pgen.1005896},
23+
}
24+
% paper on phylogenetic comparative methods for continuous traits on networks
25+
@article{2018Bastide_continuoustraitevolution,
26+
author = {Bastide, Paul and Sol{\'\i}s-Lemus, Claudia and Kriebel, Ricardo and William Sparks, K and An{\'e}, C{\'e}cile},
27+
title = {Phylogenetic Comparative Methods on Phylogenetic Networks with Reticulations},
28+
journal = {Systematic Biology},
29+
year = {2018},
30+
volume = {67},
31+
number = {5},
32+
pages = {800-820},
33+
doi = {10.1093/sysbio/syy033},
34+
}
35+
% paper on phylogenetic comparative methods for discrete traits on networks
36+
@article{2020Karimi_baobab_discretetraitevolution,
37+
author = {Karimi, Nisa and Grover, Corrinne E and Gallagher, Joseph P and Wendel, Jonathan F and An{\'e}, C{\'e}cile and Baum, David A},
38+
title = {Reticulate Evolution Helps Explain Apparent Homoplasy in Floral Biology and Pollination in Baobabs (\textit{{Adansonia}}; {Bombacoideae}; {Malvaceae})},
39+
journal = {Systematic Biology},
40+
year = {2020},
41+
volume = {69},
42+
number = {3},
43+
pages = {462-478},
44+
doi = {10.1093/sysbio/syz073},
45+
}
46+
% paper on continuous traits with intraspecific variation
47+
@article{2022Teo_intraspeciesvariation,
48+
author = {Teo, Benjamin and Rose, Jeffrey P. and Bastide, Paul and An{\'e}, C{\'e}cile},
49+
title = {Accounting for intraspecific variation in continuous trait evolution on a reticulate phylogeny},
50+
journal = {bioRxiv},
51+
year = {2022},
52+
doi = {10.1101/2022.05.12.490814},
53+
publisher = {Cold Spring Harbor Laboratory},
54+
}

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ To get help, check
3333
for common questions. Join the group to post/email your questions,
3434
or to receive information on new versions, bugs fixed, etc.
3535

36-
If you use the package, please cite
36+
If you use the package, please cite ([bibtex format here](CITATION.bib))
3737

3838
- Claudia Sol&iacute;s-Lemus, Paul Bastide and C&eacute;cile An&eacute; (2017).
3939
PhyloNetworks: a package for phylogenetic networks.
@@ -86,5 +86,5 @@ ancestral state reconstruction, rates):
8686
- Karimi, Grover, Gallagher, Wendel, Ané & Baum (2020). Reticulate evolution
8787
helps explain apparent homoplasy in floral biology and pollination in baobabs
8888
(*Adansonia*; Bombacoideae; Malvaceae).
89-
[Systematic Biology](https://academic.oup.com/sysbio/advance-article/doi/10.1093/sysbio/syz073/5613901?guestAccessKey=a32e7dd3-27fd-4a13-b171-7ff5d6da0e01),
90-
69(3):462-478. doi: 10.1093/sysbio/syz073.
89+
Systematic Biology,
90+
69(3):462-478. doi: [10.1093/sysbio/syz073](https://academic.oup.com/sysbio/advance-article/doi/10.1093/sysbio/syz073/5613901?guestAccessKey=a32e7dd3-27fd-4a13-b171-7ff5d6da0e01).

docs/src/index.md

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ and their use for trait evolution.
1919

2020
## References
2121

22+
See their [bibtex format](https://github.com/crsl4/PhyloNetworks.jl/blob/master/CITATION.bib).
23+
2224
for the package:
2325
- Claudia Solís-Lemus, Paul Bastide and Cécile Ané (2017).
2426
PhyloNetworks: a package for phylogenetic networks.

src/auxiliary.jl

+4-32
Original file line numberDiff line numberDiff line change
@@ -1707,36 +1707,8 @@ end
17071707

17081708
#------------------------------------
17091709
function citation()
1710-
println("If you use PhyloNetworks, please cite:")
1711-
println("@article{phylonetworks,")
1712-
println("author = {Sol\'{i}s-Lemus, C. and Bastide, P. and An\'{e}, C.},")
1713-
println("year = {2017},")
1714-
println("title = {{PhyloNetworks: a package for phylogenetic networks}},")
1715-
println("journal = {Molecular Biology and Evolution},")
1716-
println("volume = {34},")
1717-
println("number = {12},")
1718-
println("pages = {3292--3298},")
1719-
println("pmid = {28961984}}")
1720-
println("\n")
1721-
println("If you use SNaQ, please also cite:")
1722-
println("@article{snaq,")
1723-
println("author = {Sol\'{i}s-Lemus, C. AND An\'{e}, C.},")
1724-
println("journal = {PLOS Genetics},")
1725-
println("title = {Inferring Phylogenetic Networks with Maximum Pseudolikelihood under Incomplete Lineage Sorting},")
1726-
println("year = {2016},")
1727-
println("volume = {12},")
1728-
println("pages = {1--21},")
1729-
println("number = {3},")
1730-
println("pmc = {PMC4780787}}")
1731-
println("\n")
1732-
println("If you use trait models in networks, please also cite:")
1733-
println("@article {traits,")
1734-
println("author = {Bastide, Paul and Sol\'{i}s-Lemus, Claudia and Kriebel, Ricardo and Sparks, Kenneth William and An{\'e}, C{\'e}cile},")
1735-
println("title = {Phylogenetic Comparative Methods on Phylogenetic Networks with Reticulations},")
1736-
println("journal = {Systematic Biology},")
1737-
println("volume = {67},")
1738-
println("number = {5},")
1739-
println("pages = {800--820},")
1740-
println("year = {2018},")
1741-
println("doi = {10.1093/sysbio/syy033}}")
1710+
bibfile = joinpath(@__DIR__, "..", "CITATION.bib")
1711+
out = readlines(bibfile)
1712+
println("Bibliography in bibtex format also in CITATION.bib")
1713+
println(join(out,'\n'))
17421714
end

src/manipulateNet.jl

+19-8
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,13 @@ function fuseedgesat!(i::Integer, net::HybridNetwork, multgammas=false::Bool)
494494
end
495495

496496
"""
497-
removedegree2nodes!(net::HybridNetwork)
497+
removedegree2nodes!(net::HybridNetwork, keeproot=false::Bool)
498498
499499
Delete *all* nodes of degree two in `net`, fusing the two adjacent edges
500500
together each time, and return the network.
501-
If the network has a degree-2 root, then the root is eliminated as well,
502-
leaving the network unrooted.
501+
If the network has a degree-2 root and `keeproot` is false,
502+
then the root is eliminated as well, leaving the network unrooted.
503+
If `keeproot` is true, then the root is kept even if it's of degree 2.
503504
504505
See [`fuseedgesat!`](@ref).
505506
@@ -520,13 +521,23 @@ julia> PhyloNetworks.removedegree2nodes!(net);
520521
julia> writeTopology(net) # even the root is gone
521522
"(#H2,S4,(((S1,(S2)#H1),(#H1,S3)))#H2);"
522523
524+
julia> net = readTopology("((((C:0.9)I1:0.1)I3:0.1,((A:1.0)I2:0.4)I3:0.6):1.4,(((B:0.2)H1:0.6)I2:0.5)I3:2.1);");
525+
526+
julia> PhyloNetworks.removedegree2nodes!(net, true);
527+
528+
julia> writeTopology(net, round=true) # the root was kept
529+
"((C:1.1,A:2.0):1.4,B:3.4);"
530+
523531
```
524532
"""
525-
function removedegree2nodes!(net::HybridNetwork)
526-
ndegree2nodes = sum(length(n.edge) == 2 for n in net.node)
527-
# caution: nodes and their indices in the 'current' network may change some of them are removed
528-
for ni in 1:ndegree2nodes # empty if 0 degree-2 nodes
529-
i = findfirst(n -> length(n.edge) == 2, net.node)
533+
function removedegree2nodes!(net::HybridNetwork, keeproot=false::Bool)
534+
rootnode = net.node[net.root]
535+
toberemoved(nn) = (keeproot ? length(nn.edge) == 2 && nn !== rootnode :
536+
length(nn.edge) == 2 )
537+
ndegree2nodes = sum(toberemoved.(net.node))
538+
# caution: nodes and their indices in the 'current' network may change when some of them are removed
539+
for _ in 1:ndegree2nodes # empty if 0 degree-2 nodes
540+
i = findfirst(toberemoved, net.node)
530541
i !== nothing || error("incorrect predicted number of degree-2 nodes to remove...")
531542
fuseedgesat!(i, net)
532543
end

test/test_manipulateNet.jl

+8
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,11 @@ net=readTopology("(4,((1,(2)#H7:::0.864):2.069,(6,5):3.423):0.265,(3,#H7:::0.136
217217
@test [e.number for e in net.node[12].edge] == [1,12,9] # or: rotate didn't work at node -2
218218

219219
end # of testset for rotate
220+
221+
@testset "other in manipulateNet" begin
222+
223+
net0 = readTopology("((((C:0.9)I1:0.1)I3:0.1,((A:1.0)I2:0.4)I3:0.6):1.4,(((B:0.2)H1:0.6)I2:0.5)I3:2.1);");
224+
PhyloNetworks.removedegree2nodes!(net0, true) # true: to keep the root of degree-2
225+
@test writeTopology(net0, round=true) == "((C:1.1,A:2.0):1.4,B:3.4);"
226+
227+
end # of testset for other functions in manipulateNet

0 commit comments

Comments
 (0)