## ----setup, include=FALSE------------------------------------------------ knitr::opts_chunk$set(echo = TRUE) ## ----create_S------------------------------------------------------------ S <- c(0,1,2,5,8,12,30,50) ## ----create_v------------------------------------------------------------ v <- c(0,11.1,25.4,44.8,54.5,58.2,72.0,60.1) ## ----combine_data-------------------------------------------------------- # Combine data in a dataframe: kinData <- data.frame(S,v) # Print the data: kinData ## ----first_plot---------------------------------------------------------- plot (S,v) ## ----theoretical_curve_formula------------------------------------------- # "velocity = Vmax times S divided by (Km plus S)", stored in MMcurve MMcurve <- formula(v ~ Vmax*S/(Km+S)) ## ------------------------------------------------------------------------ bestfit <- nls(MMcurve, kinData, start=list(Vmax=50,Km=2)) # print the results bestfit ## ----theoretical_curve_points-------------------------------------------- # Hypothetical oncentration ranges for S: SconcRange <- seq(0,50,0.1) # Calculate the predicted velocities using the predict() function: theorLine <- predict(bestfit,list(S=SconcRange)) ## ----replot_final-------------------------------------------------------- # Now plot the data, the best fit line, and put the best fit coefficients in the plot plot (kinData, xlab="Subtrate (mM)", ylab="Velocity (nmol/s)", title(main="Fitted MM data"), pch=17, col="blue", cex=1.5) # Now add the theoretical line with the lines() function: lines(SconcRange,theorLine,col="red") # Add text with the values: text(28,30, "Vmax = ") text(35,30,round(coef(bestfit)[1],2)) text(29,25, "Km = ") text(36,25,round(coef(bestfit)[2],2)) ## ----sessionInfo--------------------------------------------------------- sessionInfo()