Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
- added tiff
- improved phopho/glyco titles
- capitalised first letter some legends
- removed some grids
- added common species names
  • Loading branch information
jeanmanguy committed Aug 26, 2019
1 parent 1f2e09d commit 73fabd8
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 107 deletions.
2 changes: 1 addition & 1 deletion config/global.dcf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ libraries: tidyverse, glue, farver,
XML, rvest, withr, patchwork,
ggtree, here, assertthat,
geoscale, magrittr, knitr,
kableExtra
kableExtra, ggtext
as_factors: FALSE
attach_internal_libraries: FALSE
cache_loaded_data: TRUE
Expand Down
78 changes: 48 additions & 30 deletions figures_and_tables_paper.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,24 @@ save_plot_jpg <- partial(
dpi = "retina",
units = "in"
)

save_plot_tiff <- partial(
ggsave,
path = plot_output_dir,
dpi = "retina",
units = "in"
)

save_plot <- function(plot, name, ...) {
suppressMessages(
save_plot_pdf(plot = plot, filename = glue("{name}.pdf"), ...)
)
suppressMessages(
save_plot_jpg(plot = plot, filename = glue("{name}.jpg"), ...)
)
suppressMessages(
save_plot_tiff(plot = plot, filename = glue("{name}.tiff"), ...)
)
invisible(plot)
}
save_table <- function(table, name, ...) {
Expand Down Expand Up @@ -869,7 +880,7 @@ plot_ncpr_change_mature <- kappa_caseins_ncpr %>%
axis.ticks = element_line(size = 0.2, colour = "black"),
legend.margin = margin(0, 0, 0, 200),
legend.text.align = 0,
legend.text = ggtext::element_markdown(size = 8),
legend.text = element_markdown(size = 8),
legend.key.size = unit(10, "pt"),
legend.box.spacing = unit(0.05, "line"),
) +
Expand Down Expand Up @@ -961,7 +972,8 @@ plot_phospho_counts <- df_phospho_glyco_counts %>%
legend.position = "bottom",
) +
labs(
x = "count of predicted phosphorylations",
title = "Phosphorylations",
x = "count of predicted sites",
fill = "Parts"
) +
NULL
Expand Down Expand Up @@ -991,7 +1003,8 @@ plot_glyco_counts <- df_phospho_glyco_counts %>%
axis.text.y = element_text(face = "italic", size = 6),
) +
labs(
x = "count of predicted O-glycosylations"
title = "O-glycosylations",
x = "count of predicted sites"
) +
NULL

