Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
ESB
ONT_pilot_gitlab
Commits
6eb4eac9
Commit
6eb4eac9
authored
Apr 23, 2021
by
Valentina Galata
Browse files
figures: fix for mmseqs2 upsetr plots using cowplot (issue
#127
)
parent
2c899e7f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
33 deletions
+35
-33
workflow_figures/scripts/fig_mmseqs2.R
workflow_figures/scripts/fig_mmseqs2.R
+31
-30
workflow_report/envs/r.yaml
workflow_report/envs/r.yaml
+2
-1
workflow_report/scripts/utils.R
workflow_report/scripts/utils.R
+2
-2
No files found.
workflow_figures/scripts/fig_mmseqs2.R
View file @
6eb4eac9
...
...
@@ -8,10 +8,11 @@ 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
# suppressMessages(library(grid)) # to combine upsetr plots
# suppressMessages(library(gridExtra)) # to combine upsetr plots
# suppressMessages(library(patchwork)) # combine plots
# suppressMessages(library(ggplotify)) # for as.ggplot
suppressMessages
(
library
(
grid
))
# to combine upsetr plots
suppressMessages
(
library
(
gridExtra
))
# to combine upsetr plots
suppressMessages
(
library
(
cowplot
))
# custom
source
(
snakemake
@
params
$
const
)
...
...
@@ -40,36 +41,36 @@ for(sname in names(snakemake@config$samples)){
############################## PLOT
# individual plots
FIGS
<-
list
()
for
(
sname
in
names
(
snakemake
@
config
$
samples
)){
FIGS
[[
sname
]]
<-
as.ggplot
(
plot_mmseqs2_overlap
(
TABS
[[
sname
]]))
+
labs
(
title
=
SAMPLE_NAMES
[
sname
])
+
theme
(
plot.title
=
element_text
(
size
=
16
,
face
=
"bold"
))
}
# combine plots
FIGS_ALL
<-
Reduce
(
"+"
,
FIGS
)
+
plot_layout
(
ncol
=
2
)
#+ plot_annotation(tag_levels='A')
# PDF
pdf
(
snakemake
@
output
$
pdf
,
width
=
20
,
height
=
12
)
print
(
FIGS_ALL
)
dev.off
()
# # individual plots
# # solution for how to combine upsetR plots: https://stackoverflow.com/questions/57457651/upsetr-manually-order-set-intersections-to-align-multiple-upset-plots
# FIGS <- list()
# for(sname in names(snakemake@config$samples)){
# FIGS[[sname]] <- plot_mmseqs2_overlap(TABS[[sname]])
# print(FIGS[[sname]])
# grid.text(SAMPLE_NAMES[sname], x=0.05, y=0.95, gp=gpar(fontsize=16, fontface="bold"))
# grid.edit('arrange', name=sname)
# vp <- grid.grab()
# FIGS[[sname]] <- vp
# FIGS[[sname]] <-
# as.ggplot(plot_mmseqs2_overlap(TABS[[sname]])) +
# labs(title=SAMPLE_NAMES[sname]) +
# theme(plot.title=element_text(size=16, face="bold"))
# }
# # combine plots
# FIGS_ALL <- Reduce("+", FIGS) + plot_layout(ncol=2) #+ plot_annotation(tag_levels='A')
# # PDF
# pdf(snakemake@output$pdf, width=20, height=12)
# grid.arrange(grobs = FIGS, nrow=2)
# dev.off()
\ No newline at end of file
# print(FIGS_ALL)
# dev.off()
# individual plots
FIGS
<-
list
()
for
(
sname
in
names
(
snakemake
@
config
$
samples
)){
FIGS
[[
sname
]]
<-
plot_mmseqs2_overlap
(
TABS
[[
sname
]])
# NOTE: the barplot w/ set sizes is not meaningful, therefore plot only the intersection sizes and the matrix
FIGS
[[
sname
]]
<-
cowplot
::
plot_grid
(
FIGS
[[
sname
]]
$
Main_bar
,
FIGS
[[
sname
]]
$
Matrix
,
nrow
=
2
,
align
=
'hv'
,
rel_heights
=
c
(
3
,
1
),
rel_widths
=
c
(
2
,
3
),
labels
=
SAMPLE_NAMES
[
sname
],
label_fontface
=
"bold"
)
}
# PDF
pdf
(
snakemake
@
output
$
pdf
,
width
=
20
,
height
=
12
)
grid.arrange
(
grobs
=
FIGS
,
nrow
=
2
)
dev.off
()
\ No newline at end of file
workflow_report/envs/r.yaml
View file @
6eb4eac9
...
...
@@ -19,4 +19,5 @@ dependencies:
-
r-upsetr=1.4.0
-
r-viridis=0.5.1
-
r-patchwork=1.1.1
-
r-ggplotify=0.0.5
\ No newline at end of file
-
r-ggplotify=0.0.5
-
r-cowplot
\ No newline at end of file
workflow_report/scripts/utils.R
View file @
6eb4eac9
...
...
@@ -656,9 +656,9 @@ plot_mmseqs2_overlap <- function(df, topN=20){
decreasing
=
TRUE
,
# titles
mainbar.y.label
=
"Total number of proteins\nin clusters"
,
sets.x.label
=
"
Total number of proteins\nper assembly
"
,
sets.x.label
=
"
Ignore this statistic:\nit is not meaningful
"
,
# text size: intersection size title, intersection size tick labels, set size title, set size tick labels, set names, numbers above bars
text.scale
=
c
(
2
,
1.6
,
1.8
,
1.3
,
2
,
1
),
text.scale
=
c
(
2
,
2
,
1.8
,
1.3
,
2
,
1
.3
),
# ratio between matrix plot and main bar plot
mb.ratio
=
c
(
0.6
,
0.4
),
# highlight those w/ only one set
...
...
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