Commit 590f85ba authored by Valentina Galata's avatar Valentina Galata
Browse files

figures: added mappability fig

parent 63a86656
......@@ -26,9 +26,30 @@ workdir:
rule all:
input:
fig_mappability=["figures/fig_mappability.pdf","figures/fig_mappability_gdb_metat.pdf"],
fig_quast="figures/fig_quast.pdf",
fig_gdb_rgi_aro3004454_flye="figures/fig_gdb_rgi_aro3004454_flye.pdf"
rule fig_mappability:
input:
zymo=os.path.join(config["samples"]["zymo"], "mapping/metag/mappability.tsv"),
nwc=os.path.join(config["samples"]["nwc"], "mapping/metag/mappability.tsv"),
gdb=os.path.join(config["samples"]["gdb"], "mapping/metag/mappability.tsv"),
rumen=os.path.join(config["samples"]["rumen"], "mapping/metag/mappability.tsv"),
gdb_metat=os.path.join(config["samples"]["gdb"], "mapping/metat/mappability.tsv")
output:
pdf="figures/fig_mappability.pdf",
pdf_gdb_metat="figures/fig_mappability_gdb_metat.pdf"
log:
"figures/fig_mappability.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_mappability.R")
rule fig_quast:
input:
zymo=os.path.join(config["samples"]["zymo"], "analysis/quast/summary_report.tsv"),
......
#!/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 c(names(snakemake@config$samples), "gdb_metat")){
testit::assert(sname %in% names(snakemake@input))
TABS[[sname]] <- read_mappability(snakemake@input[[sname]])
}
############################## PLOT
# individual plots
FIGS <- list()
for(sname in names(snakemake@config$samples)){
FIGS[[sname]] <-
TABS[[sname]] %>%
filter(variable=="mapped_pct") %>%
plot_mappability() +
labs(
title=LETTERS[which(names(TABS) == sname)],
subtitle=SAMPLE_NAMES[sname]
)
}
# combine plots
FIGS_ALL <- Reduce("+", FIGS) + plot_layout(ncol=2)
# extra plot
FIGS_gdb_metat <- TABS[["gdb_metat"]] %>% filter(variable=="mapped_pct") %>% plot_mappability()
# PDF
pdf(snakemake@output$pdf, width=20, height=14)
print(FIGS_ALL)
dev.off()
pdf(snakemake@output$pdf_gdb_metat, width=10, height=7)
print(FIGS_gdb_metat)
dev.off()
\ No newline at end of file
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