Skip to content

Commit dad4787

Browse files
authored
Update rules (#16)
* update plot pca and roc * update plot scripts * fix typo + add logs * update common * new report files * Update report * update rule graph * update readme
1 parent fa5f6f0 commit dad4787

16 files changed

+166
-138
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Qadabra generates many results files including many intermediate files that can
5757
Each tool's output is stored in a separate subdirectory.
5858
For the R tools, an RDS object with the tool's R data is saved.
5959
The raw outputs are processed and concatenated into a file called `concatenated_differentials.tsv`.
60-
A Qurro visualization of all the tool ranks is generated at `qurro/index.html`.
60+
A Qurro visualization of all the tool ranks is generated at `results/qurro/index.html`.
6161
An interactive table with all the tool outputs is at `results/differentials_table.html`.
6262

6363
For each tool, the ranked features are used for machine learning models.
@@ -71,8 +71,7 @@ The `ml` subdirectory of each tool contains the features used, sample log-ratios
7171
The differential rank plots of each tool are plotted as `<tool_name>_differentials.svg`.
7272
A heatmap of the pairwise Spearman correlation among all pairs of tools is available as well.
7373
We also generated interactive plots to help compare the ranks of different microbes from the tools.
74-
`figures/pca.html` generates a PCA plot of all the microbes, showing the concordance and discordance of results as well as the contribution of the tools.
74+
`figures/pca.svg` generates a PCA plot of all the microbes, showing the concordance and discordance of results as well as the contribution of the tools.
7575
You can use the `figures/rank_comparisons.html` webpage to dynamically explore the relationship between pairs of tools.
7676
The `upset` subdirectory contains [UpSet](https://doi.org/10.1109%2FTVCG.2014.2346248) plots comparing the features from each tool.
77-
7877
Finally, the `roc` subdirectory contains ROC plots of all tools at each percentile of features.

config/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
table: "data/table.biom"
22
metadata: "data/metadata.tsv"
3+
stylesheet: "config/qadabra.mplstyle"
34
model:
45
covariate: anemia
56
target: anemic

imgs/rule_graph.png

1.05 KB
Loading

workflow/report/create_table.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Table of differentials from all tools.

workflow/report/plot_pca.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Plot of differentials from all tools. Differentials are mean-centered and scaled before PCA.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Interactive plot of rank comparisons. Select the two tools to compare and the plot will update.

workflow/report/qurro.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Qurro visualization of differentials from all tools. For more information on Qurro, see `Fedarko 2020 <https://academic.oup.com/nargab/article/2/2/lqaa023/5826153>`_.

workflow/rules/common.smk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ all_viz_files.extend(
3030
pctile=config["log_ratio_feat_pcts"],
3131
)
3232
)
33-
all_viz_files.extend(expand("figures/{fig}.html", fig=["pca", "rank_comparisons"]))
33+
all_viz_files.append("figures/rank_comparisons.html")
34+
all_viz_files.append("figures/pca.svg")
3435

3536
all_input = all_viz_files.copy()
3637
all_input.extend(["results/qurro", "results/differentials_table.html"])

workflow/rules/diffab.smk

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -159,41 +159,3 @@ rule combine_differentials:
159159
"../envs/qadabra-default.yaml"
160160
script:
161161
"../scripts/concatenate_differentials.py"
162-
163-
164-
rule qurro:
165-
input:
166-
ranks="results/concatenated_differentials.tsv",
167-
table=config["table"],
168-
metadata=config["metadata"],
169-
output:
170-
report(
171-
directory("results/qurro"),
172-
htmlindex="index.html",
173-
category="Visualization",
174-
),
175-
log:
176-
"log/qurro.log",
177-
conda:
178-
"../envs/qadabra-songbird.yaml"
179-
shell:
180-
"""
181-
qurro \
182-
--ranks {input.ranks} \
183-
--table {input.table} \
184-
--sample-metadata {input.metadata} \
185-
--output-dir {output} > {log} 2>&1
186-
"""
187-
188-
189-
rule create_table:
190-
input:
191-
"results/concatenated_differentials.tsv",
192-
output:
193-
report("results/differentials_table.html", category="Visualization"),
194-
log:
195-
"log/create_table.log",
196-
conda:
197-
"../envs/qadabra-default.yaml"
198-
script:
199-
"../scripts/create_table.py"

workflow/rules/visualization.smk

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import re
22

33

4-
stylesheet = "config/qadabra.mplstyle"
4+
stylesheet = config["stylesheet"]
55

66

77
rule plot_differentials:
@@ -11,14 +11,12 @@ rule plot_differentials:
1111
report(
1212
"figures/{tool}_differentials.svg",
1313
caption="../report/plot_differentials.rst",
14-
category="Visualization",
15-
subcategory="Differentials",
14+
category="Differentials",
15+
subcategory="Rank Plots",
1616
labels={"tool": "{tool}"},
1717
),
1818
log:
1919
"log/plot_differentials.{tool}.log",
20-
params:
21-
stylesheet,
2220
conda:
2321
"../envs/qadabra-default.yaml"
2422
script:
@@ -32,19 +30,18 @@ rule plot_rank_correlation:
3230
report(
3331
"figures/spearman_heatmap.svg",
3432
caption="../report/plot_rank_correlation.rst",
35-
category="Visualization",
33+
category="Differentials",
34+
subcategory="Comparison"
3635
),
3736
log:
3837
"log/plot_rank_correlation.log",
39-
params:
40-
stylesheet,
4138
conda:
4239
"../envs/qadabra-default.yaml"
4340
script:
4441
"../scripts/plot_rank_correlations.py"
4542

4643

47-
rule upset:
44+
rule plot_upset:
4845
input:
4946
expand(
5047
"results/ml/{tool}/pctile_feats/pctile_{{pctile}}.tsv",
@@ -54,23 +51,19 @@ rule upset:
5451
numerator=report(
5552
"figures/upset/upset.pctile_{pctile}.numerator.svg",
5653
caption="../report/plot_upset.rst",
57-
category="Visualization",
58-
subcategory="UpSet",
54+
category="UpSet",
5955
labels={"percentile": "{pctile}", "type": "numerator"},
6056
),
6157
denominator=report(
6258
"figures/upset/upset.pctile_{pctile}.denominator.svg",
6359
caption="../report/plot_upset.rst",
64-
category="Visualization",
65-
subcategory="UpSet",
60+
category="UpSet",
6661
labels={"percentile": "{pctile}", "type": "denominator"},
6762
),
6863
wildcard_constraints:
6964
tool="(?!pca_pc1)\w*",
7065
log:
7166
"log/upset.pctile_{pctile}.log",
72-
params:
73-
stylesheet,
7467
conda:
7568
"../envs/qadabra-default.yaml"
7669
script:
@@ -87,14 +80,11 @@ rule plot_roc:
8780
report(
8881
"figures/roc/roc.pctile_{pctile}.svg",
8982
caption="../report/plot_roc.rst",
90-
category="Visualization",
91-
subcategory="ROC",
83+
category="ROC",
9284
labels={"percentile": "{pctile}"},
9385
),
9486
log:
9587
"log/plot_roc.{pctile}.log",
96-
params:
97-
stylesheet,
9888
conda:
9989
"../envs/qadabra-default.yaml"
10090
script:
@@ -108,9 +98,10 @@ rule plot_pca:
10898
prop_exp="results/pca/proportion_explained.tsv",
10999
output:
110100
report(
111-
"figures/pca.html",
112-
category="Visualization",
113-
subcategory="Differentials",
101+
"figures/pca.svg",
102+
caption="../report/plot_pca.rst",
103+
category="Differentials",
104+
subcategory="Comparison"
114105
),
115106
log:
116107
"log/plot_pca.log",
@@ -126,12 +117,58 @@ rule plot_rank_comparison:
126117
output:
127118
report(
128119
"figures/rank_comparisons.html",
129-
category="Visualization",
130-
subcategory="Differentials",
120+
caption="../report/plot_rank_comparison.rst",
121+
category="Differentials",
122+
subcategory="Comparison"
131123
),
132124
log:
133125
"log/plot_rank_comparison.log",
134126
conda:
135127
"../envs/qadabra-default.yaml"
136128
script:
137129
"../scripts/plot_rank_comparison.py"
130+
131+
132+
rule qurro:
133+
input:
134+
ranks="results/concatenated_differentials.tsv",
135+
table=config["table"],
136+
metadata=config["metadata"],
137+
output:
138+
report(
139+
directory("results/qurro"),
140+
caption="../report/qurro.rst",
141+
htmlindex="index.html",
142+
category="Differentials",
143+
subcategory="Comparison"
144+
),
145+
log:
146+
"log/qurro.log",
147+
conda:
148+
"../envs/qadabra-songbird.yaml"
149+
shell:
150+
"""
151+
qurro \
152+
--ranks {input.ranks} \
153+
--table {input.table} \
154+
--sample-metadata {input.metadata} \
155+
--output-dir {output} > {log} 2>&1
156+
"""
157+
158+
159+
rule create_table:
160+
input:
161+
"results/concatenated_differentials.tsv",
162+
output:
163+
report(
164+
"results/differentials_table.html",
165+
caption="../report/create_table.rst",
166+
category="Differentials",
167+
subcategory="Comparison"
168+
),
169+
log:
170+
"log/create_table.log",
171+
conda:
172+
"../envs/qadabra-default.yaml"
173+
script:
174+
"../scripts/create_table.py"

workflow/scripts/plot_differentials.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
fh.setFormatter(formatter)
1616
logger.addHandler(fh)
1717

18-
plt.style.use(snakemake.params[0])
18+
logging.captureWarnings(True)
19+
logging.getLogger("py.warnings").addHandler(fh)
20+
21+
plt.style.use(snakemake.config["stylesheet"])
1922

2023
logger.info("Loading differentials...")
2124
diffs = pd.read_table(snakemake.input[0], sep="\t", index_col=0).squeeze()

0 commit comments

Comments
 (0)