Final Figure for pH calibrations

This is the code for the calibration figure, and also shows code for plots comparing a two and three point calibration.

setwd("~/Box Sync/Ulmschneider manuscript/fig1_supp/threeptcalibration/")
set3 = read.csv("130803_nig_redo.csv")
set3$Type = as.character(set3$Type)
set3$Type[set3$Type == "daughter_F2" | set3$Type == "daughter_F3"] <- "follicle"
set3$Type[set3$Type == "daughter_F1"] <- "prefollicle"

This is the plot for the three point calibration.

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.1.3
p3 = ggplot(set3, aes(x= pH, y = Ratio, fill = Type, colour = Type  ))
p3 + geom_point(position = position_jitter(w = 0.01)  ) + stat_smooth(method = "lm", se = FALSE) + theme_classic(base_size = 15 )

plot of chunk unnamed-chunk-2

This is the plot for the two point calibration

set3.twopt = set3[set3$pH != 7.0,]
p4 = ggplot(set3.twopt, aes(x= pH, y = Ratio, fill = Type, colour = Type  ))
p4 + geom_point(position = position_jitter(w = 0.01)  ) + stat_smooth(method = "lm", se = FALSE) + theme_classic(base_size = 15 )

plot of chunk unnamed-chunk-3

This code extracts the slope and y-intercept from the linear regression model

source("newpH.R")
## Warning: package 'plyr' was built under R version 3.1.3
lms = dlply(set3, .(Type), mylm)
coefs1= mycoefs(lms)
set3.twopt = set3[set3$pH != 7.0,]
lms2 = dlply(set3.twopt, .(Type), mylm)
coefs2 = mycoefs(lms2)
names(coefs1) <- c("cellType", "intercept", "slope", "rsquared")
#remames columns 

names(coefs2) <- c("cellType", "intercept", "slope", "rsquared")

Three point calibration

coefs1
##      cellType intercept     slope  rsquared
## 1    follicle -6.222341 1.0353002 0.9173353
## 2 prefollicle -5.741280 0.9542530 0.9032306
## 3        stem -5.784677 0.9537504 0.8522626

Two point calibration

coefs2
##      cellType intercept     slope  rsquared
## 1    follicle -6.247494 1.0379101 0.9220061
## 2 prefollicle -5.776138 0.9578554 0.9091619
## 3        stem -5.684990 0.9446426 0.8673960

This code calculates the differences between the two and three point calibrations, and puts everything in a single data frame

diffSlope = coefs1$slope - coefs2$slope
diffInt = coefs1$intercept - coefs2$intercept
diffRsq = coefs1$rsquared - coefs2$rsquared 
coefs1$calType = "threept"
coefs2$calType = "twopt"
allcoefs = rbind(coefs1, coefs2) 
allcoefs$diffSlope = diffSlope
allcoefs$diffInt = diffInt
allcoefs$diffrsq = diffRsq
allcoefs
##      cellType intercept     slope  rsquared calType    diffSlope
## 1    follicle -6.222341 1.0353002 0.9173353 threept -0.002609893
## 2 prefollicle -5.741280 0.9542530 0.9032306 threept -0.003602363
## 3        stem -5.784677 0.9537504 0.8522626 threept  0.009107874
## 4    follicle -6.247494 1.0379101 0.9220061   twopt -0.002609893
## 5 prefollicle -5.776138 0.9578554 0.9091619   twopt -0.003602363
## 6        stem -5.684990 0.9446426 0.8673960   twopt  0.009107874
##       diffInt      diffrsq
## 1  0.02515352 -0.004670823
## 2  0.03485852 -0.005931296
## 3 -0.09968715 -0.015133362
## 4  0.02515352 -0.004670823
## 5  0.03485852 -0.005931296
## 6 -0.09968715 -0.015133362