Commit 8fcc05ef authored by Valentina Galata's avatar Valentina Galata
Browse files

figures: added prodigal gene count fig

parent f42ccc86
......@@ -29,6 +29,7 @@ rule all:
fig_mappability=["figures/fig_mappability.pdf","figures/fig_mappability_gdb_metat.pdf"],
fig_quast="figures/fig_quast.pdf",
fig_mash="figures/fig_mash.pdf",
fig_prodigal="figures/fig_prodigal.pdf",
fig_gdb_rgi_aro3004454_flye="figures/fig_gdb_rgi_aro3004454_flye.pdf"
rule fig_mappability:
......@@ -87,6 +88,24 @@ rule fig_mash:
script:
os.path.join(SRC_DIR, "fig_mash.R")
rule fig_prodigal:
input:
zymo=os.path.join(config["samples"]["zymo"], "annotation/prodigal/summary.gene.counts.tsv"),
nwc=os.path.join(config["samples"]["nwc"], "annotation/prodigal/summary.gene.counts.tsv"),
gdb=os.path.join(config["samples"]["gdb"], "annotation/prodigal/summary.gene.counts.tsv"),
rumen=os.path.join(config["samples"]["rumen"], "annotation/prodigal/summary.gene.counts.tsv")
output:
pdf="figures/fig_prodigal.pdf"
log:
"figures/fig_prodigal.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_prodigal.R")
rule fig_gdb_rgi_aro3004454_flye_metaT:
input:
os.path.join(config["samples"]["gdb"], "mapping/metat/lr/flye/ASSEMBLY.POLISHED.sr.cov.perbase")
......
#!/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
# 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_prodigal_gcounts(snakemake@input[[sname]])
}
############################## PLOT
# individual plots
FIGS <- list()
for(sname in names(snakemake@config$samples)){
FIGS[[sname]] <- plot_prodigal2(TABS[[sname]]) +
labs(
title=LETTERS[which(names(TABS) == sname)],
subtitle=SAMPLE_NAMES[sname]
)
}
# combine plots
FIGS_ALL <- Reduce("+", FIGS) + plot_layout(ncol=2)
# PDF
pdf(snakemake@output$pdf, width=20, height=14)
print(FIGS_ALL)
dev.off()
\ No newline at end of file
......@@ -412,6 +412,23 @@ plot_prodigal <- function(df_gc, df_gl){
))
}
plot_prodigal2 <- function(df_gc){
df_gcm <- reshape2::melt(df_gc[,c("tool", "total", "partial")], id.vars=c("tool"))
df_gcm <- set_tool_order(df_gcm, c("tool"))
pp <-
ggplot(data=df_gcm, aes(x=tool, y=value, fill=tool)) +
geom_col(position="dodge") +
scale_fill_manual(values=ASM_TOOL_COLORS, guide=NULL) +
facet_wrap(vars(variable), ncol=2, scales="fixed") +
labs(
x="",
y="Gene count"
) +
quast_theme
return(pp)
}
plot_barrnap <- function(df){
df <- set_tool_order(df, c("tool"))
pp <-
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment