# Run this code block to load the Tidyverse package
.libPaths(new = "~/Rlibs")
install.packages("GGally", lib = "~/Rlibs")
library(tidyverse)
library(dplyr)
library("GGally")
# Import the dataset
original_data <- read_csv("Brauer2008_Dataset1.csv")
nrow(original_data)
ncol(original_data)
The code below splits the values in the NAME column so that each value (separated by ||) is in a separate column and assigns the dataframe to a variable original_data_1 by way of the function separate(). The new columns are named as follows: “name”, “BP”, “MF”, “systematic_name”, and “number”.
original_data_1<-separate(original_data,NAME,c("name","BP","MF","systematic_name","number"),sep="\\|\\|")
The code below removes the whitespace from the five new columns that were created using the function mutate_each() and assigns the dataframe to a variable original_data_1.
original_data_1<-mutate_each(original_data_1, funs(trimws), name:systematic_name)
The code below removes the GID, YORF, and GWEIGHT columns from the dataset but leave all the others. The minus sign indicates to remove the columns specified.
original_data_1 <- subset(original_data_1, select = -c(GID, YORF,GWEIGHT))
The code below uses the gather() function to move variable names in columns G0.05 through U0.3 into a single column. The new column holding the variable names is called “sample” and the new column holding the values underneath the G0.05 through U0.3 is called “expression”.
original_data_1<-gather(original_data_1,"sample","expression",G0.05:U0.3)
The code below splits the "sample" column into two columns "nutrient" and "rate" by using the separate() function.
original_data_1<-separate(original_data_1,sample,c("nutrient","rate"),sep=1,convert=TRUE)
The code below applies a filter() to only look at the rows with a name of “LEU1” in the dataset.
leucine<-filter(original_data_1, name == "LEU1")
A line plot is created using ggplot2. The rate is shown on the horizontal axis, expression on the vertical, and the separate nutrients plotted as different colors.
enzyme.plot<-ggplot(data=leucine,aes(rate, expression, colour=nutrient)) + geom_line(lwd=1.5)
ggsave("enzymePlot.png", plot = enzyme.plot, device="png", scale=1, width=5, height=4)
enzyme.plot
Look closely at that! LEU1 is highly expressed when starved of leucine because the cell has to synthesize its own! And as the amount of leucine in the environment (the growth rate) increases, the cell can worry less about synthesizing leucine, so LEU1 expression goes back down. Consequently the cell can devote more energy into other functions, and we see other genes’ expression very slightly raising.
head(original_data_1)
head(original_data)