Dear GitLab Users, due to maintance work and updates, the GitLab service will be unavailable for a few minutes between 20:00-20:30 CET on 20.01.2022. We are sorry for any inconvenience.

Unverified Commit bd8d0002 authored by Maximilian von der Linde's avatar Maximilian von der Linde Committed by GitHub
Browse files

InfiniteWhite-patch-3.2

final version of the uploaded code, last update of patch 3, so that patch 3 can then be merged to the master branch.
Functionality of both data types have been succesfully tested.
parent 4ce3bd53
################### Plotting functions for DTS data ###################### ################### Plotting functions for DTS data ######################
######## Plot torque and position data for each period ######## ######## Plot torque and position data for each period ########
trq_pos_traces <- function(temp) trq_pos_traces <- function(temp)
{ {
##modify a_Pos to introduce gaps between -180 and 180 ##modify a_Pos to introduce gaps between -180 and 180
pos <- temp$a_pos pos <- temp$a_pos
for(p in 2:nrow(temp)) for(p in 2:nrow(temp))
{ {
if (abs(as.numeric(pos[p]))>1950 && sign(as.numeric(pos[p]))!=sign(as.numeric(pos[p-1]))) {pos[p-1]="NA"} if (abs(as.numeric(pos[p]))>1950 && sign(as.numeric(pos[p]))!=sign(as.numeric(pos[p-1]))) {pos[p-1]="NA"}
} }
par(mar=c(5, 4, 4, 4) + 0.1) par(mar=c(5, 4, 4, 4) + 0.1)
traces <- plot(x = temp$time, y = temp$a_pos, type = "n", axes=FALSE, xaxs = "i", yaxs = "i", ylim=c(-2047,2048), ylab = "",xlab="") traces <- plot(x = temp$time, y = temp$a_pos, type = "n", axes=FALSE, xaxs = "i", yaxs = "i", ylim=c(-2047,2048), ylab = "",xlab="")
#shade quadrants #shade quadrants
rect(temp$time[1],-1538,temp$time[nrow(temp)],-512, col = "grey95") rect(temp$time[1],-1538,temp$time[nrow(temp)],-512, col = "grey95")
rect(temp$time[1],512,temp$time[nrow(temp)],1538, col = "grey95") rect(temp$time[1],512,temp$time[nrow(temp)],1538, col = "grey95")
par(new=TRUE) par(new=TRUE)
plot(x = temp$time, y = pos, type = "l", col="red3", xaxs = "i", yaxs = "i", ylim=c(-2047,2048), ylab = "position[arb.units]",xlab="time [ms]") plot(x = temp$time, y = pos, type = "l", col="red3", xaxs = "i", yaxs = "i", ylim=c(-2047,2048), ylab = "position[arb.units]",xlab="time [ms]")
par(new=TRUE) par(new=TRUE)
plot(x = temp$time, temp$torque, type = "l", col="blue", xaxs = "i", ylim=c(-500,500), main = paste("Fly Traces", flyname, "Period", i), axes=F, xlab=NA, ylab="") plot(x = temp$time, temp$torque, type = "l", col="blue", xaxs = "i", ylim=c(-500,500), main = paste("Fly Traces", flyname, "Period", i), axes=F, xlab=NA, ylab="")
lines(c(temp$time[1],temp$time[nrow(temp)]),c(0,0),type="l",lty=1,lwd=1, col="black") lines(c(temp$time[1],temp$time[nrow(temp)]),c(0,0),type="l",lty=1,lwd=1, col="black")
axis(4) axis(4)
mtext("torque [arb_units]", side = 4, line = 3) mtext("torque [arb_units]", side = 4, line = 3)
return(traces) return(traces)
} }
dytraces <- function(rawdata) dytraces <- function(rawdata)
{ {
traces <- dygraph(rawdata, main = paste("Time Traces", flyname)) %>% traces <- dygraph(rawdata, main = paste("Time Traces", flyname)) %>%
dySeries("a_pos", label = "position", color = "darkred") %>% dySeries("a_pos", label = "position", color = "darkred") %>%
dySeries("torque", axis = 'y2', color = "blue") %>% dySeries("torque", axis = 'y2', color = "blue") %>%
dyAxis("x", drawGrid = FALSE) %>% dyAxis("x", drawGrid = FALSE) %>%
dyAxis("y", label = "Position [arb_units]", valueRange = c(-2048,2048)) %>% dyAxis("y", label = "Position [arb_units]", valueRange = c(-2048,2048)) %>%
dyOptions(gridLineColor = "lightgrey") %>% dyOptions(gridLineColor = "lightgrey") %>%
dyAxis("y2", label = "Torque [arb_units]", independentTicks = TRUE, valueRange = c(-700,700), drawGrid = FALSE) %>% dyAxis("y2", label = "Torque [arb_units]", independentTicks = TRUE, valueRange = c(-700,700), drawGrid = FALSE) %>%
dyOptions(includeZero = TRUE) %>% dyOptions(includeZero = TRUE) %>%
dyRangeSelector() dyRangeSelector()
return(traces) return(traces)
} }
############ Function to plot several plots into a single plot ######### dytraces_platform <- function(rawdata)
{
multiplot <- function(..., plotlist = NULL, file, cols = 1, layout = NULL) traces <- dygraph(rawdata, main = paste("Time Traces", flyname)) %>%
{ dySeries("arena", label = "position", color = "darkred") %>%
require(grid) dySeries("fly", axis = 'y2', color = "blue") %>%
dyAxis("x", drawGrid = FALSE) %>%
plots <- c(list(...), plotlist) dyAxis("y", label = "Arena Position [arb_units]") %>%
dyOptions(gridLineColor = "lightgrey") %>%
numPlots = length(plots) dyAxis("y2", label = "Fly [arb_units]", independentTicks = TRUE, drawGrid = FALSE) %>%
dyOptions(includeZero = TRUE) %>%
if (is.null(layout)) { dyRangeSelector()
layout <- matrix(seq(1, cols * ceiling(numPlots/cols)),
ncol = cols, nrow = ceiling(numPlots/cols)) return(traces)
} }
if (numPlots == 1) { ############ Function to plot several plots into a single plot #########
print(plots[[1]])
multiplot <- function(..., plotlist = NULL, file, cols = 1, layout = NULL)
} else { {
grid.newpage() require(grid)
pushViewport(viewport(layout = grid.layout(nrow(layout), ncol(layout))))
plots <- c(list(...), plotlist)
for (i in 1:numPlots) {
matchidx <- as.data.frame(which(layout == i, arr.ind = TRUE)) numPlots = length(plots)
print(plots[[i]], vp = viewport(layout.pos.row = matchidx$row, if (is.null(layout)) {
layout.pos.col = matchidx$col)) layout <- matrix(seq(1, cols * ceiling(numPlots/cols)),
} ncol = cols, nrow = ceiling(numPlots/cols))
} }
}
if (numPlots == 1) {
############ Function to annotate plots after stats ######### print(plots[[1]])
#Wilcoxon annotations } else {
wilcox.annotate <- function(boxes, wilcoxon) grid.newpage()
{ pushViewport(viewport(layout = grid.layout(nrow(layout), ncol(layout))))
annotate("text",
x=boxes, for (i in 1:numPlots) {
y=1.1, matchidx <- as.data.frame(which(layout == i, arr.ind = TRUE))
label=paste("p=",wilcoxon[boxes]))
} print(plots[[i]], vp = viewport(layout.pos.row = matchidx$row,
layout.pos.col = matchidx$col))
#samplesizes annotations }
samplesizes.annotate <- function(boxes, samplesizes) }
{ }
annotate("text", #source: http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/
x=boxes,
y=-1.1, ############ Function to annotate plots after stats #########
label=paste("N=", samplesizes[boxes]))
} #Wilcoxon annotations
wilcox.annotate <- function(boxes, wilcoxon)
########### Function to calculate False Positive Risk {
annotate("text",
#====================================================== x=boxes,
calc.FPR = function(samplesizes,pval,prior,delta1){ y=1.1,
sdiff=sqrt(1/samplesizes[1] + 1/samplesizes[2]) label=paste("p=",wilcoxon[boxes]))
df=samplesizes[1]+samplesizes[2]-2 }
# Note FPR doesn't need calculation of power for p-equals case
# #samplesizes annotations
#under H0, use central t distribution samplesizes.annotate <- function(boxes, samplesizes)
tcrit=qt((1-pval/2),df,ncp=0) {
x0=tcrit annotate("text",
y0=dt(x0,df,0) x=boxes,
# y=-1.1,
# under H1 use non-central t distribution label=paste("N=", samplesizes[boxes]))
ncp1=delta1/sdiff #non-centrality paramater }
x1=x0 #tcrit
y1=dt(x1,df,ncp=ncp1) ########### Function to calculate False Positive Risk
# Calc false positive risk #======================================================
p0=2*y0 calc.FPR = function(samplesizes,pval,prior,delta1){
p1=y1 sdiff=sqrt(1/samplesizes[1] + 1/samplesizes[2])
FPR=((1-prior)*p0)/(((1-prior)*p0) + prior*p1) df=samplesizes[1]+samplesizes[2]-2
FPR # Note FPR doesn't need calculation of power for p-equals case
output=c(FPR,x0,y0,x1,y1) #
return(output) #under H0, use central t distribution
tcrit=qt((1-pval/2),df,ncp=0)
x0=tcrit
y0=dt(x0,df,0)
#
# under H1 use non-central t distribution
ncp1=delta1/sdiff #non-centrality paramater
x1=x0 #tcrit
y1=dt(x1,df,ncp=ncp1)
# Calc false positive risk
p0=2*y0
p1=y1
FPR=((1-prior)*p0)/(((1-prior)*p0) + prior*p1)
FPR
output=c(FPR,x0,y0,x1,y1)
return(output)
} }
\ No newline at end of file
...@@ -43,20 +43,33 @@ grouped.poshistos <- list() #Position histograms for group in a list of length ...@@ -43,20 +43,33 @@ grouped.poshistos <- list() #Position histograms for group in a list of length
grouped.flyhistos <- list() grouped.flyhistos <- list()
grouped.flyhistosL <- list() #Platform position histograms for group in a list of length NofPeriods grouped.flyhistosL <- list() #Platform position histograms for group in a list of length NofPeriods
grouped.flyhistosR <- list() #Platform position histograms for group in a list of length NofPeriods grouped.flyhistosR <- list() #Platform position histograms for group in a list of length NofPeriods
grouped.flytraces <- list() #Platform position traces in a list of length NofGroups
grouped.PIprofiles <- list() #PIProfile data frames in a list of length NofGroups grouped.PIprofiles <- list() #PIProfile data frames in a list of length NofGroups
grouped.periods <- list() #Period designs in a list of length NofGroups grouped.periods <- list() #Period designs in a list of length NofGroups
grouped.spectra <- list() #Power spectra in a list of length NofGroups grouped.spectra <- list() #Power spectra in a list of length NofGroups
#create empty list for individual fly names in each group for display in project evaluation
exp_groups <- list()
for(x in 1:NofGroups) for(x in 1:NofGroups)
{ {
xml_list = paste(project.path, project.data[["resources"]][[x]][["data"]], sep = "/") grp_title = project.data[["resources"]][[x]][["title"]] #collect title of the group
grp_description = project.data[["resources"]][[x]][["description"]] #collect description of the group
xml_list = paste(project.path, project.data[["resources"]][[x]][["data"]], sep = "/") #create list of file names
#create/empty lists for collecting all single fly data by period #create/empty lists for collecting all single fly data by period
period.data <- list() #data grouped by period period.data <- list() #data grouped by period
grouped.data <- list() #total data grouped grouped.data <- list() #total data grouped
grouped.data.periodsL <- list() #total data grouped by left or right turning arena for platform grouped.data.periodsL <- list() #total data grouped by left or right turning arena for platform
grouped.data.periodsR <- list() grouped.data.periodsR <- list()
grouped.data.tracesL <- list() #mean trace of left or right Periods
grouped.data.tracesR <- list()
grouped.data.flyL <- list()
grouped.data.flyR <- list()
speclist <- list() speclist <- list()
#vectors for pooled platform period traces
flytracesL <- list()
flytracesR <- list()
#start evaluating #start evaluating
if(MultiFlyDataVerification(xml_list)==TRUE) # make sure all flies in a group have the identical experimental design if(MultiFlyDataVerification(xml_list)==TRUE) # make sure all flies in a group have the identical experimental design
...@@ -87,15 +100,17 @@ if(MultiFlyDataVerification(xml_list)==TRUE) # make sure all flies in a group ha ...@@ -87,15 +100,17 @@ if(MultiFlyDataVerification(xml_list)==TRUE) # make sure all flies in a group ha
#create/empty plot lists #create/empty plot lists
poshistos <- list() poshistos <- list()
trqhistos <- list() trqhistos <- list()
flyhistos <- list() #still needed? flyhistos <- list()
flyhistosR <- list() flyhistosR <- list()
flyhistosL <- list() flyhistosL <- list()
#vectors for pooled platform periods flytraces <- list()
optomotoL_flydata <- c() #vectors for pooled platform period histograms
optomotoR_flydata <- c() optomotoL_flydata <- list() #unused?
flyhistosL.rawdata <- list() optomotoR_flydata <- list() #unused?
flyhistosR.rawdata <- list() periodL <- data.frame() #these empty data frames are needed if no Platform data is used
periodR <- data.frame()
flytracesL_data_frame <- data.frame()
flytracesR_data_frame <- data.frame()
#### call RMarkdown for single fly evaluations ################################################ #### call RMarkdown for single fly evaluations ################################################
single_fly_path <- paste(start.wd, "single_fly.Rmd", sep = "/") single_fly_path <- paste(start.wd, "single_fly.Rmd", sep = "/")
rmarkdown::render(single_fly_path, rmarkdown::render(single_fly_path,
...@@ -110,11 +125,15 @@ if(MultiFlyDataVerification(xml_list)==TRUE) # make sure all flies in a group ha ...@@ -110,11 +125,15 @@ if(MultiFlyDataVerification(xml_list)==TRUE) # make sure all flies in a group ha
##add period data to grouped data ##add period data to grouped data
grouped.data[[l]] <- period.data grouped.data[[l]] <- period.data
grouped.data.periodsL[[l]] <- list(periodL) grouped.data.periodsL[[l]] <- list(periodL) #special lists for left and right p_opomtor periods
grouped.data.periodsR[[l]] <- list(periodR) grouped.data.periodsR[[l]] <- list(periodR)
xml_list[[l]] = paste('<a href="',flyname,'_descr_anal.html">', flyname,'</a>', sep = '') #create link to each single fly evaluation HTML document to be used in project evaluation
} #for number of flies in xml_list } #for number of flies in xml_list
exp_groups[[x]] <- c(grp_title, grp_description, xml_list) #add name and description and file links to dataframe to be used in project evaluation document
########### plot graphs for all experiments ##################### ########### plot graphs for all experiments #####################
##pool all data except "optomotor" by period ##pool all data except "optomotor" by period
...@@ -164,11 +183,50 @@ if(MultiFlyDataVerification(xml_list)==TRUE) # make sure all flies in a group ha ...@@ -164,11 +183,50 @@ if(MultiFlyDataVerification(xml_list)==TRUE) # make sure all flies in a group ha
} }
## pool all torque/platform and position data into single data.frame ## pool all torque/platform and position data into single data.frame
for (n in 1:length(grouped.data.periodsL)) {
grouped.data.flyL[[n]] <- grouped.data.periodsL[[n]][[1]]$fly
grouped.data.flyR[[n]] <- grouped.data.periodsR[[n]][[1]]$fly
}
## make final data frames for plotting
#for histogram with all fly data
all.data <- do.call(rbind, pooled.data)
if (sequence$type[1]=="OptomotoL"||sequence$type[1]=="OptomotoR") {
#for histogram with all fly data sorted by left turning arena
all.data.periodsL <- data.frame(unlist(grouped.data.flyL))
names(all.data.periodsL) <- "fly"
all.data <- do.call(rbind, pooled.data) #for histogram with all fly data sorted by right turning arena
all.data.periodsL <- data.frame(grouped.data.periodsL[[l]]) all.data.periodsR <- data.frame(unlist(grouped.data.flyR))
all.data.periodsR <- data.frame(grouped.data.periodsR[[l]]) names(all.data.periodsR) <- "fly"
#for multiple traces graph with mean trace of each period in left/right
#fit "flytraces" list for the "data.frame()" function
flytracesL <- lapply(flytracesL, function(x) {
length(x) <- min(lengths(flytracesL)); x})
flytracesR <- lapply(flytracesR, function(x) {
length(x) <- min(lengths(flytracesR)); x})
#create data frame for pooled traces plot
fly <- unlist(flytracesL)
period <- rep(c(1:length(flytracesL)), each=length(flytracesL[[1]]))
time <- rep(seq(0, (length(flytracesL[[1]])-1)*10, by=10), times=length(flytracesL))
all.data.periodL <- data.frame(fly, period, time)
#create data frame for pooled traces plot
fly <- unlist(flytracesR)
period <- rep(c(1:length(flytracesR)), each=length(flytracesR[[1]]))
time <- rep(seq(0, (length(flytracesR[[1]])-1)*10, by=10), times=length(flytracesR))
all.data.periodR <- data.frame(fly, period, time)
#for mean traces graph of all left/right periods
all.data.flytracesL <- rowMeans(data.frame(flytracesL))
all.data.flytracesL <- data.frame(all.data.flytracesL, seq(0, (length(all.data.flytracesL)-1)*10, by=10))
names(all.data.flytracesL) <- c("fly", "time")
all.data.flytracesR <- rowMeans(data.frame(flytracesR))
all.data.flytracesR <- data.frame(all.data.flytracesR, seq(0, (length(all.data.flytracesR)-1)*10, by=10))
names(all.data.flytracesR) <- c("fly", "time")
}
## plot pooled histograms for all flies over all periods ## plot pooled histograms for all flies over all periods
if(sequence$type[1]=="fs"||sequence$type[1]=="color"||sequence$type[1]=="optomotor") { if(sequence$type[1]=="fs"||sequence$type[1]=="color"||sequence$type[1]=="optomotor") {
...@@ -193,17 +251,42 @@ if(MultiFlyDataVerification(xml_list)==TRUE) # make sure all flies in a group ha ...@@ -193,17 +251,42 @@ if(MultiFlyDataVerification(xml_list)==TRUE) # make sure all flies in a group ha
xlim(-5,2) + xlim(-5,2) +
ggtitle("Pooled P_Pos Histogram") ggtitle("Pooled P_Pos Histogram")
flyhistos[[NofPeriods+2]] <- ggplot(data=all.data.periodsL, aes_string(all.data.periodsL$optomotoL_flydata)) + flyhistos[[NofPeriods+2]] <- ggplot(data=all.data.periodsL, aes_string(all.data.periodsL$fly)) +
geom_histogram(binwidth=0.0175) + geom_histogram(binwidth=0.0175) +
labs(x="fly [arb units]", y="frequency") + labs(x="fly [arb units]", y="frequency") +
xlim(-5,2) + xlim(-5,2) +
ggtitle("Pooled P_Pos Histogram\n(left turning arena)") ggtitle("Pooled P_Pos Histogram\n(left turning arena)")
flyhistos[[NofPeriods+3]] <- ggplot(data=all.data.periodsR, aes_string(all.data.periodsR$optomotoR_flydata)) + flyhistos[[NofPeriods+3]] <- ggplot(data=all.data.periodsR, aes_string(all.data.periodsR$fly)) +
geom_histogram(binwidth=0.0175) + geom_histogram(binwidth=0.0175) +
labs(x="fly [arb units]", y="frequency") + labs(x="fly [arb units]", y="frequency") +
xlim(-5,2) + xlim(-5,2) +
ggtitle("Pooled P_Pos Histogram\n(right turning arena)") ggtitle("Pooled P_Pos Histogram\n(right turning arena)")
flytraces[[1]] <- ggplot(data=all.data.periodL, aes_string(y = all.data.periodL$fly, x = all.data.periodL$time, colour = all.data.periodL$period)) +
geom_line(aes_string(group = all.data.periodL$period)) +
scale_color_gradientn(colours=rainbow(4)) +
geom_smooth() +
labs(x="time (ms)", y="fly") +
ggtitle("Multi Traces\n(left turning arena)")
flytraces[[2]] <- ggplot(data=all.data.periodR, aes_string(y = all.data.periodR$fly, x = all.data.periodR$time, colour = all.data.periodR$period)) +
geom_line(aes_string(group = all.data.periodR$period)) +
scale_color_gradientn(colours=rainbow(4)) +
geom_smooth() +
labs(x="time (ms)", y="fly") +
ggtitle("Multi Traces\n(right turning arena)")
flytraces[[3]] <- ggplot(data=all.data.flytracesL, aes_string(x=all.data.flytracesL$time, y=all.data.flytracesL$fly)) +
geom_line() +
ggtitle("Pooled traces\n(left turning arena)") +
labs(x="time(ms)", y="fly")
flytraces[[4]] <- ggplot(data=all.data.flytracesR, aes_string(x=all.data.flytracesR$time, y=all.data.flytracesR$fly)) +
geom_line() +
ggtitle("Pooled traces\n(right turning arena)") +
labs(x="time(ms)", y="fly")
} }
} else {print("You have selected files with differing metadata")} } else {print("You have selected files with differing metadata")}
...@@ -220,11 +303,8 @@ trqhistos <- list() #empty torque histograms ...@@ -220,11 +303,8 @@ trqhistos <- list() #empty torque histograms
#Platform Histograms #Platform Histograms
grouped.flyhistos[[x]] = flyhistos #add platform histograms to list of grouped p_position histograms grouped.flyhistos[[x]] = flyhistos #add platform histograms to list of grouped p_position histograms
flyhistos <- list() #empty list of p_position histograms flyhistos <- list() #empty list of p_position histograms
# grouped.flyhistosL[[x]] = flyhistosL #add platform histograms to list of grouped p_position histograms for left turning arena grouped.flytraces[[x]] <- flytraces #add platform traces to list of grouped p_position traces
# flyhistosL <- list() flytraces <- list() #empty list of p_position traces
# grouped.flyhistosR[[x]] = flyhistosR #add platform histograms to list of grouped p_position histograms for right turning arena
# flyhistosR <- list()
#Position Histograms #Position Histograms
grouped.poshistos[[x]] = poshistos #add torque histograms to list of grouped position histograms grouped.poshistos[[x]] = poshistos #add torque histograms to list of grouped position histograms
......
...@@ -30,7 +30,7 @@ source("readXMLdatafile.R") ...@@ -30,7 +30,7 @@ source("readXMLdatafile.R")
source("DTS_plotfunctions.R") source("DTS_plotfunctions.R")
``` ```
<center><h1><i>Drosophila</i> Time Series Project Data Evaluation Sheet</h1></center> <center><h1><i>Drosophila</i> Time Series Project Evaluation Sheet</h1></center>
<center><h2>for time series data set: "<b>`r paste(project.data$title)`</b>"</h2></center> <center><h2>for time series data set: "<b>`r paste(project.data$title)`</b>"</h2></center>
### 1. Metadata: ### 1. Metadata:
...@@ -55,7 +55,19 @@ type_no_platform <- isFALSE(sequence$type[1] == "OptomotoL" | sequence$type[1] = ...@@ -55,7 +55,19 @@ type_no_platform <- isFALSE(sequence$type[1] == "OptomotoL" | sequence$type[1] =
type_is_platform <- isTRUE(sequence$type[1] == "OptomotoL" | sequence$type[1] == "OptomotoR") type_is_platform <- isTRUE(sequence$type[1] == "OptomotoL" | sequence$type[1] == "OptomotoR")
``` ```
### 3. Torque Histograms: ### 3. Experimental groups and single fly evaluations:
**Number of experimental groups:** `r paste(NofGroups)`
```{r singleflydata, eval=TRUE, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE}
exp_groups <- as.data.frame(t(plyr::ldply(exp_groups, rbind))) #make dataframe from list
colnames(exp_groups) <- as.character(unlist(exp_groups[1,])) # make group names to column names
#tidy the dataframe up a little
exp_groups = exp_groups[-1,]
rownames(exp_groups) <- NULL
kable(exp_groups) #plot table with links to individual fly evaluations
```
### 4. Torque Histograms:
```{r TorqueHistograms, eval=type_no_platform, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 12, fig.width = 8, comment=NA, results='asis'} ```{r TorqueHistograms, eval=type_no_platform, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 12, fig.width = 8, comment=NA, results='asis'}
for(x in 1:NofGroups) for(x in 1:NofGroups)
...@@ -66,7 +78,7 @@ type_is_platform <- isTRUE(sequence$type[1] == "OptomotoL" | sequence$type[1] == ...@@ -66,7 +78,7 @@ type_is_platform <- isTRUE(sequence$type[1] == "OptomotoL" | sequence$type[1] ==
} }
``` ```
### 3. Platform Histograms: ### 4. Platform Histograms and Pooled Traces:
```{r PlatformHistogram, eval=type_is_platform, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 12, fig.width = 8, comment=NA, results='asis'} ```{r PlatformHistogram, eval=type_is_platform, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 12, fig.width = 8, comment=NA, results='asis'}
for(x in 1:NofGroups) for(x in 1:NofGroups)
...@@ -74,18 +86,13 @@ type_is_platform <- isTRUE(sequence$type[1] == "OptomotoL" | sequence$type[1] == ...@@ -74,18 +86,13 @@ type_is_platform <- isTRUE(sequence$type[1] == "OptomotoL" | sequence$type[1] ==
cat("<center><h4>",project.data[["resources"]][[x]][["title"]],"</h4></center>") cat("<center><h4>",project.data[["resources"]][[x]][["title"]],"</h4></center>")
flyhistos <- grouped.flyhistos[[x]] flyhistos <- grouped.flyhistos[[x]]
multiplot(plotlist = flyhistos, cols=4) multiplot(plotlist = flyhistos, cols=4)
#
# cat("<center><h4>",project.data[["resources"]][[x]][["title"]],"</h4></center>") flytraces <- grouped.flytraces[[x]]
# flyhistosL <- grouped.flyhistosL[[x]] multiplot(plotlist = flytraces, cols = 2)
# multiplot(plotlist = flyhistosL, cols=4)
#
# cat("<center><h4>",project.data[["resources"]][[x]][["title"]],"</h4></center>")
# flyhistosR <- grouped.flyhistosR[[x]]
# multiplot(plotlist = flyhistosR, cols=4)
} }
``` ```
### 4. Position Histograms: ### 5. Position Histograms:
```{r PositionHistogram, eval=type_no_platform, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 12, fig.width = 8, comment=NA, results='asis'} ```{r PositionHistogram, eval=type_no_platform, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 12, fig.width = 8, comment=NA, results='asis'}
for(x in 1:NofGroups) for(x in 1:NofGroups)
...@@ -96,7 +103,7 @@ type_is_platform <- isTRUE(sequence$type[1] == "OptomotoL" | sequence$type[1] == ...@@ -96,7 +103,7 @@ type_is_platform <- isTRUE(sequence$type[1] == "OptomotoL" | sequence$type[1] ==
} }
``` ```
### 5. Fourier Spectrum Analysis ### 6. Fourier Spectrum Analysis
```{r spectra, eval=TRUE, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 6, fig.width = 8} ```{r spectra, eval=TRUE, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 6, fig.width = 8}
spectemp <- do.call("rbind", grouped.spectra) #create single data.frame with grouping variable from list of groups spectemp <- do.call("rbind", grouped.spectra) #create single data.frame with grouping variable from list of groups
...@@ -124,7 +131,7 @@ print(ggplot(spectemp, aes(x=freq, y=mean, group = group)) + ...@@ -124,7 +131,7 @@ print(ggplot(spectemp, aes(x=freq, y=mean, group = group)) +
``` ```
### 6. Performance Index bar plot with SEM: ### 7. Performance Index bar plot with SEM:
```{r PIbar, eval=type_no_platform, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 8, fig.width = 8} ```{r PIbar, eval=type_no_platform, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 8, fig.width = 8}
PIplots <- list() PIplots <- list()
...@@ -156,7 +163,7 @@ for(x in 1:NofGroups) ...@@ -156,7 +163,7 @@ for(x in 1:NofGroups)
grid.arrange(grobs = PIplots, nrow=NofGroups) grid.arrange(grobs = PIplots, nrow=NofGroups)
``` ```
### 7. Performance Index box&dotplot with notches: ### 8. Performance Index box&dotplot with notches:
```{r BoxWithNotch, eval=type_no_platform, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 8, fig.width = 8}