Skip to content
Snippets Groups Projects

Figures valentina

Merged Susheel Busi requested to merge figures_valentina into master
+ 37
17
@@ -11,6 +11,7 @@ suppressMessages(library(testit))
suppressMessages(library(UpSetR))
suppressMessages(library(ggplot2))
suppressMessages(library(reshape2))
suppressMessages(library(UpSetR))
# custom
source(snakemake@params$utils)
@@ -22,12 +23,14 @@ stats <- read.csv(
stringsAsFactors=FALSE,
check.names=FALSE
)
# change names
colnames(stats) <- sapply(colnames(stats), function(x){ ifelse(x %in% names(ASM_TOOL_NAMES), ASM_TOOL_NAMES[x], x) })
# reshape
stats_melted <- reshape2::melt(stats, id.vars=c("label", "col", "type"), variable.name="tool", value.name="count")
# change names
stats_melted$tool <- ASM_TOOL_NAMES[as.character(stats_melted$tool)]
# stats_melted$tool <- ASM_TOOL_NAMES[as.character(stats_melted$tool)]
## PLOT
## PLOT: counts
my_theme <-
theme_bw() +
theme(
@@ -60,20 +63,6 @@ for(ctype in unique(stats_melted$type)){
) +
my_theme
}
# Total counts
# df <- stats_melted[stats_melted$type == ctype,]
# df <- aggregate(df$count, by=list(tool=df$tool), FUN=sum)
# plots[[sprintf("%s_%s", ctype, "total")]] <-
# ggplot(data=df, aes(x=tool, y=x, fill=tool)) +
# geom_col() +
# scale_fill_manual(values=ASM_TOOL_COLORS$notmeth, guide=NULL) +
# labs(
# # title="",
# subtitle=sprintf("Hits: %s", ctype),
# x="",
# y="Total hits"
# ) +
# my_theme
}
# Total counts
df <- stats_melted[stats_melted$col == "ARO",]
@@ -89,7 +78,38 @@ plots[[sprintf("%s_%s", ctype, "total")]] <-
) +
my_theme
## PDF
## PLOT: intersection & PDF
plot_overlap <- function(df, ctype, col){
df <- df[df$type == ctype & df$col == col,]
df_list <- lapply(ASM_TOOL_NAMES_NOTMETH, function(x){ df[df[,x] > 0,"label"] })
names(df_list) <- ASM_TOOL_NAMES_NOTMETH[names(df_list)]
UpSetR::upset(
data=UpSetR::fromList(df_list),
# overlap order
order.by="degree",
decreasing=FALSE,
# y-label title
mainbar.y.label=sprintf("Intersection size (%s hits, %s)", ctype, RGI_NAMES$col[col]),
# text size
text.scale = c(2, 2, 1.5, 1.5, 2, 2),
# colors
set.metadata=list(
data=data.frame(
sets=names(df_list),
Tool=names(df_list),
stringsAsFactors=FALSE
),
plots=list(list(type="matrix_rows", column="Tool", colors=ASM_TOOL_COLORS$notmeth, alpha=0.7))
)
)
}
pdf(snakemake@output$pdf, width=snakemake@params$width, height=snakemake@params$height)
# Count plots
for(pp in plots){ print(pp) }
# Intersection plot
plot_overlap(stats, "all", "ARO")
plot_overlap(stats, "nudged", "ARO")
plot_overlap(stats, "strict", "ARO")
dev.off()
Loading