-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotData.R
More file actions
183 lines (131 loc) · 5.65 KB
/
Copy pathplotData.R
File metadata and controls
183 lines (131 loc) · 5.65 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
library(ggplot2)
# ============================================================================
#
# DESCRIPTION: Data analysis for Fíji pHlorin workflow
#
# AUTHOR: Christopher Schmied,
# CONTACT: schmied@dzne.de
# INSITUTE: Leibniz-Forschungsinstitut f r Molekulare Pharmakologie (FMP)
# Cellular Imaging - Core facility
# Campus Berlin-Buch
# Robert-Roessle-Str. 10
# 13125 Berlin, Germany
#
# BUGS:
# NOTES:
# DEPENDENCIES: ggplot2: install.packages("ggplot2")
# gridExtra: install.packages("gridExtra")
#
# VERSION: 1.0.0
# CREATED: 2018-05-24
# REVISION: 2018-08-07
#
# ============================================================================
# plotting the raw values of all the experiments
plotRawMean <- function(dataTable){
mean.signal <- subset(dataTable, variable == "mean" )
count <- as.data.frame(table(mean.signal$name))
mean.list <- list()
plots <- list()
for (names in count$Var1){
one.table <- subset(mean.signal, name == names )
mean.list[[names]] <- one.table
plots[[names]] <- ggplot(data=one.table, aes(x=time, y=value, colour=variable, group=roi)) +
geom_line() +
guides(colour="none") +
theme_light() +
xlab("time (s)") +
ylab("Fluorescence (a.u.)") +
#ylim(0, 800) +
ggtitle(names)
}
return (plots)
}
plotRawMean_single <- function(dataTable, dataName){
mean <- subset(dataTable, variable == "mean" )
singleData <- subset(mean, name == dataName)
single_plot <- ggplot(data=singleData, aes(x=time, y=value, color = roi, group=roi)) +
geom_line() +
guides(colour="none") +
theme_light() +
xlab("time (s)") +
ylab("Fluorescence (a.u.)") +
ggtitle(dataName)
return(single_plot)
}
# plotting the raw values of all the experiments
plotMean_single <- function(dataTable, dataName){
singleData <- subset(dataTable, name == dataName)
singleData$high <- with(singleData, singleData$mean.corr + singleData$sd.sig)
singleData$low <- with(singleData, singleData$mean.corr - singleData$sd.sig)
plot <- ggplot(data=singleData, aes(x=time, y=mean.corr )) +
geom_ribbon(aes(ymin = low, ymax = high, colour=name, group=name, fill = name ), alpha=.3) +
geom_line(colour = "black") +
guides(fill = "none", color = "none", linetype = "none", shape = "none") +
theme_light() +
xlab("time (s)") +
ylab("Avg. Fluorescence (a.u.)") +
ggtitle(paste0("Avg. background subtracted +/- SD"))
return (plot)
}
plotRawArea <- function(dataTable, label) {
# create box plot the show the size distribution of the segmented objects
area.signal <- subset(dataTable, variable == "area" )
area.signal <- subset(area.signal, frame == "1" )
areaplot <- ggplot(area.signal, aes(x=name, y=value)) +
geom_boxplot(outlier.colour="black", outlier.shape=16, outlier.size=2, notch=FALSE) +
xlab("Movie name") +
ylab("Area (square micrometer)") +
ggtitle(paste0("Area ", label, " ROIs")) +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
return (areaplot)
}
# plotting the raw values of all the experiments
plotMean <- function(dataTable, column, title, sd){
if (sd == TRUE){
dataTable$high <- with(dataTable, dataTable$mean + dataTable$sd)
dataTable$low <- with(dataTable, dataTable$mean - dataTable$sd)
plot <- ggplot(data=dataTable, aes(x=time, y=mean, colour=name, group=name, fill = name)) +
geom_ribbon(aes(ymin = low, ymax = high, colour=name, group=name, fill = name ), alpha=.3) +
geom_line(colour = "black") +
guides(fill = "none", color = "none", linetype = "none", shape = "none") +
theme_light() +
xlab("time (s)") +
ylab("Avg. Fluorescence (a.u.)") +
#ylim(0, 450) +
ggtitle(paste0("Avg. grey value ", title))
} else if (sd == FALSE) {
varname <- c(column)
plot <- ggplot(data=dataTable, aes(x=time, y=get(varname[1]), colour=name, group=name, fill = name)) +
geom_ribbon(aes(ymin = get(varname[1]), ymax = get(varname[1]), colour=name, group=name, fill = name ), alpha=.3) +
geom_line() +
guides(fill = "none", color = "none", linetype = "none", shape = "none") +
theme_light() +
xlab("time (s)") +
ylab("Avg. Fluorescence (a.u.)") +
ggtitle(paste0("Avg. grey value ", title))
}
return (plot)
}
plotMeans <- function(avg.signal, avg.background, finalTable) {
plot.list <- list()
plot.list[["Peak Norm"]] <- plotMean(finalTable, "peak_norm", "peak normalized", FALSE)
plot.list[["Surface Norm"]] <- plotMean(finalTable, "surf_norm", "surface normalized", FALSE)
plot.list[["Corrected"]] <- plotMean(finalTable, "mean.corr", "background subtracted", FALSE)
plot.list[["Signal"]] <- plotMean(avg.signal, "mean", "Signal", FALSE)
plot.list[["Background"]] <- plotMean(avg.background, "mean", "Background", FALSE)
return(plot.list)
}
plotSummary1 <- function(finalTable) {
plot.list <- list()
plot.list[["Peak Norm"]] <- plotMean(finalTable, "peak_norm", "peak normalized", FALSE)
plot.list[["Surface Norm"]] <- plotMean(finalTable, "surf_norm", "surface normalized", FALSE)
plot.list[["Corrected"]] <- plotMean(finalTable, "mean.corr", "background subtracted", FALSE)
return(plot.list)
}
plotSummary2 <- function(avg.signal, avg.background, finalTable) {
plot.list <- list()
plot.list[["Signal"]] <- plotMean(avg.signal, "mean", "Signal", FALSE)
plot.list[["Background"]] <- plotMean(avg.background, "mean", "Background", FALSE)
return(plot.list)
}