for (i in seq_along(params$primers)) {
    primer.df <- params$primers[[i]]
    template.df <- params$templates[[i]]
    id <- primer.df$Run[1]
    caption <-  paste0("Overview of the *", id, "* primer set.")
    out.df <- openPrimeR:::view.primers.report(primer.df, template.df)
    tab <- knitr::kable(out.df, row.names = FALSE, caption = caption,
                escape = TRUE, longtable = FALSE)
    print(tab)
    # pandoc doesn't support multi-column/row tables
    #row.idx <- which(colnames(out.df) == "Mismatches")
    #if (length(row.idx) != 0) {
        #tab <- kableExtra::add_header_above(tab, c("" = 1, "aa" = 2)
        #c("Mismatches" = row.idx[1], "" = tail(row.idx, n = 1)+1))
    #}
}

Primer Set Summary

#summary(cars)
tab <- openPrimeR:::get_comparison_table(params$templates, params$primers, params$sample)
caption <- paste0("Summary of the primer sets. Brackets indicate inter-quartile ranges.")
# show fewer columns to remain in the boundary of the page, don't show template (2nd column)
#knitr::kable(tab[,c(1,seq(3,5))], row.names = FALSE, caption = caption,
             #escape = TRUE, longtable = FALSE)
# use pander to split up the table instead:
pander::pander(tab[,c(1,seq(3,ncol(tab)))], caption = caption,
                split.table = 120, style = 'rmarkdown')

#########
# this is how a long table works (still too long ..)
#cat(paste0(
#"\\begin{table}[ht]\\centering\\rotatebox{90}{",
    #paste0(capture.output(
      #print(xtable(tab), floating=FALSE, comment=FALSE)),
      #collapse="\n"),
    #"}\\caption{Landscape table.}\\end{table}"))
############

Coverage

cvg.stats <- openPrimeR::get_cvg_stats(params$primers, params$templates, for.viewing = TRUE)
knitr::kable(cvg.stats, row.names = FALSE, caption = "Percentage of covered template sequences per primer set and group of template sequences.", longtable = TRUE)
openPrimeR:::plot_template_cvg(params$primers, params$templates)
idx <- which(sapply(params$direction, function(x) x %in% c("fw", "both")))
if (length(idx) != 0) {
    openPrimeR::plot_primer_binding_regions(params$primers[idx], 
                params$templates[idx], relation = "fw")
}
idx <- which(sapply(params$direction, function(x) x %in% c("rev", "both")))
if (length(idx) != 0) {
    openPrimeR::plot_primer_binding_regions(params$primers[idx], 
                    params$templates[idx], relation = "rev")
}
openPrimeR::plot_cvg_vs_set_size(params$primers, params$templates)

Physicochemical properties

# not enough space for p-vals
#openPrimeR::plot_constraint_signature(params$primers, params$templates,  # TODO: does not work in package yet.
openPrimeR::plot_constraint_fulfillment(params$primers,
                                params$settings, 
                                plot.p.vals = FALSE) 
constraints <- c("primer_coverage", "primer_efficiency", "primer_specificity")
constraints <- constraints[constraints %in% names(openPrimeR::constraints(params$settings))]
openPrimeR::plot_constraint(params$primers, params$settings,
    active.constraints = c("primer_coverage", "primer_efficiency", 
                    "primer_specificity"))
constraints <- c("self_dimerization", "cross_dimerization", "secondary_structure")
constraints <- constraints[constraints %in% names(openPrimeR::constraints(params$settings))]
openPrimeR::plot_constraint(params$primers, params$settings,
      active.constraints = constraints)
constraints <- c("primer_length", "no_runs",
                "no_repeats", "gc_ratio", 
                "gc_clamp", "melting_temp_range")
constraints <- constraints[constraints %in% names(openPrimeR::constraints(params$settings))]
openPrimeR::plot_constraint(params$primers, params$settings, 
    active.constraints = constraints)

# reset theme to default setting
ggplot2::theme_set(old.theme)


matdoering/openPrimeR documentation built on Feb. 11, 2024, 9:22 p.m.