---
title: "Figure 4 Analysis"
output: html_notebook
---


```{r}
library(tidyverse)
library(lme4)
library(lmerTest)
library(readxl)
setwd("D:/Labs/Levkowitz/Mikey/")
fig4 <- read_excel("Fig4_FusionFRAP_individualsynapses_Formatted_Ron.xlsx")
fig4$synapse.ID <- gsub("'", "", fig4$synapse.ID)
fig4$synapse.ID <- gsub(".txt", "", fig4$synapse.ID)
fig4$fish.ID <- as.factor(fig4$fish.ID)
fig4$genotype <- factor(fig4$genotype, levels=unique(fig4$genotype))
ggplot(data=fig4, aes(x=time, y=fluorescence)) +
  geom_point(alpha=0.1) +
  geom_smooth(aes(group=synapse.ID, color=genotype), se=FALSE)
```
```{r}
ggplot(data=fig4, aes(x=time, y=fluorescence)) +
  geom_point(alpha=0.1) +
  geom_smooth(aes(group=synapse.ID, color=genotype), se=FALSE, method="lm")

m1.intercept <- lmer(fluorescence ~ genotype * time + (1|synapse.ID) + (1|fish.ID), 
                     data=fig4)
summary(m1.intercept)
```
# Effect size for time>250
```{r}
effsize::cohen.d(fluorescence~genotype, data=filter(fig4, time>250))
```