R/meltCurves.R

Defines functions meltCurves plotMeltCurves

#' @export
plotMeltCurves <- function(temps, effs) {
  plot(
    temps, effs[,1], ylim=c(0,1),
    ylab="Hybridization Efficiency",
    xlab=expression(paste("Temperature (", degree, "C)", sep="")),
    type="l", lwd=2, col="Blue", main="Denaturation Plot"
  )
  lines(temps, effs[,2], col="Red", lwd=2)
  abline(h=0.5, lty=2, lwd=2, col="Orange")
  abline(v=64, lty=2, lwd=2, col="Green")
  legend(
    "topright",
    legend = c(
      "Forward Primer",
      "Reverse Primer",
      "50% Efficiency",
      "Annealing Temperature"
    ),
    col = c("Blue", "Red", "Orange", "Green"),
    lwd = c(2, 2, 2, 2), lty = c(1, 1, 2, 2)
  )
}

#' @param primers A vector of the forward and reverse DNA oligos to pass to `DECIPHER::CalculateEfficiencyPCR` e.g. `c("CGTTGA", "CCCTCG")`.
#' @param target A vector of the target DNA oligos to pass to `DECIPHER::CalculateEfficiencyPCR`.
#' @param target A vector reprsenting the temp range over which to calculate melting curves.
#' @export
meltCurves <- function(primers, target=reverseComplement(DNAStringSet(primers)), temps=60:75, P=4e-7, ions=.225, doPlot=TRUE, ...) {
    fxn <- function(temp) CalculateEfficiencyPCR(primers, target, temp, P=P, ions=ions, ...)
    effs <- matrix(unlist(lapply(temps, fxn)), ncol=2, byrow=TRUE)
    if (doPlot) plotMeltCurves(temps, effs)
    list(temps = temps, effs = effs)
  }
Chebuu/Design-Group-Specific-Primers documentation built on Aug. 17, 2020, 1:29 a.m.