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 4ce3bd53 authored by Maximilian von der Linde's avatar Maximilian von der Linde Committed by GitHub
Browse files

Merge pull request #6 from brembslab/InfiniteWhite-patch-3.1

Update of HTML_DTS_project.R adaptation
parents a80f8ce1 33d8f084
......@@ -54,6 +54,8 @@ xml_list = paste(project.path, project.data[["resources"]][[x]][["data"]], sep =
#create/empty lists for collecting all single fly data by period
period.data <- list() #data grouped by period
grouped.data <- list() #total data grouped
grouped.data.periodsL <- list() #total data grouped by left or right turning arena for platform
grouped.data.periodsR <- list()
speclist <- list()
#start evaluating
......@@ -91,7 +93,9 @@ if(MultiFlyDataVerification(xml_list)==TRUE) # make sure all flies in a group ha
#vectors for pooled platform periods
optomotoL_flydata <- c()
optomotoR_flydata <- c()
flyhistosL.rawdata <- list()
flyhistosR.rawdata <- list()
#### call RMarkdown for single fly evaluations ################################################
single_fly_path <- paste(start.wd, "single_fly.Rmd", sep = "/")
rmarkdown::render(single_fly_path,
......@@ -106,7 +110,8 @@ if(MultiFlyDataVerification(xml_list)==TRUE) # make sure all flies in a group ha
##add period data to grouped data
grouped.data[[l]] <- period.data
grouped.data.periodsL[[l]] <- list(periodL)
grouped.data.periodsR[[l]] <- list(periodR)
} #for number of flies in xml_list
......@@ -161,6 +166,8 @@ if(MultiFlyDataVerification(xml_list)==TRUE) # make sure all flies in a group ha
## pool all torque/platform and position data into single data.frame
all.data <- do.call(rbind, pooled.data)
all.data.periodsL <- data.frame(grouped.data.periodsL[[l]])
all.data.periodsR <- data.frame(grouped.data.periodsR[[l]])
## plot pooled histograms for all flies over all periods
......@@ -184,7 +191,19 @@ if(MultiFlyDataVerification(xml_list)==TRUE) # make sure all flies in a group ha
geom_histogram(binwidth=0.0175) +
labs(x="fly [arb units]", y="frequency") +
xlim(-5,2) +
ggtitle("Pooled Platform Position Histogram")
ggtitle("Pooled P_Pos Histogram")
flyhistos[[NofPeriods+2]] <- ggplot(data=all.data.periodsL, aes_string(all.data.periodsL$optomotoL_flydata)) +
geom_histogram(binwidth=0.0175) +
labs(x="fly [arb units]", y="frequency") +
xlim(-5,2) +
ggtitle("Pooled P_Pos Histogram\n(left turning arena)")
flyhistos[[NofPeriods+3]] <- ggplot(data=all.data.periodsR, aes_string(all.data.periodsR$optomotoR_flydata)) +
geom_histogram(binwidth=0.0175) +
labs(x="fly [arb units]", y="frequency") +
xlim(-5,2) +
ggtitle("Pooled P_Pos Histogram\n(right turning arena)")
}
} else {print("You have selected files with differing metadata")}
......@@ -201,10 +220,11 @@ trqhistos <- list() #empty torque histograms
#Platform Histograms
grouped.flyhistos[[x]] = flyhistos #add platform histograms to list of grouped 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
flyhistosL <- list()
grouped.flyhistosR[[x]] = flyhistosR #add platform histograms to list of grouped p_position histograms for right turning arena
flyhistosR <- list()
# grouped.flyhistosL[[x]] = flyhistosL #add platform histograms to list of grouped p_position histograms for left turning arena
# flyhistosL <- list()
# grouped.flyhistosR[[x]] = flyhistosR #add platform histograms to list of grouped p_position histograms for right turning arena
# flyhistosR <- list()
#Position Histograms
grouped.poshistos[[x]] = poshistos #add torque histograms to list of grouped position histograms
......
......@@ -40,12 +40,13 @@ source("DTS_plotfunctions.R")
**Experiment duration:** `r paste(seconds_to_period(as.numeric(as.character(experiment$duration))))`
### 2. Experimental Design:
```{r expdesign, eval=TRUE, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 3, fig.width = 9}
```{r expdesign, eval=TRUE, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 10, fig.width = 9}
#Write table of period design
periods <- periods[-6,]
periods[3,periods["outcome",]==0]="test"
periods[3,periods["outcome",]==1]="training"
grid.table(periods)
transposed_periods <- t(periods)
grid.table(transposed_periods)
```
```{r typePrep, echo=FALSE}
......@@ -67,7 +68,7 @@ type_is_platform <- isTRUE(sequence$type[1] == "OptomotoL" | sequence$type[1] ==
### 3. Platform Histograms:
```{r TorqueHistogram, 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)
{
cat("<center><h4>",project.data[["resources"]][[x]][["title"]],"</h4></center>")
......
......@@ -42,18 +42,20 @@ source("DTS_plotfunctions.R")
**Fly description:** `r paste(fly$description)`; **FlyBase ID:** [`r paste(fly$flybase)`](http://flybase.org/reports/`r paste(fly$flybase)`)
### 2. Experimental Design:
```{r expdesign, eval=TRUE, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 3, fig.width = 9}
```{r expdesign, eval=TRUE, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 10, fig.width = 9}
#plot table of period sequence
periods=t(sequence)
# check if number of periods in metadata is true
#check if number of periods in metadata is true
if (ncol(periods) != NofPeriods) {
NofPeriods = ncol(periods)
print("sequence$type metadata faulty, function will still be working correctly")
}
colnames(periods)<-sprintf("Period %s",1:NofPeriods)
grid.table(periods)
#transpose the table so that it doesn't go out of the boudaries
transposed_periods <- t(periods)
grid.table(transposed_periods)
```
### 3. Interactive Time Traces:
......@@ -72,6 +74,10 @@ source("DTS_plotfunctions.R")
```{r PeriodTraces, eval=TRUE, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, fig.align = "center", fig.height = 6, fig.width = 10}
#variables needed for platform function
countL = 1
countR = 1
for(i in 1:NofPeriods){
#save colors for later plotting
......@@ -98,19 +104,21 @@ source("DTS_plotfunctions.R")
#platform (distinguish between OptomotoR and OptomotoL)
if (sequence$type[i] == "OptomotoR") {
flyhistosR[[length(flyhistosR)+1]] <- ggplot(data=temp, aes_string(temp$fly)) +
flyhistosR[[countR]] <- ggplot(data=temp, aes_string(temp$fly)) +
geom_histogram(binwidth = 0.0175, fill = sequence$histocolor[i]) +
labs(x="fly [arb units]", y="frequency") +
xlim(-3.2, 0) +
ggtitle(paste(flyname, "Period", i, "OptomotoR"))
optomotoR_flydata <- c(optomotoR_flydata, period.data[[i]]["fly"], recursive = TRUE, use.names = FALSE)
countR = countR+1
} else if (sequence$type[i] == "OptomotoL") {
flyhistosL[[length(flyhistosL)+1]] <- ggplot(data=temp, aes_string(temp$fly)) +
flyhistosL[[countL]] <- ggplot(data=temp, aes_string(temp$fly)) +
geom_histogram(binwidth = 0.0175, fill = sequence$histocolor[i]) +
labs(x="fly [arb units]", y="frequency") +
xlim(-3.2, 0) +
ggtitle(paste(flyname, "Period", i, "OptomotoL"))
optomotoL_flydata <- c(optomotoL_flydata, period.data[[i]]["fly"], recursive = TRUE, use.names = FALSE)
countL = countL+1
}
#torque
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment