Skip to content

Commit

Permalink
Merge pull request #31 from MurrellGroup/Phylo-svg-tree-export
Browse files Browse the repository at this point in the history
Respond to #24
  • Loading branch information
nossleinad authored Jan 9, 2025
2 parents a2cd506 + 15b432a commit c6daed9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ version = "0.1.0"
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
AdvancedHMC = "0bf59076-c3b1-5ca4-86bd-e02cd72cde3d"
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"
Expand All @@ -21,6 +20,7 @@ MolecularEvolution = "9f975960-e239-4209-8aa0-3d3ad5a82892"
NLopt = "76087f3c-5699-56af-9a33-bf431cd00edd"
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
ParameterHandling = "2412ca09-6db7-441c-8e3a-88d5709968c5"
Phylo = "aea672f4-3940-5932-aa44-993d1c3ff149"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
SimpleUnPack = "ce78b400-467f-4804-87d8-8f486da07d0a"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Expand Down
2 changes: 1 addition & 1 deletion src/CodonMolecularEvolution.jl
Original file line number Diff line number Diff line change
@@ -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
using NNlib, Distributions, Zygote, AdvancedHMC, LogDensityProblems, SimpleUnPack, AbstractMCMC, LogDensityProblemsAD, Interpolations, MCMCChains

abstract type difFUBARGrid end
Expand Down
19 changes: 11 additions & 8 deletions src/difFUBAR/difFUBAR.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,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
Expand Down
2 changes: 1 addition & 1 deletion src/difFUBAR/grids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ function gridprep(tree, tags; verbosity = 1, foreground_grid = 6, background_gri
length(background_omega_grid) * length(alphagrid) * length(omegagrid)^2

num_groups = length(tags)
is_background = maximum([model_ind(n.name, tags) for n in getnodelist(tree) if !isroot(n)]) > num_groups
is_background = maximum([model_ind(n.name, tags) for n in getnodelist(tree) if !MolecularEvolution.isroot(n)]) > num_groups
tensor_dims = 1+num_groups+is_background;

codon_param_vec = [[a] for a in alphagrid]
Expand Down

0 comments on commit c6daed9

Please sign in to comment.