R/hello.R

Defines functions BradfordAssay

Documented in BradfordAssay

#' Data Analysis for Bradford Assay
#' @export
BradfordAssay <- function(){
  #These lines  creates a plot with our standard data with a line of best fit which will be useful for printouts
  plot(STANDARD$concentration, STANDARD$absorbance,
       main = "Protein Concentration vs. Absorbance (750 nm)",
       xlab = "Protein Concentration (mg/ml)",
       ylab = "Absorbance (750 nm")
  abline(lm(STANDARD$absorbance ~ STANDARD$concentration), col = "red")

  #This line takes the values from our line of best fit and adds them to an object which will will access in a later function
  bestfit <- lm(formula = STANDARD$absorbance ~ STANDARD$concentration)

  #These lines create a function which can be used to predict protein concentrations based on absorbance values
  predictconcentration <- function(absorbance) {
     concentration <- ((absorbance - bestfit$coefficients[[1]])/bestfit$coefficients[[2]])
     return(concentration)
    }

  #This line runs our unknown values through the function we previously created and adds them to a list
  UNKNOWNCONCENTRATION <- c(predictconcentration(UNKNOWNS$absorbance))

  #These lines give us a graph of our known absorbance values and predicted protein concentrations
  plot(UNKNOWNCONCENTRATION, UNKNOWNS$absorbance,
       main = "Unknown Protein Concentration vs. Absorbance (750 nm)",
       xlab = "Predicted Protein Concentration (mg/ml)",
       ylab = "Absorbance (750 nm")
  abline(lm(STANDARD$absorbance ~ STANDARD$concentration), col = "red")

  #This provides us with a dataframe of our samples with both the absorbance and predicted concentration values.
  cbind(data.frame(UNKNOWNS$absorbance), data.frame(UNKNOWNCONCENTRATION))

}
DuganLJ/bradfordassay documentation built on Dec. 17, 2021, 5:30 p.m.