Skip to content

Commit 765fff5

Browse files
committed
Fix tree plot duplicated legend
1 parent 8ab73ff commit 765fff5

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

workflow/scripts/report/phylo_plots.R

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ source(snakemake@params[["design"]])
2222

2323
# legend thresholds for ml tree
2424
legend.names <- c(
25-
tip_label = "Studied samples",
25+
tip_label = "Target samples",
2626
boot_alrt_pass = sprintf(
2727
"UFBoot ≥ %s%s & SH-aLRT ≥ %s%s ",
2828
snakemake@params[["boot_th"]],
@@ -242,18 +242,31 @@ p <- ggtree(tree_ml, layout = "circular") +
242242
geom_treescale(x = 0.0008) +
243243
geom_rootedge(0.0005) +
244244
xlim(-0.0008, NA) +
245+
scale_color_manual(
246+
name = "Class",
247+
values = tree_colors,
248+
labels = legend.names,
249+
na.value = NA,
250+
guide = guide_legend(
251+
override.aes = list(
252+
size = node.size,
253+
alpha = node.alpha,
254+
shape = 19
255+
)
256+
)
257+
) +
245258
scale_size_manual(
246259
name = "Class",
247260
values = node.size,
248-
labels = legend.names
261+
labels = legend.names,
262+
guide = FALSE
249263
) +
250264
scale_alpha_manual(
251265
name = "Class",
252266
values = node.alpha,
253-
labels = legend.names
254-
) +
255-
labs(color = "Class") +
256-
scale_color_manual(values = tree_colors, na.value = NA, labels = legend.names)
267+
labels = legend.names,
268+
guide = FALSE
269+
)
257270

258271
ggsave(
259272
filename = snakemake@output[["tree_ml"]],

0 commit comments

Comments
 (0)