Skip to content

Commit bd15d31

Browse files
committed
Fix missing class on context tree plot
Adds context tree bootstrap settings to config YAML
1 parent 55fb139 commit bd15d31

7 files changed

Lines changed: 65 additions & 49 deletions

File tree

config/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,11 @@ All of the following variables are pre-defined in [config.yaml](/config/config.y
133133
- `COORDINATES_JSON`: path of a JSON file containing genome feature coordinates for data visualization.
134134
- `GENETIC_CODE_JSON`: path of a JSON file containing a genetic code for gene translation.
135135
- `TREE_MODEL`: substitution model used by IQTREE (see [docs](http://www.iqtree.org/doc/Substitution-Models)).
136-
- `UFBOOT_REPS`: ultrafast bootstrap replicates for IQTREE (see [UFBoot](https://doi.org/10.1093/molbev/msx281)).
137-
- `SHALRT_REPS`: Shimodaira–Hasegawa approximate likelihood ratio test bootstrap replicates for IQTREE (see [SH-aLRT](https://doi.org/10.1093/sysbio/syq010)).
136+
- `UFBOOT` & `SHALRT`: settings for ultrafast bootstrap (see [UFBoot](https://doi.org/10.1093/molbev/msx281))
137+
and Shimodaira–Hasegawa approximate likelihood ratio test bootstrap
138+
(see [SH-aLRT](https://doi.org/10.1093/sysbio/syq010)) in IQTREE runs:
139+
- `REPS`: number of replicates.
140+
- `THRESHOLD`: value cutoff for visualization.
138141
- `VC`: variant calling configuration:
139142
- `MAX_DEPTH`: maximum depth at a position for `samtools mpileup` (option `-d`).
140143
- `MIN_QUALITY`: minimum base quality for `samtools mpileup` (option `-Q`).

config/config.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ GENETIC_CODE_JSON:
88
"config/standard_genetic_code.json"
99
TREE_MODEL:
1010
"GTR+F+I+G4"
11-
UFBOOT_REPS:
12-
1000
13-
SHALRT_REPS:
14-
1000
11+
UFBOOT:
12+
REPS: 1000
13+
THRESHOLD: 0.95
14+
SHALRT:
15+
REPS: 1000
16+
THRESHOLD: 0.80
1517
VC:
1618
MAX_DEPTH: 0
1719
MIN_QUALITY: 0

config/design_plots.R

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,7 @@ TREE_NODE_SIZE <- c(
6060

6161
TREE_LEGEND_NAMES <- c(
6262
tip_label = "Target samples",
63-
boot_alrt_pass = sprintf(
64-
"UFBoot ≥ %s%s & SH-aLRT ≥ %s%s ",
65-
snakemake@params[["boot_th"]],
66-
"%",
67-
snakemake@params[["alrt_th"]],
68-
"%"
69-
)
63+
boot_alrt_pass = "UFBoot ≥ %.2f%s & SH-aLRT ≥ %.2f%s"
7064
)
7165

7266
# Nucleotide variants classification colors and labels

workflow/rules/context.smk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ rule ml_context_tree:
7676
params:
7777
seqtype = "DNA",
7878
name = OUTPUT_NAME,
79-
ufboot = config["UFBOOT_REPS"],
80-
alrt = config["SHALRT_REPS"],
79+
ufboot = config["UFBOOT"]["REPS"],
80+
alrt = config["SHALRT"]["REPS"],
8181
outgroup = config["ALIGNMENT_REFERENCE"],
8282
model = config["TREE_MODEL"]
8383
input:

workflow/rules/report.smk

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ rule context_phylogeny_data:
128128
params:
129129
design = config["PLOTS"],
130130
ref_name = config["ALIGNMENT_REFERENCE"],
131-
boot_th = 95.0,
132-
alrt_th = 80.0,
131+
boot_th = config["UFBOOT"]["THRESHOLD"],
132+
alrt_th = config["SHALRT"]["THRESHOLD"],
133133
input:
134134
target_fasta = OUTDIR/f"{OUTPUT_NAME}.fasta",
135135
tree = OUTDIR/f"tree_context/{OUTPUT_NAME}.treefile",
@@ -148,6 +148,8 @@ rule context_phylogeny_plot:
148148
design = config["PLOTS"],
149149
plot_height_mm = 119.4,
150150
plot_width_mm = 159.2,
151+
boot_th = config["UFBOOT"]["THRESHOLD"],
152+
alrt_th = config["SHALRT"]["THRESHOLD"],
151153
input:
152154
tree = OUTDIR/f"tree_context/{OUTPUT_NAME}.treefile",
153155
json = REPORT_DIR_TABLES/"context_phylogeny.json",
@@ -332,8 +334,8 @@ rule report:
332334
params:
333335
workflow_version = get_repo_version(BASE_PATH.as_posix(), __version__),
334336
min_ivar_freq = config["VC"]["IVAR_FREQ"],
335-
ufboot_reps = config["UFBOOT_REPS"],
336-
shalrt_reps = config["SHALRT_REPS"],
337+
ufboot_reps = config["UFBOOT"]["REPS"],
338+
shalrt_reps = config["SHALRT"]["REPS"],
337339
name = config["OUTPUT_NAME"],
338340
use_bionj = config["USE_BIONJ"],
339341
cor_method = config["COR"]["METHOD"],

workflow/scripts/report/context_phylogeny_data.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ log_threshold(INFO)
1616
# Import file with plots style
1717
source(snakemake@params[["design"]])
1818

19+
# Format tree label for well supported nodes
20+
TREE_LEGEND_NAMES["boot_alrt_pass"] <- sprintf(
21+
TREE_LEGEND_NAMES["boot_alrt_pass"],
22+
snakemake@params[["boot_th"]], "%",
23+
snakemake@params[["alrt_th"]], "%"
24+
)
25+
1926
tree_ml <- read.tree(snakemake@input[["tree"]]) %>%
2027
root(
2128
snakemake@params[["ref_name"]],

workflow/scripts/report/context_phylogeny_plot.R

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,46 +16,54 @@ log_threshold(INFO)
1616
# Import file with plots style
1717
source(snakemake@params[["design"]])
1818

19+
# Format tree label for well supported nodes
20+
TREE_LEGEND_NAMES["boot_alrt_pass"] <- sprintf(
21+
TREE_LEGEND_NAMES["boot_alrt_pass"],
22+
snakemake@params[["boot_th"]], "%",
23+
snakemake@params[["alrt_th"]], "%"
24+
)
25+
1926
log_info("Reading JSON data")
2027
json <- read_json(snakemake@input$json)
2128

2229
log_info("Reading tree")
2330
tree_ml <- read.tree(snakemake@input[["tree"]]) %>%
24-
root(
25-
json$root,
26-
resolve.root = TRUE
27-
)
31+
root(
32+
json$root,
33+
resolve.root = TRUE
34+
)
2835

2936
log_info("Reading tree annotation")
3037
annotation <- read_csv(snakemake@input$annotation)
3138

3239
log_info("Plotting M-L tree with context samples")
33-
p <- ggtree(tree_ml, layout = "circular") %<+% annotation +
34-
geom_highlight(node = json$target_mrca, colour = "red", alpha = 0) +
35-
geom_point(aes(color = Class, size = Class)) +
36-
geom_treescale(1.05 * json$max_tip_length) +
37-
geom_rootedge(0.05 * json$max_tip_length) +
38-
xlim(-json$max_tip_length / 3, NA) +
39-
scale_color_manual(
40-
values = setNames(
41-
TREE_PALETTE[names(TREE_LEGEND_NAMES)],
42-
TREE_LEGEND_NAMES
43-
),
44-
na.translate = FALSE
45-
) +
46-
scale_size_manual(
47-
values = setNames(
48-
TREE_NODE_SIZE[names(TREE_LEGEND_NAMES)],
49-
TREE_LEGEND_NAMES
50-
),
51-
na.translate = FALSE
52-
)
40+
p <- ggtree(tree_ml, layout = "circular") %<+%
41+
annotation +
42+
geom_highlight(node = json$target_mrca, colour = "red", alpha = 0) +
43+
geom_point(aes(color = Class, size = Class)) +
44+
geom_treescale(1.05 * json$max_tip_length) +
45+
geom_rootedge(0.05 * json$max_tip_length) +
46+
xlim(-json$max_tip_length / 3, NA) +
47+
scale_color_manual(
48+
values = setNames(
49+
TREE_PALETTE[names(TREE_LEGEND_NAMES)],
50+
TREE_LEGEND_NAMES
51+
),
52+
na.translate = FALSE
53+
) +
54+
scale_size_manual(
55+
values = setNames(
56+
TREE_NODE_SIZE[names(TREE_LEGEND_NAMES)],
57+
TREE_LEGEND_NAMES
58+
),
59+
na.translate = FALSE
60+
)
5361

5462
ggsave(
55-
filename = snakemake@output[["plot"]],
56-
plot = p,
57-
width = snakemake@params[["plot_width_mm"]],
58-
height = snakemake@params[["plot_height_mm"]],
59-
units = "mm",
60-
dpi = 250
63+
filename = snakemake@output[["plot"]],
64+
plot = p,
65+
width = snakemake@params[["plot_width_mm"]],
66+
height = snakemake@params[["plot_height_mm"]],
67+
units = "mm",
68+
dpi = 250
6169
)

0 commit comments

Comments
 (0)