Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ESB
ONT_pilot_gitlab
Commits
bb04dfe0
Commit
bb04dfe0
authored
Mar 05, 2021
by
Valentina Galata
Browse files
figures: added rgi fig
parent
fef8b5e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
workflow_figures/Snakefile
View file @
bb04dfe0
...
...
@@ -33,6 +33,7 @@ rule all:
fig_diamond_db="figures/fig_diamond_db.pdf",
fig_mmseqs2="figures/fig_mmseqs2.pdf",
fig_barrnap="figures/fig_barrnap.pdf",
fig_rgi=["figures/fig_rgi_counts.pdf", "figures/fig_rgi_overlap.pdf"],
fig_gdb_rgi_aro3004454_flye="figures/fig_gdb_rgi_aro3004454_flye.pdf"
rule fig_mappability:
...
...
@@ -145,6 +146,25 @@ rule fig_barrnap:
script:
os.path.join(SRC_DIR, "fig_barrnap.R")
rule fig_rgi:
input:
zymo=os.path.join(config["samples"]["zymo"], "annotation/rgi/summary.tsv"),
nwc=os.path.join(config["samples"]["nwc"], "annotation/rgi/summary.tsv"),
gdb=os.path.join(config["samples"]["gdb"], "annotation/rgi/summary.tsv"),
rumen=os.path.join(config["samples"]["rumen"], "annotation/rgi/summary.tsv")
output:
pdf_c="figures/fig_rgi_counts.pdf",
pdf_o="figures/fig_rgi_overlap.pdf"
log:
"figures/fig_rgi.log"
params:
const=os.path.join(SRC_DIR, "const.R"),
utils=os.path.join(SRC_DIR, "utils.R")
conda:
os.path.join(ENV_DIR, "r.yaml")
script:
os.path.join(SRC_DIR, "fig_rgi.R")
rule fig_mmseqs2:
input:
zymo=os.path.join(config["samples"]["zymo"], "analysis/mmseqs2/summary.tsv"),
...
...
workflow_figures/scripts/fig_rgi.R
0 → 100644
View file @
bb04dfe0
#!/usr/bin/Rscript
# Figure: QUAST statistics
############################## LOG
sink
(
file
=
file
(
snakemake
@
log
[[
1
]],
open
=
"wt"
),
type
=
c
(
"output"
,
"message"
))
############################## LIBS
suppressMessages
(
library
(
testit
))
# assertions
suppressMessages
(
library
(
dplyr
))
# tables
suppressMessages
(
library
(
patchwork
))
# combine plots
suppressMessages
(
library
(
ggplotify
))
# for as.ggplot
# custom
source
(
snakemake
@
params
$
const
)
source
(
snakemake
@
params
$
utils
)
############################## CONFIG
# assemblers
ASM_NAMES_CONFIG
<-
c
(
snakemake
@
config
$
assemblers
$
lr
,
snakemake
@
config
$
assemblers
$
sr
,
snakemake
@
config
$
assemblers
$
hy
)
ASM_TOOL_NAMES
<-
ASM_TOOL_NAMES
[
ASM_NAMES_CONFIG
]
ASM_TOOL_COLORS
<-
ASM_TOOL_COLORS
[
ASM_NAMES_CONFIG
];
names
(
ASM_TOOL_COLORS
)
<-
ASM_TOOL_NAMES
[
names
(
ASM_TOOL_COLORS
)]
ASM_TOOL_SHAPES
<-
ASM_TOOL_SHAPES
[
ASM_NAMES_CONFIG
];
names
(
ASM_TOOL_SHAPES
)
<-
ASM_TOOL_NAMES
[
names
(
ASM_TOOL_SHAPES
)]
############################## DATA
# individual tables
TABS
<-
list
()
for
(
sname
in
names
(
snakemake
@
config
$
samples
)){
testit
::
assert
(
sname
%in%
names
(
snakemake
@
input
))
TABS
[[
sname
]]
<-
read_rgi
(
snakemake
@
input
[[
sname
]])
}
############################## PLOT
# individual plots
FIGS_c
<-
list
()
FIGS_o
<-
list
()
for
(
sname
in
names
(
snakemake
@
config
$
samples
)){
if
(
nrow
(
TABS
[[
sname
]])
>
0
){
FIGS_c
[[
sname
]]
<-
plot_rgi_counts_total
(
proc_rgi
(
TABS
[[
sname
]])
$
aggr
)
+
labs
(
title
=
LETTERS
[
which
(
names
(
TABS
)
==
sname
)],
subtitle
=
SAMPLE_NAMES
[
sname
]
)
FIGS_o
[[
sname
]]
<-
as.ggplot
(
plot_rgi_overlap
(
TABS
[[
sname
]],
"strict"
,
"ARO"
))
+
labs
(
title
=
LETTERS
[
which
(
names
(
TABS
)
==
sname
)],
subtitle
=
SAMPLE_NAMES
[
sname
]
)
}
}
# combine plots
FIGS_ALL_c
<-
Reduce
(
"+"
,
FIGS_c
)
+
plot_layout
(
ncol
=
2
)
FIGS_ALL_o
<-
Reduce
(
"+"
,
FIGS_o
)
+
plot_layout
(
ncol
=
2
)
# PDF
pdf
(
snakemake
@
output
$
pdf_c
,
width
=
20
,
height
=
14
)
print
(
FIGS_ALL_c
)
dev.off
()
pdf
(
snakemake
@
output
$
pdf_o
,
width
=
20
,
height
=
14
)
print
(
FIGS_ALL_o
)
dev.off
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment