From 4fcb1caee93164239dc9adb286b0847b7532c3ab Mon Sep 17 00:00:00 2001 From: Maximilian Danielsson Date: Mon, 29 Jul 2024 15:54:52 +0200 Subject: [PATCH] Respond to #24 --- Project.toml | 2 +- src/CodonMolecularEvolution.jl | 2 +- src/difFUBAR/difFUBAR.jl | 19 +++++++++++-------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Project.toml b/Project.toml index b68678c..2dd3baa 100644 --- a/Project.toml +++ b/Project.toml @@ -5,7 +5,6 @@ version = "0.1.0" [deps] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" -Compose = "a81c6b42-2e10-5240-aca2-a61377ecd94b" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" FASTX = "c2308a5c-f048-11e8-3e8a-31650f418d12" @@ -14,6 +13,7 @@ Measures = "442fdcdd-2543-5da2-b0f3-8c86c306513e" MolecularEvolution = "9f975960-e239-4209-8aa0-3d3ad5a82892" NLopt = "76087f3c-5699-56af-9a33-bf431cd00edd" ParameterHandling = "2412ca09-6db7-441c-8e3a-88d5709968c5" +Phylo = "aea672f4-3940-5932-aa44-993d1c3ff149" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" diff --git a/src/CodonMolecularEvolution.jl b/src/CodonMolecularEvolution.jl index d171f1a..f5f850d 100644 --- a/src/CodonMolecularEvolution.jl +++ b/src/CodonMolecularEvolution.jl @@ -1,6 +1,6 @@ module CodonMolecularEvolution -using FASTX, MolecularEvolution, Measures, Compose, Plots, StatsBase, Distributions, DataFrames, CSV, NLopt, ParameterHandling, LinearAlgebra +using FASTX, MolecularEvolution, Measures, Plots, StatsBase, Distributions, DataFrames, CSV, NLopt, ParameterHandling, LinearAlgebra, Phylo abstract type difFUBARGrid end diff --git a/src/difFUBAR/difFUBAR.jl b/src/difFUBAR/difFUBAR.jl index d9ca4df..b93843d 100644 --- a/src/difFUBAR/difFUBAR.jl +++ b/src/difFUBAR/difFUBAR.jl @@ -173,14 +173,17 @@ function difFUBAR_init(outpath_and_file_prefix, treestring, tags; tag_colors=DIF push!(tag_colors, "black") #ASSUMPTION: background color is always black if exports - #Replace with Phylo.jl based plot? - color_dict = Dict(zip(getnodelist(tree), [tag_colors[model_ind(n.name, tags)] for n in getnodelist(tree)])) - label_dict = Dict(zip(getnodelist(tree), [strip_tags_from_name(n.name) for n in getnodelist(tree)])) - img = tree_draw(tree, canvas_height=(3 + length(getleaflist(tree)) / 5)cm, - draw_labels=true, dot_color_dict=color_dict, - line_color_dict=color_dict, line_width=0.3, min_dot_size=0.01, - nodelabel_dict=label_dict) - img |> SVG(analysis_name * "_tagged_input_tree.svg", 15cm, (3 + length(getleaflist(tree)) / 5)cm) + #TODO: update plots in docs + phylo_tree = get_phylo_tree(tree) + tagging = [tag_colors[model_ind(n, tags)] for n in nodenameiter(phylo_tree)] + for node in nodeiter(phylo_tree) + renamenode!(phylo_tree, node, strip_tags_from_name(node.name)) + end + #Warnings regarding marker- and linecolor also appear in the Phylo.jl docs example + #Note: sometimes long leafnames are truncated/not visible in the plot + pl = plot(phylo_tree, + showtips = true, tipfont = 6, markercolor = tagging, linecolor = tagging, markerstrokewidth = 0, size = (600, (120 + length(getleaflist(tree)) * 8))) + savefig_tweakSVG(analysis_name * "_tagged_input_tree.svg", pl) end #Tags and tag colors are now ordered, and tag_colors includes the untagged category