Example Calculation of pH values from Ratio values and plot of Nhe2RNAi pH data

What follows is a generic description of what I did to calculate pH values from ratio values for each set of RNAi data.

setwd("~/Box Sync/Nystul_lab/R/pHdata")
source("calcpH.R")
source("calcpH2.R")
source("newpH.R")
## Warning: package 'plyr' was built under R version 3.1.3
source("doStats.R")
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.1.3

This is an example of how to calculate pH values from a linear regression model for one of my Nhe2RNAi experiments. The rest of this file details the locations of the other two files and the same procedure would be used to generate the pHi values and then was combined into a final file called “160426_reanalysis_nhe2RNAi.csv”

new = read.csv("150504_pHraw.csv")
pnew <- splitp(new)
hnew <- splith(new)

plot the regression lines

ggplot(pnew, aes(x=nph, y = Ratio, fill = genotype )) + geom_point() + stat_smooth(method = "lm") + facet_wrap(~region)

plot of chunk unnamed-chunk-3 Breakdown by genotype

pctrl <- pnew[pnew$genotype == "10930ctrl",]
poe <- pnew[pnew$genotype == "10930Nhe2RNAi",]
ctrl.lm <- all_lm(pctrl, pctrl$region)
mut.lm <- all_lm(poe, poe$region)
df.ctrl <- mycoefs(ctrl.lm)
df.ctrl$genotype <- "10930ctrl"
df.oe <- mycoefs(mut.lm)
df.oe$genotype <- "10930Nhe2RNAi"
df.all <- rbind(df.ctrl, df.oe)
names(df.all) = c("region", "int", "slope", "rsquared", "genotype")

merged = merge(hnew, df.all, by = c("region", "genotype"))
merged$calcpH = calclm(merged$Ratio, merged$slope, merged$int)

Did this three times for three different Ns
relevant .csv files are: 150504_pHraw.csv 150428_pHraw.csv 150505and0513_pHraw.csv

all combined are in… write.csv(rnaiAll, “160426_reanalysis_nhe2RNAi.csv”, row.names = FALSE)

This is the plot for the Nhe2RNAi pH data.

rnaiAll = read.csv("160426_reanalysis_nhe2RNAi.csv")
rnaiAll= read.csv("")
## Warning in file(file, "rt"): file("") only supports open = "w+" and open =
## "w+b": using the former
## Error in read.table(file = file, header = header, sep = sep, quote = quote, : no lines available in input
rnaiAll.clean = rnaiAll[rnaiAll$calcpH < 7.8 & rnaiAll$calcpH > 6.5,]
pvals = getpvals(rnaiAll.clean, myt)
summaryRNAi = ddply(rnaiAll.clean, .(genotype, region), summarise, ph = mean(calcpH), sd = sd(calcpH), se = sd/sqrt(3))
colnames(summaryRNAi)[2] <- "pval"
rnaiAll.clean$region = relevel(rnaiAll.clean$region, ref = "stem")
ggplot(rnaiAll.clean[rnaiAll.clean$region %in% c("stem", "2b", "3"),], aes(x=region, y = calcpH, fill = genotype) ) + geom_boxplot() + theme_classic() + theme(axis.text = element_text(size = 15), line = element_line(size =2 ))

plot of chunk unnamed-chunk-7