-
Notifications
You must be signed in to change notification settings - Fork 1
/
GCG Super Script.R
143 lines (106 loc) · 5.44 KB
/
GCG Super Script.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# Made By Derek J. Debrauske, 2021
# ddebrauske@gmail.com
# ddebrauske@wisc.edu
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#Update, install and attach GCG package.
detach(package:GCG)
remove.packages("GCG")#remove GCG package from R root folder so you can update it.
#remove GCG package from workspace so you can update it.
devtools::install_github("ddebrauske/GCG", force=TRUE)#install GCG package from github
library(GCG) #add package to current R environment
#run "help()" commands to see more information on each function
#run "head()" commands to preview data
#Optional - Set the working directory to the folder you'd like to work from. (If you open a .R file, the wd will by default be the folder you opened from.)
setwd("C:/Users/Derek Debrauske/Dropbox/R/Projects/")
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##Act I: Gathering data
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~
#1. Step through plate layout input file, edited from template
# This function returns a long data frame, combining all of the information from your plate layouts. Each row of this data frame refers to one well
help("PlateLayout")
layout <- PlateLayout("Plate_Layout.csv") #change this path to refer to th elocation of your Plate_layout file.
head(layout, n = 12) #run this to see what the converted format looks like.
unique(layout$Plate)
#~~~~~~~~~~~~
#2. Do the same with the blank input file.
# Returns a similar, long dataframe with wells as rows.
help("PlateBlank")#Converts matrix style blanks from template into long table
blank <- PlateBlank("Plate_Blanks.csv") #change this path to refer to th elocation of your Plate_blank file.
head(blank, n=12) #check out what the output format looks like
unique(blank$Plate) #check that you got all your plates
#~~~~~~~~~~~~
#3. Combine all of the above information into one table.
help("CombineLayoutBlank")
layout.blanks <- CombineLayoutBlank(layoutDF = layout, blankDF = blank)
head(layout.blanks, n=12)
# ~~~~~~~~~~~~
# Optional step -- if your plate reader data is exported from your plate reader as a workbook with many sheets, you can use this function to separate these sheets into separate .csv files to be used in the next steps. (uncomment to use)
# help("ExcelToCSV")
# ExcelToCSV(path = "", out_dir = "")
# list.files("")
#~~~~~~~~~~~~
#4. Import plate reader data from .csv files into R.
#make if( no blank ){ don't subtract}
help("Import")
Timepoint.data <- Import(path = "Spark Data/", plate.reader.type = "spark", read.interval = 60)
head(Timepoint.data, n=12)
#~~~~~~~~~~~~
#5. attach information from layout and blank to plate reader data. this function back-subtracts the blank values from the OD600 of corresponding wells.
help("TimeseriesLayoutBlank")
# You can run this one of two ways:
# 1. Without back subtracting blanks: use only
#data.combined.no.blank <- TimeseriesLayoutBlank(timepoint.df = Timepoint.data, layout.df = layout)
#head(data.combined.no.blank)
# 2. With back-subtracting blanks:
data.combined <- TimeseriesLayoutBlank(timepoint.df= Timepoint.data, layout.blank.df = layout.blanks)
#5.1 subset out all strains labeled as "ddH2O" these are my border wells
data.combined <- subset(data.combined, Strain != "ddH2O")
head(data.combined) #you can see now that there are no more "ddH2O" wells, and the row A (border) has been skipped.
#~~~~~~~~~~~~
#6. Summarize technical replicates
#this finds mean, SE of biological replicates. if there are technical replicates, they are averaged first, then mean and SE is calculated from these means.
help("SummarizeTechreps")
Tech.Rep.Summary <- SummarizeTechReps(data.combined)
head(Tech.Rep.Summary)
#~~~~~~~~~~~~
#7. Summarize Biological Replicates
help("SummarizeBioReps")
Bio.Rep.Summary <- SummarizeBioReps(Tech.Rep.Summary)
head(Bio.Rep.Summary)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##Act II: Plotting Curves
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~
# Plot all replicate data as a wrap of all conditions
## NOTE: Use "./" as working directory (this shorthand for working directory in R). we were able to skip this detail in previous sections and simply type "".
help("GCGplot_wrap")
p <- GCGplot_wrap(Bio.Rep.Summary, out.dir= "./", graphic.title = "ChemGen Validation R2")
print(p)
#~~~~~~~~~~~~
# Plot individual conditions
help("GCGplot_conds")
GCGplot_conds(Tech.Rep.Summary, graphic.title ="ChemGen Validation R2", out.dir= "./")#see results in folder
#~~~~~~~~~~~~
#plot all wells to spot-check plates.
help("GCGplot_matrices")
GCGplot_matrices(data.combined, out.dir = "./" , graphic.title = "ChemGen Validation R2", matrix.columns = 10 )#see results in folder
#~~~~~~~~~~~~
#plot each biological rep as a separate facet_wrap
help("GCGplot_bioreps")
GCGplot_bioreps(data.combined, out.dir = "./", graphic.title = "ChemGen Validation R2")#see results in folder
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##Act III: Other analysis
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#1. Find Area Under the Curve
eAUC_data <- SuperAUC(data.combined, TRUE)
#2. Prepare data for analysis with growthcuver
gcr_input <- Growthcurver_convert(data.combined)
# ______ __ __ ___ ___ ____ ___
# | || | | / _] / _]| \ | \
# | || | | / [_ / [_ | _ || \
# |_| |_|| _ || _] | _]| | || D |
# | | | | || [_ | [_ | | || |
# | | | | || | | || | || |
# |__| |__|__||_____| |_____||__|__||_____|