Reputation: 11
I am trying to add data of a pre, post and control absorbance values to my calibration curve graph.
The code below is what I currently have, which creates a scattergraph and a line of best fit. However I need to plot the absorbance values of...
Control: 0.008 Pre-Treatment: 0.280 Post-Treatment: 0.117
...onto the graph using the line of best fit to find their concentrations. Here is my code below:
BSA <- data.frame(Concentration=c(0.0, 0.2, 0.4, 0.6, 0.8, 1.0),
Absorbance=c(0.000, 0.182, 0.159, 0.121, 0.311, 0.352))
values <- data.frame(Sample=c("Control", "Pre-treatment", "Post-treatment"),
Absorbance=c(0.008, 0.280, 0.117))
plot(BSA, ylab="Absorbance of BSA", xlab="Assay Concentration (ml/mg)", las=1)
abline(lm(BSA$Absorbance ~ BSA$Concentration))
I am struggling to find a method to do this and previous posts are very specific to the user's data set and do not work with my data for some reason.
Upvotes: 0
Views: 109
Reputation: 7404
I'm still not entirely clear on what you need, but it sounds like you need to:
Here is how I would approach it
# You provided...
BSA = data.frame(Concentration = c(0.0, 0.2, 0.4, 0.6, 0.8, 1.0),
Absorbance = c(0.000, 0.182, 0.159, 0.121, 0.311, 0.352))
values = data.frame(Sample = c("Control", "Pre-treatment", "Post-treatment"),
Absorbance = c(0.008, 0.280, 0.117))
# Here is how I would do this...
# First, make a model
fit <- lm(Concentration ~ Absorbance, data=BSA)
# Next, plot your data
with(BSA, plot(Absorbance, Concentration))
# Add the line of best fit
abline(fit)
# Now, get the predictions from your "values" dataframe
predicted_concentration <- predict(fit, newdata = values)
values$predicted_concentration <- predicted_concentration
# Add the predictions to your plot, maybe in a different color
with(values, points(Absorbance, predicted_concentration, col='red'))
I'm not clear on what control/pre/post treatment mean here, maybe you can clarify if I've missed something.
Upvotes: 0