Expand All @@ -1006,7 +1019,7 @@ plot_glyco_counts <- df_phospho_glyco_counts %>%
axis.title.y = element_blank(),
axis.text.x = element_text(size = 7),
axis.ticks = element_line(size = 0.1, lineend = "butt"),
plot.title = element_blank(),
plot.title = element_text(size = 9),
plot.subtitle = element_blank(),
axis.title.x = element_text(size = 8),
axis.title.x.top = element_blank(),
Expand Down Expand Up @@ -1056,9 +1069,9 @@ plot_kappa_casein_cysteines <- kappa_caseins_cysteines_positions_rel_cattle %>%
fill = group
)) +
geom_tile(mapping = aes(alpha = group)) +
geom_text(family = "Source Code Pro", size = 1.8) +
scale_fill_manual("amino acid", values = aa_custom_OkabeIto_colours) +
scale_alpha_manual("amino acid", values = c("cysteine" = 1, set_names(rep(0.6, 19), c("histidine", "aromatic", "glycine", "proline", "polar", "apolar", "charged +", "charged -")))) +
geom_text(family = "Source Code Pro", size = 1.9) +
scale_fill_manual("Amino acids", values = aa_custom_OkabeIto_colours) +
scale_alpha_manual("Amino acids", values = c("cysteine" = 1, set_names(rep(0.6, 19), c("histidine", "aromatic", "glycine", "proline", "polar", "apolar", "charged +", "charged -")))) +
theme_bw() +
theme(legend.position = "bottom") +
scale_x_continuous(
Expand All @@ -1070,7 +1083,7 @@ plot_kappa_casein_cysteines <- kappa_caseins_cysteines_positions_rel_cattle %>%
scale_y_discrete(
expand = c(0, 0)
) +
guides(fill = guide_legend(nrow = 9, ncol = 1)) +
guides(fill = guide_legend(nrow = 9, ncol = 1, override.aes = list(alpha = 1))) +
theme(
text = element_text(colour = "black", family = "Arial"),
axis.ticks.y = element_blank(),
Expand All @@ -1080,17 +1093,13 @@ plot_kappa_casein_cysteines <- kappa_caseins_cysteines_positions_rel_cattle %>%
legend.justification = c(0, 1),
legend.key.width = unit(0.25, "lines"),
legend.key.height = unit(0.25, "lines"),
legend.title = element_text(size = 6),
legend.text = element_text(size = 6),
legend.title = element_text(size = 7),
legend.text = element_text(size = 7),
legend.box.margin = margin(2, 2, 2, 2, unit = "pt"),
legend.margin = margin(2, 2, 2, 2, unit = "pt"),
legend.background = element_rect(fill = "transparent"),
legend.box.background = element_rect(
colour = "black",
fill = "white",
size = 0.1
),
legend.spacing = unit(0.5, "mm"),
legend.box.background = element_blank(),
legend.spacing = unit(0.7, "mm"),
axis.title.y = element_blank(),
axis.title.x = element_text(size = 7),
axis.text.x = element_text(size = 7),
Expand All @@ -1101,7 +1110,9 @@ plot_kappa_casein_cysteines <- kappa_caseins_cysteines_positions_rel_cattle %>%
panel.grid.major.y = element_line(size = 0.01)
) +
labs(
x = "Bovine mature kappa-casein residue position"
x = "Bovine mature kappa-casein residue position",
fill = "Amino acids",
colour = "Amino acids"
) +
NULL

Expand Down Expand Up @@ -1202,7 +1213,8 @@ plot_kappa_casein_pepsin <- plot_kappa_caseins_parts +
) +
labs(
title = "Pepsin",
colour = "Cleavage site"
colour = "Cleavage site",
fill = "Parts"
) +
scale_colour_manual(values = c("predicted position" = "black")) +
guides(fill = guide_legend(order = 1))
Expand Down Expand Up @@ -1304,7 +1316,9 @@ plot_msa <- kappa_caseins_alignment_positions %>%
axis.title.y.right = element_blank(),
plot.margin = margin(0, 0, 0, 0),
panel.spacing = margin(0, 0, 0, 0),
axis.text.y = element_text(face = "italic", size = 7, colour = "black")
axis.text.y = element_text(face = "italic", size = 7, colour = "black"),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank()
) +
NULL

