%%%
\documentclass[12pt]{article}
%%%
%%% these are required for Sweave
\usepackage{Sweave}
\usepackage{lmodern}
%%% hyperref
\usepackage{color}
\definecolor{darkblue}{rgb}{0, 0, 0.5}
\usepackage{hyperref}
\hypersetup{colorlinks=true}
\hypersetup{linkcolor=darkblue}
%%%
%%% Allows the use of OpenType fonts
%%% Needs to be placed after maths font packages
%%% particularly 'euler'
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
%%% Main text font
\setmainfont[Ligatures={Rare, TeX, NoCommon}, Numbers={Lowercase}]{Linux Libertine O}
\fontsize{12 pt}{16 pt}
\selectfont
%%%
%%% other useful additions
%%%
%%% for rerunfilecheck:
%%% no need to rerun to get outlines right
\usepackage{bookmark}
%%% for nice tables
\usepackage{booktabs}
%%% for e.g. \formatdate
\usepackage{datetime}
%%% for SI units
\usepackage{siunitx}
%%% for chemical symbols
\usepackage[version=3]{mhchem}
%%% to use forced 'here'
%%% e.g. \begin{figure}[H]
\usepackage{float}
%%% for large numbers of floats
\usepackage{morefloats}
%%% to keep floats in same section
\usepackage[section]{placeins}
%%% for tables > 1 page
\usepackage{longtable}
%%%
%%%----------------------------------------
%%%
\begin{document}
%%%
\title{16k2}
\author{Chris Dardis}
\date{Monday 24th February, 2014}

\maketitle
%%% page numbers appear top-right
\pagestyle{headings}
\tableofcontents

\section{Aim}

Investigate whether growth of a melanoma cell line is impaired in the presence of Beta-Hydroxy Butyrate (BHB).

\section{Materials}

\begin{itemize}
\item \textbf{B16-F1-Luc2-BR2} cells.\\
  These were generated as follows:
  \begin{itemize}
  \item B16 cells are available from ATCC.
  \item These were were transfected in our lab with luciferase (to allow luminescence to be used a measure of cell numbers) along with a promotor.
  \item They were then injected into the right ventricle of a mouse.\\
    These animals were sacraficed when they became symptommatic due to metastatic disease.
  \item Cells metastatic to the brain were recovered and grown again in the same medium.
  \end{itemize}
\item 12-well plastic culture plate (Falcon \textregistered)
\item Media: DMEM (Gibco \textregistered) +10\% FCS +
  \SI{600}{\ug\per\ml} G418 + 1x glutamine. pH \num{7.4}.\\
  FCS = Fetal calf serum.
