EcoJulia / Phylo.jl

Simple phylogenetic trees in Julia to work with Diversity.jl - https://github.com/EcoJulia/Diversity.jl
BSD 2-Clause "Simplified" License
34 stars 13 forks source link

WIP improve plotting of traits #25

Closed mkborregaard closed 4 years ago

mkborregaard commented 4 years ago

This is still WIP - it improves the plotting of traits. It allows traits to be plotted by passing their name, and also enables plotting of discrete traits by adding keywords marker_group and line_group. So far mostly implemented for markers. The implementation is a bit DWIM as it tries to guess whether the user wants markers only on internal nodes (which is standard in R) or nodes + tips (as seems to be your expectation here), based on the number of passed marker attributes.

With this:

using Phylo, Plots
hummers = open(parsenewick, "hummingbirds_tree.txt")
rand(BrownianTrait(hummers, "Trait"))
plot(hummers, 
     showtips = false, line_z = "Trait", 
     lw = 2, linecolor = :RdYlBu)

test1

@enum TemperatureTrait lowTempPref midTempPref highTempPref
rand(SymmetricDiscreteTrait(hummers, TemperatureTrait, 0.4))
plot(hummers, showtips = false,  
     marker_group = "TemperatureTrait", 
     legend = :topleft, msc = :white, treetype = :fan, 
     c = [:red :blue :green])

test2

I need to implement the line_group keyword, and also want to add the possibility for adding Dicts.

codecov[bot] commented 4 years ago

Codecov Report

Merging #25 into rr/linkedlist will decrease coverage by 1.34%. The diff coverage is 0%.

Impacted file tree graph

@@                Coverage Diff                @@
##           rr/linkedlist      #25      +/-   ##
=================================================
- Coverage          56.43%   55.08%   -1.35%     
=================================================
  Files                 16       16              
  Lines               1834     1877      +43     
=================================================
- Hits                1035     1034       -1     
- Misses               799      843      +44
Impacted Files Coverage Δ
src/plot.jl 0% <0%> (ø) :arrow_up:
src/trim.jl 96.96% <0%> (-3.04%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 65c1be6...8dcafe1. Read the comment docs.

mkborregaard commented 4 years ago

@richardreeve you never commented on this - look how gorgeous those plots are though :-D

richardreeve commented 4 years ago

It is truly beautiful! Sorry for missing this - it was right in the middle of my teaching and it just got lost... I’m back off strike next week and I’ll have a look.

richardreeve commented 4 years ago

This does look very nice. I'm still working through the linkedlist changes, but was there more you had planned to do here? You mention the line_group keyword and adding Dicts, but I don't actually know what you mean by those comments?

mkborregaard commented 4 years ago

A keyword to color lines by a categorical variable. And coloring with a node=>trait Dict rather than passing vectors. It's just enhancements and shouldn't block merging