Expand Down Expand Up @@ -1345,18 +1359,18 @@ save_plot(

```{r figureS3, fig.height=2.25, fig.width=6, cache=TRUE}
species_old_indels <- c(
"Homo_sapiens" = "human",
"Bos_taurus" = "cow",
"Tachyglossus_aculeatus" = "echidna",
"Ornithorhynchus_anatinus" = "platypus",
"Monodelphis_domestica" = "opossum",
"Trichosurus_vulpecula" = "possum"
"Human" = "Homo_sapiens",
"Cattle" = "Bos_taurus",
"Short-beaked echidna" = "Tachyglossus_aculeatus",
"Platypus" = "Ornithorhynchus_anatinus",
"Gray short-tailed opossum" = "Monodelphis_domestica",
"Common brushtail possum" = "Trichosurus_vulpecula"
)


# tree
tips_to_drop_old_indels <- trimmed_species_tree_as_df %>%
filter(isTip, !label %in% names(species_old_indels)) %>%
filter(isTip, !label %in% species_old_indels) %>%
pull(node)

tree_old_indels <- trimmed_species_tree %>%
Expand All @@ -1371,7 +1385,7 @@ plot_tree_old_indels <- tree_old_indels_df %>%

# "barplot"
aa_old_indels_df <- kappa_caseins_alignment_positions %>%
filter(species %in% names(species_old_indels)) %>%
filter(species %in% species_old_indels) %>%
arrange(msa_index) %>%
mutate(is_gap = residue == "-") %>% # remove positions with gaps in **all** selected species
group_by(msa_index) %>%
Expand All @@ -1397,7 +1411,7 @@ plot_bars_old_indels <- aa_old_indels_df %>%
axis.ticks = element_line(size = 0.2, colour = "black"),
axis.title.y = element_blank(),
axis.line.y = element_blank(),
axis.text.y = element_text(face = "italic", colour = "black"),
axis.text.y.right = element_markdown(colour = "black"),
axis.title.x = element_text(colour = "black"),
axis.text.x = element_text(colour = "black"),
plot.margin = margin(0, 0, 0, 0),
Expand All @@ -1415,7 +1429,11 @@ plot_bars_old_indels <- aa_old_indels_df %>%
breaks = c(1, seq(50, 300, 50), aa_old_indels_df_max_length),
minor_breaks = seq(0, 300, 25)
) +
scale_y_discrete(position = "right", labels = underscore_to_space) +
scale_y_discrete(
position = "right",
breaks = species_old_indels,
labels = glue("{names(species_old_indels)}<br>_{underscore_to_space(species_old_indels)}_")
) +
NULL


Expand Down Expand Up @@ -1604,7 +1622,7 @@ plot_kappa_casein_cysteines <- plot_kappa_caseins_parts +
legend.key.width = unit(0.5, "lines"),
axis.text.y = element_text(colour = "black", family = "Arial"),
) +
labs(colour = "Cysteines", fill = "Parts") +
labs(colour = "Cysteines", fill = "Parts", title = "Cysteines") +
NULL

(cysteines_position_plot <- {
Expand Down
165 changes: 101 additions & 64 deletions figures_and_tables_paper.html

Large diffs are not rendered by default.

28 changes: 16 additions & 12 deletions session_info.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
─ Session info ──────────────────────────────────────────────────────────────────────────────
setting value
version R version 3.6.1 (2019-07-05)
os Linux Mint 19.2
system x86_64, linux-gnu
ui X11
language en_IE:en
collate en_IE.UTF-8
ctype en_IE.UTF-8
tz Europe/Dublin
date 2019-08-23

─ Packages ──────────────────────────────────────────────────────────────────────────────────
package * version date lib source
Expand All @@ -9,20 +19,22 @@
askpass 1.1 2019-01-13 [1] CRAN (R 3.6.0)
assertthat * 0.2.1 2019-03-21 [1] CRAN (R 3.6.0)
backports 1.1.4 2019-04-10 [1] CRAN (R 3.6.0)
badger 0.0.4 2019-01-08 [1] CRAN (R 3.6.0)
base64enc 0.1-3 2015-07-28 [1] CRAN (R 3.6.0)
BiocGenerics 0.30.0 2019-05-02 [1] Bioconductor
Biostrings 2.52.0 2019-05-02 [1] Bioconductor
broom 0.5.2 2019-04-07 [1] CRAN (R 3.6.1)
callr 3.3.1 2019-07-18 [1] CRAN (R 3.6.1)
cellranger 1.1.0 2016-07-27 [1] CRAN (R 3.6.0)
checkmate 1.9.4 2019-07-04 [1] CRAN (R 3.6.1)
cleaver 1.22.0 2019-05-02 [1] Bioconductor
cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.1)
cluster 2.1.0 2019-06-19 [1] CRAN (R 3.6.1)
codetools 0.2-16 2018-12-24 [1] CRAN (R 3.6.0)
colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.0)
crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0)
data.table 1.12.2 2019-04-07 [1] CRAN (R 3.6.0)
digest 0.6.20 2019-07-04 [1] CRAN (R 3.6.1)
dlstats 0.1.0 2017-08-07 [1] CRAN (R 3.6.0)
dplyr * 0.8.3 2019-07-04 [1] CRAN (R 3.6.1)
ellipsis 0.2.0.1 2019-07-02 [1] CRAN (R 3.6.1)
evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0)
Expand All @@ -38,10 +50,12 @@
ggplot2 * 3.2.1 2019-08-10 [1] CRAN (R 3.6.1)
ggpmisc * 0.3.1 2019-04-02 [1] CRAN (R 3.6.1)
ggstance * 0.3.3 2019-08-19 [1] CRAN (R 3.6.1)
ggtext * 0.1.0 2019-08-13 [1] Github (clauswilke/ggtext@5c7cfa9)
ggthemes * 4.2.0 2019-05-13 [1] CRAN (R 3.6.0)
ggtree * 1.16.5 2019-08-14 [1] Bioconductor
glue * 1.3.1 2019-03-12 [1] CRAN (R 3.6.0)
gridExtra 2.3 2017-09-09 [1] CRAN (R 3.6.0)
gridtext 0.1.0 2019-08-13 [1] Github (clauswilke/gridtext@21b7198)
gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.0)
haven 2.1.1 2019-07-04 [1] CRAN (R 3.6.1)
here * 0.1 2017-05-28 [1] CRAN (R 3.6.0)
Expand All @@ -53,7 +67,6 @@
htmlwidgets 1.3 2018-09-30 [1] CRAN (R 3.6.0)
httr 1.4.1.9000 2019-08-14 [1] Github (r-lib/httr@d7195c2)
igraph 1.2.4.1 2019-04-22 [1] CRAN (R 3.6.0)
inline 0.3.15 2018-05-18 [1] CRAN (R 3.6.1)
IRanges 2.18.1 2019-05-31 [1] Bioconductor
jsonlite 1.6 2018-12-07 [1] CRAN (R 3.6.0)
kableExtra * 1.1.0 2019-03-16 [1] CRAN (R 3.6.0)
Expand All @@ -63,31 +76,25 @@
lattice * 0.20-38 2018-11-04 [1] CRAN (R 3.6.0)
latticeExtra 0.6-28 2016-02-09 [1] CRAN (R 3.6.0)
lazyeval 0.2.2 2019-03-15 [1] CRAN (R 3.6.0)
loo 2.1.0 2019-03-13 [1] CRAN (R 3.6.1)
lubridate 1.7.4 2018-04-11 [1] CRAN (R 3.6.0)
magrittr * 1.5 2014-11-22 [1] CRAN (R 3.6.0)
markdown 1.1 2019-08-07 [1] CRAN (R 3.6.1)
MASS 7.3-51.4 2019-04-26 [1] CRAN (R 3.6.0)
Matrix 1.2-17 2019-03-22 [1] CRAN (R 3.6.0)
matrixStats 0.54.0 2018-07-23 [1] CRAN (R 3.6.0)
modelr 0.1.5 2019-08-08 [1] CRAN (R 3.6.1)
munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.0)
nlme 3.1-141 2019-08-01 [1] CRAN (R 3.6.1)
nnet 7.3-12 2016-02-02 [1] CRAN (R 3.6.0)
openssl 1.4.1 2019-07-18 [1] CRAN (R 3.6.1)
packrat 0.5.0-16 2019-06-26 [1] Github (rstudio/packrat@d7ad4c2)
patchwork * 0.0.1 2019-07-31 [1] Github (thomasp85/patchwork@fd7958b)
Peptides * 2.4.1 2019-08-20 [1] CRAN (R 3.6.1)
phangorn 2.5.5 2019-06-19 [1] CRAN (R 3.6.1)
phylogram 2.1.0 2018-06-25 [1] CRAN (R 3.6.0)
pillar 1.4.2 2019-06-29 [1] CRAN (R 3.6.1)
pkgbuild 1.0.4 2019-08-05 [1] CRAN (R 3.6.1)
pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.6.0)
plyr 1.8.4 2016-06-08 [1] CRAN (R 3.6.0)
polyclip 1.10-0 2019-03-14 [1] CRAN (R 3.6.0)
prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.6.0)
processx 3.4.1 2019-07-18 [1] CRAN (R 3.6.1)
ProjectTemplate * 0.9.0 2019-02-26 [1] CRAN (R 3.6.1)
ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.0)
purrr * 0.3.2 2019-03-15 [1] CRAN (R 3.6.0)
quadprog 1.5-7 2019-05-06 [1] CRAN (R 3.6.1)
R6 2.4.0 2019-02-14 [1] CRAN (R 3.6.0)
Expand All @@ -99,16 +106,13 @@
rmarkdown 1.14 2019-07-12 [1] CRAN (R 3.6.1)
rpart 4.1-15 2019-04-12 [1] CRAN (R 3.6.0)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.0)
rsconnect 0.8.15 2019-07-22 [1] CRAN (R 3.6.1)
rstan 2.19.2 2019-07-09 [1] CRAN (R 3.6.1)
rstudioapi 0.10 2019-03-19 [1] CRAN (R 3.6.0)
rvcheck 0.1.3 2018-12-06 [1] CRAN (R 3.6.0)
rvest * 0.3.4 2019-05-15 [1] CRAN (R 3.6.0)
S4Vectors 0.22.0 2019-05-02 [1] Bioconductor
scales 1.0.0 2018-08-09 [1] CRAN (R 3.6.0)
seqinr 3.4-5 2017-08-01 [1] CRAN (R 3.6.0)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0)
StanHeaders 2.18.1-10 2019-06-14 [1] CRAN (R 3.6.1)
stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0)
stringr * 1.4.0 2019-02-10 [1] CRAN (R 3.6.0)
survival * 2.44-1.1 2019-04-01 [1] CRAN (R 3.6.0)
Expand Down

0 comments on commit 73fabd8

Please sign in to comment.