Skip to content

Commit

Permalink
removedegree2nodes! : option to keep the root (#181)
Browse files Browse the repository at this point in the history
also: CITATION.bib that works with PkgCite, citation() now using it.
Co-authored-by: Claudia Solis-Lemus <[email protected]>
  • Loading branch information
cecileane and crsl4 authored Aug 10, 2022
1 parent 2cf465b commit 42f2c18
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 43 deletions.
54 changes: 54 additions & 0 deletions CITATION.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
% reference for the software itself
@article{2017SolislemusBastideAne_PhyloNetworks,
author = {Sol{\'\i}s-Lemus, Claudia and Bastide, Paul and An{\'e}, C{\'e}cile},
title = {PhyloNetworks: A Package for Phylogenetic Networks},
journal = {Molecular Biology and Evolution},
year = {2017},
volume = {34},
number = {12},
pages = {3292-3298},
doi = {10.1093/molbev/msx235},
}

% paper on the SNaQ method
@article{2016SolislemusAne_SNaQ,
author = {Sol{\'\i}s-Lemus, Claudia and An{\'e}, C{\'e}cile},
title = {Inferring Phylogenetic Networks with Maximum Pseudolikelihood under Incomplete Lineage Sorting},
journal = {PLOS Genetics},
year = {2016},
volume = {12},
number = {3},
pages = {1-21},
doi = {10.1371/journal.pgen.1005896},
}
% paper on phylogenetic comparative methods for continuous traits on networks
@article{2018Bastide_continuoustraitevolution,
author = {Bastide, Paul and Sol{\'\i}s-Lemus, Claudia and Kriebel, Ricardo and William Sparks, K and An{\'e}, C{\'e}cile},
title = {Phylogenetic Comparative Methods on Phylogenetic Networks with Reticulations},
journal = {Systematic Biology},
year = {2018},
volume = {67},
number = {5},
pages = {800-820},
doi = {10.1093/sysbio/syy033},
}
% paper on phylogenetic comparative methods for discrete traits on networks
@article{2020Karimi_baobab_discretetraitevolution,
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},
title = {Reticulate Evolution Helps Explain Apparent Homoplasy in Floral Biology and Pollination in Baobabs (\textit{{Adansonia}}; {Bombacoideae}; {Malvaceae})},
journal = {Systematic Biology},
year = {2020},
volume = {69},
number = {3},
pages = {462-478},
doi = {10.1093/sysbio/syz073},
}
% paper on continuous traits with intraspecific variation
@article{2022Teo_intraspeciesvariation,
author = {Teo, Benjamin and Rose, Jeffrey P. and Bastide, Paul and An{\'e}, C{\'e}cile},
title = {Accounting for intraspecific variation in continuous trait evolution on a reticulate phylogeny},
journal = {bioRxiv},
year = {2022},
doi = {10.1101/2022.05.12.490814},
publisher = {Cold Spring Harbor Laboratory},
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ To get help, check
for common questions. Join the group to post/email your questions,
or to receive information on new versions, bugs fixed, etc.

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

- Claudia Sol&iacute;s-Lemus, Paul Bastide and C&eacute;cile An&eacute; (2017).
PhyloNetworks: a package for phylogenetic networks.
Expand Down Expand Up @@ -86,5 +86,5 @@ ancestral state reconstruction, rates):
- Karimi, Grover, Gallagher, Wendel, Ané & Baum (2020). Reticulate evolution
helps explain apparent homoplasy in floral biology and pollination in baobabs
(*Adansonia*; Bombacoideae; Malvaceae).
[Systematic Biology](https://academic.oup.com/sysbio/advance-article/doi/10.1093/sysbio/syz073/5613901?guestAccessKey=a32e7dd3-27fd-4a13-b171-7ff5d6da0e01),
69(3):462-478. doi: 10.1093/sysbio/syz073.
Systematic Biology,
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).
2 changes: 2 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and their use for trait evolution.

## References

See their [bibtex format](https://github.com/crsl4/PhyloNetworks.jl/blob/master/CITATION.bib).

for the package:
- Claudia Solís-Lemus, Paul Bastide and Cécile Ané (2017).
PhyloNetworks: a package for phylogenetic networks.
Expand Down
36 changes: 4 additions & 32 deletions src/auxiliary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1707,36 +1707,8 @@ end

#------------------------------------
function citation()
println("If you use PhyloNetworks, please cite:")
println("@article{phylonetworks,")
println("author = {Sol\'{i}s-Lemus, C. and Bastide, P. and An\'{e}, C.},")
println("year = {2017},")
println("title = {{PhyloNetworks: a package for phylogenetic networks}},")
println("journal = {Molecular Biology and Evolution},")
println("volume = {34},")
println("number = {12},")
println("pages = {3292--3298},")
println("pmid = {28961984}}")
println("\n")
println("If you use SNaQ, please also cite:")
println("@article{snaq,")
println("author = {Sol\'{i}s-Lemus, C. AND An\'{e}, C.},")
println("journal = {PLOS Genetics},")
println("title = {Inferring Phylogenetic Networks with Maximum Pseudolikelihood under Incomplete Lineage Sorting},")
println("year = {2016},")
println("volume = {12},")
println("pages = {1--21},")
println("number = {3},")
println("pmc = {PMC4780787}}")
println("\n")
println("If you use trait models in networks, please also cite:")
println("@article {traits,")
println("author = {Bastide, Paul and Sol\'{i}s-Lemus, Claudia and Kriebel, Ricardo and Sparks, Kenneth William and An{\'e}, C{\'e}cile},")
println("title = {Phylogenetic Comparative Methods on Phylogenetic Networks with Reticulations},")
println("journal = {Systematic Biology},")
println("volume = {67},")
println("number = {5},")
println("pages = {800--820},")
println("year = {2018},")
println("doi = {10.1093/sysbio/syy033}}")
bibfile = joinpath(@__DIR__, "..", "CITATION.bib")
out = readlines(bibfile)
println("Bibliography in bibtex format also in CITATION.bib")
println(join(out,'\n'))
end
27 changes: 19 additions & 8 deletions src/manipulateNet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,13 @@ function fuseedgesat!(i::Integer, net::HybridNetwork, multgammas=false::Bool)
end

"""
removedegree2nodes!(net::HybridNetwork)
removedegree2nodes!(net::HybridNetwork, keeproot=false::Bool)
Delete *all* nodes of degree two in `net`, fusing the two adjacent edges
together each time, and return the network.
If the network has a degree-2 root, then the root is eliminated as well,
leaving the network unrooted.
If the network has a degree-2 root and `keeproot` is false,
then the root is eliminated as well, leaving the network unrooted.
If `keeproot` is true, then the root is kept even if it's of degree 2.
See [`fuseedgesat!`](@ref).
Expand All @@ -520,13 +521,23 @@ julia> PhyloNetworks.removedegree2nodes!(net);
julia> writeTopology(net) # even the root is gone
"(#H2,S4,(((S1,(S2)#H1),(#H1,S3)))#H2);"
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);");
julia> PhyloNetworks.removedegree2nodes!(net, true);
julia> writeTopology(net, round=true) # the root was kept
"((C:1.1,A:2.0):1.4,B:3.4);"
```
"""
function removedegree2nodes!(net::HybridNetwork)
ndegree2nodes = sum(length(n.edge) == 2 for n in net.node)
# caution: nodes and their indices in the 'current' network may change some of them are removed
for ni in 1:ndegree2nodes # empty if 0 degree-2 nodes
i = findfirst(n -> length(n.edge) == 2, net.node)
function removedegree2nodes!(net::HybridNetwork, keeproot=false::Bool)
rootnode = net.node[net.root]
toberemoved(nn) = (keeproot ? length(nn.edge) == 2 && nn !== rootnode :
length(nn.edge) == 2 )
ndegree2nodes = sum(toberemoved.(net.node))
# caution: nodes and their indices in the 'current' network may change when some of them are removed
for _ in 1:ndegree2nodes # empty if 0 degree-2 nodes
i = findfirst(toberemoved, net.node)
i !== nothing || error("incorrect predicted number of degree-2 nodes to remove...")
fuseedgesat!(i, net)
end
Expand Down
8 changes: 8 additions & 0 deletions test/test_manipulateNet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,11 @@ net=readTopology("(4,((1,(2)#H7:::0.864):2.069,(6,5):3.423):0.265,(3,#H7:::0.136
@test [e.number for e in net.node[12].edge] == [1,12,9] # or: rotate didn't work at node -2

end # of testset for rotate

@testset "other in manipulateNet" begin

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);");
PhyloNetworks.removedegree2nodes!(net0, true) # true: to keep the root of degree-2
@test writeTopology(net0, round=true) == "((C:1.1,A:2.0):1.4,B:3.4);"

end # of testset for other functions in manipulateNet

0 comments on commit 42f2c18

Please sign in to comment.