library(knitr)
# allows figure sizing within r chunck # modified from http://michaeljw.com/blog/post/subchunkify/ subchunkify <- function(g, cap=NULL, fig_height=7, fig_width=5) { #g argument is the object to plot #cap is the figure caption g_deparsed <- paste0(deparse( #deparse turns function() {g} into string that Knitr can interpret function() {g} ), collapse = '') sub_chunk <- paste0(" `","``{r sub_chunk_", floor(runif(1) * 10000), #give the generated sub-chunk a unique name ", fig.height=", fig_height, ", fig.width=", fig_width, ", fig.cap=", cap, ", echo=FALSE, message=FALSE, warning=FALSE, fig.align='center', dpi = 600}", "\n(", g_deparsed , ")()", "\n`","`` ") #knitr::knit() compiles the generated sub-chunk cat(knitr::knit(text = knitr::knit_expand(text = sub_chunk), quiet = TRUE)) }
#Extract the selected oligonucleotides names to print as a comma separated string if (length(selected.oligos.db()) > 1) { #if more than one oligo, then use plural selected.oligos <- paste("oligonucleotides", paste(selected.oligos.db()[1:length(selected.oligos.db())-1], collapse=", "), "and", selected.oligos.db()[length(selected.oligos.db())]) } else { #else use singular selected.oligos <- paste("oligonucleotide", paste(selected.oligos.db(), collapse=", ")) }
This report was generated by g4dbr for the r selected.oligos
on r Sys.Date()
.
#Document title takes selected oligonucleotides values title_var <- paste(paste(selected.oligos.db(), collapse="/"), "report")
title: r title_var
author: g4dbr
date: r Sys.Date()
output:
word_document:
reference_docx: word-styles-reference.docx
#table of oligonucleotides properties (pageable) db.info <- db.info() %>% filter(oligo %in% selected.oligos.db()) %>% #only display selected oligos data select(c('oligo', 'sequence', 'submitted_by', 'depo.date', 'DOI')) knitr::kable(db.info, caption = 'General oligonucleotide information', escape = F) #DOI parsed in HTML reports
if (length(selected.oligos.db()) > 1) { subchunkify(g = p.CD.db() + theme(legend.position = 'bottom', legend.text = element_text(size = 8), legend.title = element_text(size = 9)), #plot cap = "paste('Circular dichroism spectra of', paste('the', paste(selected.oligos.db()[1:length(selected.oligos.db())-1], collapse=', '), 'and', selected.oligos.db()[length(selected.oligos.db())]), 'oligonucleotides')", #figure caption fig_height = 3 * row.p.CD.db(), #dynamic figure height fig_width = 6.26 ) } else { #Extraction of the oligo concentration conc.cd <- db.cd.select() %>% group_by(oligo) %>% filter(oligo == selected.oligos.db()) %>% ungroup() %>% select(con) %>% unique() %>% as.numeric() #Extraction of the path length path.cd <- db.cd.select() %>% group_by(oligo) %>% filter(oligo == selected.oligos.db()) %>% ungroup() %>% select(l) %>% unique() %>% as.numeric() subchunkify(g = p.CD.db()+ guides(shape = FALSE) + theme(legend.position = 'bottom', legend.text = element_text(size = 8), legend.title = element_text(size = 9)), cap = "paste0('Circular dichroism spectra of', paste(' the', paste(selected.oligos.db(), collapse=', ', 'oligonucleotide')), ' (', conc.cd, ' μM)', ', acquired at 25°C in ', path.cd, '-cm path length cuvettes')", fig_height = 3 * row.p.CD.db(), #dynamic figure height fig_width = (8*col.p.CD.db())/(col.p.CD.db()+0.5) #dynamic figure width ) }
if (length(selected.oligos.db()) > 1) { subchunkify(g = p.NMR.db() + theme(legend.position = 'bottom', legend.text = element_text(size = 8), legend.title = element_text(size = 9)), #plot cap = "paste('1H-NMR spectra of the', paste(selected.oligos.db()[1:(length(selected.oligos.db())-1)], collapse = ', '), 'and', selected.oligos.db()[length(selected.oligos.db())], 'oligonucleotides, acquired at 25°C')", #figure caption fig_height = 4 * row.p.NMR.db(), #dynamic figure height fig_width = (9*col.p.NMR.db())/(col.p.NMR.db()+0.4) #dynamic figure width ) } else { subchunkify(g = p.NMR.db()+ theme(legend.position = 'none'), cap = "paste('1H-NMR spectrum of', paste('the', paste(selected.oligos.db(), collapse=', ', 'oligonucleotide,')), 'acquired at 25°C')", fig_height = 4 * row.p.NMR.db(), #dynamic figure height fig_width = (9*col.p.NMR.db())/(col.p.NMR.db()+0.4) #dynamic figure width ) }
puf <- p.UV.fit.db() + # guides(colour=guide_legend(nrow=length(selected.oligos.db()))) + theme( legend.text = element_text(size = 8), legend.title = element_text(size = 9), legend.direction = 'vertical') if (length(selected.oligos.db()) > 1) { subchunkify(g = puf, #plot cap = "paste('Raw UV-melting plots of', paste('the', paste(selected.oligos.db()[1:length(selected.oligos.db())-1], collapse=', '), 'and', selected.oligos.db()[length(selected.oligos.db())]), 'oligonucleotides', 'acquired at 295 nm')", #figure caption fig_height = 4, fig_width = 6.26 ) } else { subchunkify(g = puf, cap = "paste('Raw UV-melting plots of', paste('the', paste(selected.oligos.db(), collapse=', ', 'oligonucleotide')), 'aquired at 295 nm')", fig_height = 4, fig_width = 6.26 ) }
puv <- p.UV.melting.db() + # guides(colour=guide_legend(nrow=length(selected.oligos.db()))) + theme( legend.text = element_text(size = 8), legend.title = element_text(size = 9), legend.direction = 'vertical') if (length(selected.oligos.db()) > 1) { subchunkify(g = puv, #plot cap = "paste('Folded fraction from UV-melting experiments at 295 nm of', paste('the', paste(selected.oligos.db()[1:length(selected.oligos.db())-1], collapse=', '), 'and', selected.oligos.db()[length(selected.oligos.db())]), 'oligonucleotides')", #figure caption fig_height = 4, fig_width = 6.26 ) } else { subchunkify(g = puv, cap = "paste('Folded fraction from UV-melting experiments at 295 nm of', paste('the', paste(selected.oligos.db(), collapse=', ', 'oligonucleotide')))", fig_height = 4, fig_width = 6.26 ) }
#controls whether MS section is knitted or not based on the use of the plotMS button if(input$plotMS.db == 0) { print.option <- FALSE } else { print.option <- TRUE }
#conditional MS section title asis_output("## Native ESI-MS")
pms <- p.MS.db() + theme(legend.position="bottom", legend.direction = 'horizontal', legend.text = element_text(size = 8), legend.title = element_text(size = 9)) if (length(selected.oligos.db()) > 1) { subchunkify(g = pms, #plot cap = "paste('Native ESI-MS spectra of', paste('the', paste(selected.oligos.db()[1:length(selected.oligos.db())-1], collapse=', '), 'and', selected.oligos.db()[length(selected.oligos.db())]), 'oligonucleotides')", #figure caption fig_height = 3 * row.p.MS.db(), #dynamic figure heights fig_width = (9*col.p.MS.db())/(col.p.MS.db()+0.4) #dynamic figure width ) } else { subchunkify(g = pms, cap = "paste('Native ESI-MS spectra of', paste('the', paste(selected.oligos.db(), collapse=', ', 'oligonucleotide')))", fig_height = 3 * row.p.MS.db(), #dynamic figure height fig_width = (9*col.p.MS.db())/(col.p.MS.db()+0.4) #dynamic figure width ) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.