Skip to content

Conversation

@cvigilv
Copy link

@cvigilv cvigilv commented Feb 25, 2025

Decided to implement all the things I wish to have ASAP here. The list is:

  • treeplot
  • treescatter
  • treelabel
  • treecladelabel
  • treearea
  • treepie
  • treecollapsed

Related issues

Related #9, #10.

Superseeds #13.

Checklist

  • I am following the contributing guidelines
  • Tests are passing
  • Lint workflow is passing
  • Docs were updated and workflow is passing

Introduced TreeScatter recipe for scatter plots of tree nodes and
exported new functions:

- Added TreeScatter recipe with customizable attributes
- Implemented Makie.plot! function for TreeScatter
- Exported treescatter and treescatter! functions
- Updated documentation with new treescatter function details
- Removed marker-related attributes from TreePlot recipe
- Add nodeordering attribute to TreeScatter recipe
- Import AbstractTrees and PreOrderDFS in BasicTreePlotsMakieExt.jl
- Update plot! function to use nodeordering for scatter plotting
- Add nodeordering documentation in BasicTreePlots.jl
@cvigilv
Copy link
Author

cvigilv commented Feb 25, 2025

Here is an example using all the functions implemented to the moment:
image

using Revise
using CairoMakie, NewickTree
import Makie
using BasicTreePlots
using AbstractTrees

# Basic example
begin
    tree = ((:a, :b), (:c, (:d, :e)))

    fig = Figure()
    ax = Axis(fig[1, 1], xautolimitmargin=(0.1, 0.5))
    hidedecorations!(ax)
    hidespines!(ax)
    treearea!(ax, tree; addstroke=true, strokestyle=:dashdot, strokewidth=1.0, strokecolor=:magenta, padding=[0.0, 0.0])
    treearea!(ax, tree; node=(:c, (:d, :e)), color=:green, alpha=0.2, padding=[0.3, 0.3])
    treearea!(ax, tree; node=(:d, :e), color=:green, alpha=0.2)
    treearea!(ax, tree; node=(:a, :b), color=:red, alpha=0.2)
    treelabels!(ax, tree, usemaxdepth=true, tipannotations=Dict(:a => "A", :b => "B", :c => "C", :d => "D", :e => "E"))
    treescatter!(ax, tree)
    treecladelabel!(ax, tree, node=(:d, :e), color=:green, font=:bold, label="Super-Interesting-Clade", lineoffset=1.0)
    treecladelabel!(ax, tree, node=(:c, (:d, :e)), color=:lime, label="Clade", rotation=pi / 2, lineoffset=0.5, linestyle=:dash, linewidth=3, align=(:center, :top))
    treeplot!(ax, tree)
    fig
end

@cvigilv cvigilv mentioned this pull request Feb 25, 2025
4 tasks
@cvigilv
Copy link
Author

cvigilv commented Feb 25, 2025

Current status

  • treeplot*: draws tree, allows for diffent styling (stripped down old version)
  • treelabels: draws labels for given node, accepts a Dict to map label to node
  • treescatter*: add points into the nodes (same as Add TreeScatter Makie recipe #13)
  • treecladelabel: add label to clade (based on ggtree's geom_cladelabel)
  • treearea: highlight nodes using polygon (based on ggtree's geom_hilight)

Note: Functions suffixed with * already have their PolarAxis implementation done.

Note: I extracted the labeling functionality of treeplot, but it has a bug when plotting if the argument usemaxdepth to false. I'm currently looking into this.

@cvigilv
Copy link
Author

cvigilv commented Feb 25, 2025

I was thinking on renaming the functions to (1) shorten them and (2) make them more similar to ggtree. For example:

  • treelabels => labelnode
  • treescatter => treenodes
  • treecladelabel => labelclade

Let me know what you think, I really like the ggtree convention but its to atomic for how this package is structured.

@cvigilv
Copy link
Author

cvigilv commented Feb 25, 2025

image

Not the most pretty, but getting there

@cvigilv
Copy link
Author

cvigilv commented Feb 28, 2025

Update: due to how the plotting works, the treecollapsed function has to accept an argument nodestocollapse in order to convert the node into a collapsed representation. I find this ugly, since intuitively I would collapse the leafs after plotting the original tree. What do you think is the best way to handle this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant