-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plotting of AbstractTrees; close #8 #15
Conversation
src/plot.jl
Outdated
@@ -0,0 +1,222 @@ | |||
using RecipesBase | |||
using Phylo | |||
using Plots # now necessary for the labels :-( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using Plots
will have to go before merging! But it's waiting for some functionality becoming available in RecipesBase.
Codecov Report
@@ Coverage Diff @@
## master #15 +/- ##
==========================================
- Coverage 74.22% 66.47% -7.75%
==========================================
Files 14 15 +1
Lines 1253 1402 +149
==========================================
+ Hits 930 932 +2
- Misses 323 470 +147
Continue to review full report at Codecov.
|
I'll write tests before merging of course. |
due to clashes with `seriescolor` in Plots
Does not work yet
8685609
to
0ddb2c5
Compare
It all looks great so far - I'll have a look in more detail tomorrow. In the meanwhile, if you want an easily accessible tree that you don't have to delete to work with for plotting that we can play with too, then in the repo julia> tree = open(parsenexus, "test/H1N1.trees")["TREE1"]
[ Info: Created a tree called 'TREE1'
[ Info: Created a tree called 'TREE2'
BinaryTree{DataFrames.DataFrame,Dict{String,Any}} with 507 tips, 1013 nodes and 1012 branches.
Leaf names are H1N1_A_MIYAGI_3_2000, H1N1_A_PARMA_6_2008, H1N1_A_AKITA_86_2002, H1N1_A_DAKAR_14_1997, H1N1_A_EGYPT_84_2001, ... [501 omitted] ... and H1N1_A_HONGKONG_2070_1999
julia> getnoderecord(tree, "H1N1_A_PARMA_6_2008")
Dict{String,Any} with 12 entries:
"rate_95%_HPD" => [0.000800258, 0.00565223]
"length_median" => 1.0634
"rate" => 0.00295453
"length_range" => [0.272117, 2.10698]
"height_range" => [1.0, 1.0]
"length" => 1.06811
"height" => 1.0
"rate_median" => 0.00270733
"rate_range" => [0.00036974, 0.0152626]
"length_95%_HPD" => [0.629248, 1.47885]
"height_95%_HPD" => [1.0, 1.0]
"height_median" => 1.0 |
I've added the fix to Plots in v0.22.2 (tagged) and updated this, so now this works and can be merged. |
I've merged this, but I haven't put out a release yet, because I have finally fixed the problem I had with Julia 1.0 crashing. If I don't manage to get everything working by the end of today I'll release this as is, but I'm hoping to at least revise the whole API and Interface so that all future changes will be fairly seamless... |
oh sounds sweet! |
Yeah, well... time will tell! |
Do not merge yet
This PR awaits some improvements on the text formatting side in Plots, which may be a little while. However, I just wanted to show the progress and ideas, and harvest feedback. Feedback on anything - the interface, commands, defaults, line widths, font sizes, spacing etc very welcome. This is a crucial part of getting it right.
I've put some general considerations in #14, as there was things that was difficult for me to learn and adapt to.
The PR adds plotting functionality for AbstractTrees. I've essentially ignored the whole concept of branches (I think of them as property of their subtending nodes) and done everything on nodes. Everything is designed to fit in with the existing syntax of Plots.
One improvement I still want to do is to allow passing things like
line_z
(to color the lines) asDict{Node, T}
and have the recipe transform it into Vectors, so the user will not have to worry about ordering things the right way.I've also made a
ladderize
function for better plotting to throw in, but I can't get the thing to work. I think it's something to do with the traversal order.There are two basic layouts:
:dendrogram
(the default)and
:fan
You can color the branches after a variable. So let us evolve a trait on the
hummingbird tree according to Brownian motion. I use a depth-first recursive mapping
function I've also put in the code
Or let's highlight the oscines in the passerine tree
It's also got support for markers (that can have different colors and layout as well), and basic support for branch annotations (though this isn't as nice as it should be).
Finally, it's already somewhat efficient (but there is plenty of room for avoiding allocations and making it faster still)