Skip to content
Snippets Groups Projects

Figures valentina

Merged Susheel Busi requested to merge figures_valentina into master
1 file
+ 8
0
Compare changes
  • Side-by-side
  • Inline
+ 64
0
#!/usr/bin/Rscript
## LOG FILE
sink(file=file(snakemake@log[[1]], open="wt"), type="message")
## NOTE
# Plot protein/gene counts
## IMPORT
suppressMessages(library(testit))
suppressMessages(library(ggplot2))
suppressMessages(library(reshape2))
# custom
source(snakemake@params$utils)
## DATA
counts <- read.csv(
file=snakemake@input$counts,
sep="\t",
header=TRUE,
stringsAsFactors=FALSE,
check.names=FALSE
)
# change tool names
counts$tool <- GENE_TOOL_NAMES[counts$tool]
colnames(counts) <- sapply(colnames(counts), function(x){ ifelse(x %in% names(ASM_TOOL_NAMES), ASM_TOOL_NAMES[x], x) })
# reshape
counts_melted <- reshape2::melt(counts, id.vars="tool")
# Gene tool name - as ordered factor
counts_melted$tool <- factor(counts_melted$tool, levels=GENE_TOOL_NAMES, ordered=TRUE)
# Gene tool name - short version
counts_melted$tool_name <- sapply(as.character(counts_melted$tool), function(x){ unlist(strsplit(x, " "))[1] })
## PLOT
counts_p <-
ggplot(data=counts_melted, aes(x=tool, y=value, fill=variable)) +
geom_col(position = "dodge") +
scale_fill_manual(values=ASM_TOOL_COLORS$notmeth, guide="legend") +
facet_wrap(vars(tool_name), nrow=1, scales="free_x") +
labs(
# title="",
# subtitle="",
x="",
y="Number of proteins/genes"
) +
theme_bw() +
theme(
# legend
legend.title=element_blank(),
# grid
panel.grid=element_blank(),
# strip
strip.background=element_rect(fill="white"),
strip.text=element_text(size=12, color="black"),
# axes
axis.title=element_text(size=12, color="black"),
axis.text.y=element_text(size=9, color="black"),
axis.text.x=element_text(size=9, color="black", angle=90, vjust=0.5, hjust=1)
)
## PDF
pdf(snakemake@output$pdf, width=snakemake@params$width, height=snakemake@params$height)
print(counts_p)
dev.off()
Loading