\documentclass{article} \usepackage{fullpage} \usepackage[colorlinks=true]{hyperref} \usepackage[tableposition=top]{caption} \usepackage[utf8]{inputenc} \begin{document} \title{Sample Analysis of Glycogen Determination from Tissues} \author{The Author} \date{The Date} \maketitle <>= working_directory <- 'some location' setwd(working_directory) data_file <- "raw_glycogen_data.csv" #columns include Volume, Weight, A505 and Treatment or Genotype data <- read.csv(data_file) #std_curve_file <- "std_curve.csv" #columns Glucose, A505 #std_curve <- read.csv(std_curve_file) #uncomment the previous two lines and comment the next two if entering std curve data from a file std_curve <- data.frame(Glucose = c(0,0.2,0.4,0.6,0.8,1.0), A505=c(0,140,269,360,471,561)) @ The data is saved in \Sexpr{working_directory}. <>= glucose.mwt <- 180.15588 #g/mol not used unless wanting to convert to molar std_fit <- lm(Glucose~A505 -1, data=std_curve) #force through intercept summary(std_fit) @ <>= plot(Glucose~A505, data=std_curve, ylab="Glucose (ug)", ylim=c(0,max(std_curve$Glucose)), xlim=c(0,max(std_curve$A505))) ) abline(std_fit) @ \begin{figure} \begin{center} <>= <> @ \end{center} \caption{Standard Curve for Glucose Assay.} \label{fig:one} \end{figure} <>= data$Glycogen <- data$A505*coefficients(std_fit) #in ug/assay assay.volume <- 100 #uL data$total.glycogen <- data$Glycogen*200/assay.volume #in ug data$normalized.glycogen <- data$total.glycogen/data$Weight*1000 # in ug/g calculated.data <- data.frame(Mouse = data$Mouse, Treatment = data$Treatment, Glycogen = data$normalized.glycogen, check.rows=F) result.t.test <- t.test(Glycogen~Treatment, data=calculated.data) #for single comparason #result.t.test <- with(calculated.data, pairwise.t.test(Glycogen,Treatment)) for multiple comparasons print(result.t.test) @ <>= require(xtable) print(xtable(calculated.data[order(calculated.data$Treatment),], caption = "Calculated Data", label = "tab:one"), include.rownames=F) @ <>= require(reshape) summary <- as.matrix(cast(calculated.data, ~Treatment, value="Glycogen", fun.aggregate=mean)) se <- function(x) sd(x, na.rm=T)/sqrt(length(x)) error.se <- as.matrix(cast(calculated.data, ~Treatment, value="Glycogen", fun.aggregate=se)) summary.table <- rbind(Mean=summary, SE=error.se) rownames(summary.table) <- c("Mean", "Standard Error") @ <>= print(xtable(summary.table, caption = "Summarized Data", label = "tab:summary")) @ <>= ymax <- max(summary)+max(error.se) plot <- barplot(summary, ylab="Glycogen Levels (ug/g)", ylim = c(0,ymax)) superpose.eb <- function (x, y, ebl, ebu = ebl, length = 0.08, ...) arrows(x, y + ebu, x, y - ebl, angle = 90, code = 3, length = length, ...) superpose.eb(plot, summary, error.se) @ <>= plot <- boxplot(calculated.data$Glycogen~calculated.data$Treatment, ylab="Glycogen Levels (ug/g)", ylim = c(0,max(calculated.data$Glycogen))) @ <>= plot(jitter(as.numeric(calculated.data$Treatment)), calculated.data$Glycogen, pch=19, xaxt="n", ylab="Glycogen Levels (ug/g)", xlab="", ylim=c(0,max(calculated.data$Glycogen))) axis(side=1, at=1:length(levels(calculated.data$Treatment)), labels=levels(calculated.data$Treatment)) #calculate means means <- tapply(calculated.data$Glycogen,calculated.data$Treatment, mean) #add axis means scaling = length(levels(calculated.data$Treatment)) scaling.values <- seq(1, scaling, by=1) scaling.values.upper <- scaling.values+1/scaling scaling.values.lower <- scaling.values-1/scaling for (i in scaling.values) segments(scaling.values.lower[i], means[i], scaling.values.upper[i], means[i]) @ \begin{figure} \begin{center} <>= <> @ \end{center} \caption{Summary of Glycogen Levels.} \label{fig:barplot} \end{figure} \begin{figure} \begin{center} <>= <> @ \end{center} \caption{Summary of Glycogen Levels.} \label{fig:boxplot} \end{figure} \begin{figure} \begin{center} <>= <> @ \end{center} \caption{Summary of Glycogen Levels.} \label{fig:dotplot} \end{figure} \section*{Session Information} <>= toLatex(sessionInfo()) @ \end{document}