%load_ext rpy2.ipython
from how to
Lab experiment zip file
Contained in the laboratory zip file are CSV files of the normalized HIF-1α data and associated R script. The Threshold and Time-course analyses and plots (Fig. 5 & 6) are saved in separate files.
First, open the desired R script. Set the working directory so R can call the CSV files. Then simply run the code to view the results of the two-way ANOVA and recreation of the plots in the manuscript.
pwd
u'/Users/sr320/Dropbox/Steven/ipython_nb'
!cat /Users/sr320/Desktop/1190951/Lab\ experiments/ANOVA_Threshold.r
cd /Users/sr320/Desktop/1190951/Lab\ experiments
/Users/sr320/Desktop/1190951/Lab experiments
%%R
threshold.data <-read.csv('Threshold_data.csv', header = TRUE)
head(threshold.data)
Sample Treatment Size NormalizedExp 1 14C Control 128 0.000284707 2 15C Control 119 0.000094400 3 16C Control 108 0.000048100 4 17C Control 124 0.000103488 5 18C Control 114 0.000067300 6 31C Control 131 0.001671205
%%R
th.anova<-lm(NormalizedExp~Treatment + Size, data=threshold.data)
summary(th.anova)
anova(th.anova)
Analysis of Variance Table Response: NormalizedExp Df Sum Sq Mean Sq F value Pr(>F) Treatment 2 1.0011e-05 5.0057e-06 3.2856 0.04353 * Size 1 5.0000e-09 4.6000e-09 0.0030 0.95637 Residuals 67 1.0208e-04 1.5235e-06 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
pylab inline
Populating the interactive namespace from numpy and matplotlib
%%R
library(Hmisc) #for errorbars
#first calculate mean, sd, and count
th.mean<-tapply(data1$NormalizedExp,data1$Treatment, mean)
th.sd<-tapply(data1$NormalizedExp,data1$Treatment, sd)
th.count<-tapply(data1$NormalizedExp,data1$Treatment, length)
#calculate SE
th.se<-th.sd/(sqrt(th.count))
#Bind mean and SE for plotting
threshold.plot<-cbind(th.mean,th.se)
threshold.plot
#Data was exported and relative expression and SE were claculated
##Upload plot data
th.plot <-read.csv('Mean_threshold_plot.csv', header = TRUE)
head(th.plot )
yplus<-th.plot$Relative+th.plot$RelativeSE
yminus<-th.plot$Relative
barx<-barplot(th.plot$Relative, las=1, ylab="Relative HIF-1a mRNA Expression",
ylim=c(0,3),cex.lab=1.1, cex.axis=1.11,col="gray", axis.lty=1,
names.arg=c("Control","Moderate","Hypoxia"),
cex=1.1)
errbar(barx,th.plot$Relative, yplus,yminus, type='n', add=T)
Error in tapply(data1$NormalizedExp, data1$Treatment, mean) : object 'data1' not found
!cat /Users/sr320/Desktop/1190951/Lab\ experiments/Mean_threshold_plot.csv
%%R
workdir <-"/Users/sr320/Desktop/1190951/Field\ data"
setwd(workdir)
%%R
field.data <-read.csv('All_field_qPCR.csv', header = TRUE)
head(field.data)
Sample Year Month Site Size TrawlDepth NormalizedExp RelativeExp Elevated 1 2012-42 2012 August A 178 35.6 0.000449324 0.66562636 0 2 2012-43 2012 August A 195 35.6 0.000026700 0.03959079 0 3 2012-44 2012 August A 194 35.6 0.000029800 0.04408860 0 4 2012-45 2012 August A 195 35.6 0.001332981 1.97467024 1 5 2012-46 2012 August B 195 72.5 0.000909842 1.34783478 0 6 2012-47 2012 August B 171 72.5 0.000679925 1.00723675 0
%%R
library(lme4)
#Year model
yr.mod<- glm(Elevated ~ factor(Year) + Site + Size + TrawlDepth, family=binomial(link = "logit"), data=field.data)
summary(yr.mod)
anova(yr.mod, test="Chisq")
Error in library(lme4) : there is no package called ‘lme4’