\item Trypsin
\item Hemocytometer (manual and automated
  (Countess\texttrademark by Invitrogen\texttrademark)
\item \SI{15}{\ml} plastic centrifuge tube (VWR\texttrademark)
  \begin{itemize}
  \item Trypan blue stain 10\%
  \item Eppendorf tubes (plastic, sterile)
  \item PCR tubes (for mixing cells and Trypan blue)
  \item Disposable slides for Countess\texttrademark
  \end{itemize}
\end{itemize}

\section{Methods}

\subsection{Day 0}

\formatdate{17}{2}{2014}

The molecular weight of BHB is 126.\\
The calculations to convert to a target concentration
of \SI{10}{\mmol\per\l} are shown in equations~\ref{eq:bhb2}.

\begin{align}
  \label{eq:bhb2}
  \SI{1}{\mol} & = \SI{126}{\g} \\
  \SI{10}{\mmol} & = \SI{1.26}{\g} \\
  \SI{10}{\mmol\per\l} & = \SI{1.26}{\g\per\l} \\
  & = \SI{0.00126}{\g\per\ml} \\
  \intertext{Thus \SI{0.00126}{\g} in \SI{10}{\ul}
    added to \SI{1}{\ml} gives:}
  \SI{0.00126}{\g} \, per \SI{1}{\ml} & = \SI{10}{\mmol\per\l}
\end{align}

  The quantities of BHB required each day are shown in table~\ref{tab:bhb}.

\begin{table}[ht]
  \centering
  \begin{tabular}{cccc}
    Day & No wells & Volume of media (ml) & BHB (grams) \\\midrule
    1 & 9 & 10 & 0.01260 \\
    2 & 6 & 7 & 0.00882 \\
    3 & 3 & 4 & 0.00504 \\
  \end{tabular}
  \caption{Quantity of BHB required by day}
  \label{tab:bhb}
\end{table}

\begin{enumerate}
\item Cell counts from the T-25 flask are shown in table \ref{tab:ccd0}.

  \subsubsection{Cell counts on Day 0}
<<Cell counts on Day 0, results=tex, echo=TRUE, fig=FALSE, png=TRUE, strip.white=false>>=
df1 <- data.frame(Cells_per_ml=
                  c(468e3, 344e3, 504e3))
library(xtable)
print(xtable(df1,
             caption="Cell counts on day 0",
             align=c("l", "c"),
             display=c("d", "e"),
             label="tab:ccd0"),
      booktabs=TRUE)
@

\subsubsection{Mean}
<<Mean, results=tex, echo=TRUE, fig=FALSE, png=TRUE, strip.white=false>>=
(m1 <- mean(df1$Cells_per_ml))
@
The mean from the \num{3} counts was thus \SI{438e3}{\ml}.

\item For the cells being grown with \SI{10}{\umol\per\liter} BHB,
  add \SI{0.01639}{\g} of (R)-(-)-3-hydroxy butyric acid sodium salt to the \SI{50}{\ml} tube before the media and cells.
\item Seed $2 \times$ \num{12}-well plates with \num{16e3} cells in \SI{1}{\ml} of media.\\
  For \num{16e3} cells, this is $\frac{16}{438} = \SI{0.035}{\ml}$. \\
  Add $13 \times \SI{0.035}{\ml} = \SI{0.46}{\ml}$ to a \SI{50}{\ml} plastic tube (for mixing media with BHB) and
  top up to \SI{13}{\ml}. \\
  Mix well by pipetting up and down $\times 20$. \\
  Add \SI{1}{\ml} was to each of the \num{12} wells.

\item Shake the plates gently to evenly distribute the cells.\\
  Return to the incubator at \formattime{17}{30}{00}.

\item Incubate at \SI{37}{\celsius}, in 5\% \ce{CO2} for
  \SI{24}{\hour}.

\end{enumerate}

\subsection{Days 1-4}

\begin{enumerate}
\item For plates which are not being counted:\\
  Aspirate the old media and replace with \SI{1}{\ml} of new media.
\item For plates being grown in BHB, prepare the media was prepared by adding BHB as on day 0.\\
  The quantities of BHB required are shown in table \ref{tab:bhb}.
\item For plates to be counted:\\
  Add \SI{2}{\ml} of trypsin to each in the row to be counted.\\
  Rock the plates.\\
  Remove the trypsin after \textless \SI{30}{\s}.
\item Add \SI{250}{\uL} of trypsin.
\item Incubate at \SI{37}{\celsius} for \SI{3}{\minute}.
\item Shake the plate to ensure all cells are dislodged from the base.\\
  Check with the microscope.
\item 'Quench' the trypsin quenched with \SI{250}{\uL} of media.\\
  Pipette up and down $\times 20$ using glass Pasteur pipette to ensure the cells are thoroughly mixed.
\item Return plates to incubator.
\item Remove \SI{11}{\uL} of cell suspension and add \SI{11}{\uL}
  Trypan Blue in a sterile PCR tube.\\
  Mix using a pipette.
\item Place \SI{10}{\uL} of the mixture into a sample well of the hemocytometer.
\item Count the cells using the hemocytometer.\\
  These counts are shown in table \ref{tab:data}.
\end{enumerate}

\section{Results}

<<Results, results=tex, echo=TRUE, fig=FALSE, png=TRUE, strip.white=false>>=
df1 <- data.frame(Day = rep(rep(0:4, each=3), 2),
                  Tx = rep(c("Control", "BHB"), each=15),
                  Well = rep(LETTERS[1:3], 5),
                  Count = c(rep(16e3, 3),
                  32e3, 56e3, 6e3,
                  36e3, 14e3, 24e3,
                  90e3, 22e3, 18e3,
                  246e3, 38e3, 82e3,
                  rep(16e3, 3),
                  16e3, 34e3, 16e3,
                  20e3, 20e3, 24e3,
                  4e3, 12e3, 16e3,
                  20e3, 5e3, 12e3))
print(xtable(df1,
             caption="Cells per ml, day 0 - 4",
             align=c("l", rep("c", 4)),
             display=c("d", "d", "s", "s", "fg"),
             label="tab:data"),
      booktabs=TRUE)
@

\subsection{Standard error}

<<Standard error, results=tex, echo=TRUE, fig=FALSE, png=TRUE, strip.white=false>>=
stdErr <- function(x) sqrt(var(x)) / sqrt(length(x))
library(plyr)
## summarise as mean and standard error
## to allow for plotting
df2 <- ddply(df1, c("Day", "Tx"), summarise,
             mean = mean(Count),
             SE = stdErr(Count))
print(xtable(df2,
             caption="Cells per ml by treatment",
             align=c("l", rep("c", 4)),
             display=c("d", "d", "s", "fg", "fg"),
             label="tab:means"),
      booktabs=TRUE)
@

\subsection{Plot}

<<Plot, results=tex, echo=TRUE, fig=TRUE, png=TRUE, strip.white=false>>=
library(ggplot2)
## plot with position dodge
pd <- position_dodge(.1)
ggplot(df2, aes(x=Day, y=mean, color=Tx)) +
    geom_errorbar(aes(ymin=mean-SE, ymax=mean+SE),
                  width=.1, position=pd) +
    geom_line(position=pd) +
    geom_point(position=pd, size=3) +
    ggtitle("Effect of BHB (10 mMol/lt) \n on growth of B16 cells") +
    ylab("No. cells / ml")
@

\subsection{Day 4: t-test}

<<Day 4: t-test, results=verbatim, echo=TRUE, fig=FALSE, png=TRUE, strip.white=false>>=
with(df1[df1$Day==4, ], t.test(Count ~ Tx))
@

\subsection{Compare linear models}

<<compare linear models, results=tex, echo=TRUE, fig=FALSE, png=TRUE, strip.white=false>>=
## linear models perhaps not justified here
## but this is the simplest choice
l1 <- lm(Count ~ Day, data=df1)
l2 <- lm(Count ~ Day + Tx, data=df1)
a1 <- anova(l1, l2)
print(xtable(a1,
             caption="Analysis of variance \n when adding Tx to linear model",
             align=c("l", rep("c", 6)),
             display=c(rep("d", 2), "e", "d", "e", "fg", "fg"),
             label="tab:anova"),
      booktabs=TRUE)

@

\section{Conclusions}

The cells grown with BHB show signs of impaired growth vs. controls.\\
Although no clear difference could be demonstrated in cell counts on day 4 via a t-test, comparing linear models with and without treatment does show a significant effect.

%%%
\end{document}