Skip to content
Snippets Groups Projects
Commit efaf4a36 authored by Xianzong Meng's avatar Xianzong Meng
Browse files

add ggsave function to figs

parent 55640253
No related branches found
No related tags found
No related merge requests found
......@@ -222,13 +222,15 @@ anova(ESPND140,ESPND140_sex)
```{r}
p_SD_foraging <- ggplot(df.SD_Rday1, aes(x=trials, y=foraging.score, group=age, colour=age))
colors <- c("#c6c7c9", "#d15034", "#0c0d0f", "#f1ae2d")
p_SD_foraging +
Fig_SD_foraging<- p_SD_foraging +
stat_summary(fun = "mean", size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se, geom = "errorbar", alpha=1, width=0.05, aes(colour = age, fill = age))+
scale_color_manual(values = colors)+
scale_y_continuous(breaks = seq(0, 7, by = 1))+
#facet_wrap(~ age, ncol = 2)
geom_jitter(alpha = 0.5,width = 0.1) + labs(x = "positions", y = "foraging score") + theme_minimal()
Fig_SD_foraging
ggsave('C:/Users/xiamen/Desktop/modified robogator/result figs/SD_foraging.svg', plot = Fig_SD_foraging, device = 'svg',dpi = 300)
```
## SD rat, success rate
......@@ -365,81 +367,93 @@ anova(ESrestriction60,ESrestriction60_sex)
```{r}
p_LE_foraging <- ggplot(df.LE_Rday1, aes(x=trials, y=foraging.score, group=restriction, colour=restriction))
colors <- c("#c6c7c9", "#d15034", "#0c0d0f", "#f1ae2d")
p_LE_foraging +
Fig_LE_restriction_foraging <- p_LE_foraging +
stat_summary(fun = "mean", size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se, geom = "errorbar", alpha=1, width=0.05, aes(colour = restriction, fill = restriction))+
scale_color_manual(values = colors)+
scale_y_continuous(breaks = seq(0, 7, by = 1))+
#facet_wrap(~ age, ncol = 2)
geom_jitter(alpha = 0.5,width = 0.1) + labs(x = "positions", y = "foraging score") + theme_minimal()
Fig_LE_restriction_foraging
ggsave('C:/Users/xiamen/Desktop/modified robogator/result figs/LE_restriction_foraging.svg', plot = Fig_LE_restriction_foraging, device = 'svg',dpi = 300)
```
##plot_sex effect
#PND70
```{r}
EFsex_age_70 <- ggplot(PND70, aes(x=trials, y=foraging.score, group=sex, colour=sex))
colors <- c("#c6c7c9", "#d15034", "#0c0d0f", "#f1ae2d")
EFsex_age_70 +
Fig_SD_sex_age_70 <- EFsex_age_70 +
stat_summary(fun = "mean", size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se, geom = "errorbar", alpha=1, width=0.05, aes(colour = age, fill = age))+
scale_color_manual(values = colors)+
scale_y_continuous(breaks = seq(0, 7, by = 1))+
#facet_wrap(~ age, ncol = 2)
geom_jitter(alpha = 0.5,width = 0.1) + labs(x = "positions", y = "foraging score") + theme_minimal()
Fig_SD_sex_age_70
ggsave('C:/Users/xiamen/Desktop/modified robogator/result figs/Fig_SD_sex_age_70.svg', plot = Fig_SD_sex_age_70, device = 'svg',dpi = 300)
```
#PND140
```{r}
EFsex_age_140 <- ggplot(PND140, aes(x=trials, y=foraging.score, group=sex, colour=sex))
colors <- c("#c6c7c9", "#d15034", "#0c0d0f", "#f1ae2d")
EFsex_age_140 +
Fig_SD_sex_age_140 <- EFsex_age_140 +
stat_summary(fun = "mean", size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se, geom = "errorbar", alpha=1, width=0.05, aes(colour = age, fill = age))+
scale_color_manual(values = colors)+
scale_y_continuous(breaks = seq(0, 7, by = 1))+
#facet_wrap(~ age, ncol = 2)
geom_jitter(alpha = 0.5,width = 0.1) + labs(x = "positions", y = "foraging score") + theme_minimal()
Fig_SD_sex_age_140
ggsave('C:/Users/xiamen/Desktop/modified robogator/result figs/Fig_SD_sex_age_140.svg', plot = Fig_SD_sex_age_140, device = 'svg',dpi = 300)
```
#45% restriction
```{r}
EFsex_restriction_45 <- ggplot(restriction45, aes(x=trials, y=foraging.score, group=sex, colour=sex))
colors <- c("#c6c7c9", "#d15034", "#0c0d0f", "#f1ae2d")
EFsex_restriction_45 +
Fig_LE_sex_restriction_45 <- EFsex_restriction_45 +
stat_summary(fun = "mean", size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se, geom = "errorbar", alpha=1, width=0.05, aes(colour = age, fill = age))+
scale_color_manual(values = colors)+
scale_y_continuous(breaks = seq(0, 7, by = 1))+
#facet_wrap(~ age, ncol = 2)
geom_jitter(alpha = 0.5,width = 0.1) + labs(x = "positions", y = "foraging score") + theme_minimal()
Fig_LE_sex_restriction_45
ggsave('C:/Users/xiamen/Desktop/modified robogator/result figs/Fig_LE_sex_restriction_45.svg', plot = Fig_LE_sex_restriction_45, device = 'svg',dpi = 300)
```
#60% restriction
```{r}
EFsex_restriction_60 <- ggplot(restriction60, aes(x=trials, y=foraging.score, group=sex, colour=sex))
colors <- c("#c6c7c9", "#d15034", "#0c0d0f", "#f1ae2d")
EFsex_restriction_60 +
Fig_LE_sex_restriction_60 <- EFsex_restriction_60 +
stat_summary(fun = "mean", size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se, geom = "errorbar", alpha=1, width=0.05, aes(colour = age, fill = age))+
scale_color_manual(values = colors)+
scale_y_continuous(breaks = seq(0, 7, by = 1))+
#facet_wrap(~ age, ncol = 2)
geom_jitter(alpha = 0.5,width = 0.1) + labs(x = "positions", y = "foraging score") + theme_minimal()
Fig_LE_sex_restriction_60
ggsave('C:/Users/xiamen/Desktop/modified robogator/result figs/Fig_LE_sex_restriction_60.svg', plot = Fig_LE_sex_restriction_60, device = 'svg',dpi = 300)
```
##general sex effect
```{r}
p_LE_foraging <- ggplot(df.LE_Rday1, aes(x=trials, y=foraging.score, group=sex, colour=sex))
colors <- c("#c6c7c9", "#d15034", "#0c0d0f", "#f1ae2d")
p_LE_foraging +
colors <- c("#d15034", "#0c0d0f", "#c6c7c9", "#f1ae2d")
Fig_LE_sex_general <- p_LE_foraging +
stat_summary(fun = "mean", size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se, geom = "errorbar", alpha=1, width=0.05, aes(colour = sex, fill = sex))+
scale_color_manual(values = colors)+
scale_y_continuous(breaks = seq(0, 7, by = 1))+
#facet_wrap(~ age, ncol = 2)
geom_jitter(alpha = 0.5,width = 0.1) + labs(x = "positions", y = "foraging score") + theme_minimal()
Fig_LE_sex_general
ggsave('C:/Users/xiamen/Desktop/modified robogator/result figs/Fig_LE_sex_general.svg', plot = Fig_LE_sex_general, device = 'svg',dpi = 300)
```
##Blineday6 sex effect plot
```{r}
df.LE_Bday6 <- df %>% filter(df$baseline.day == 6, df$group == "LE")
EFsex_blinedays <- ggplot(df.LE_Bday6, aes(x=trials, y=foraging.score, group=sex, colour=sex))
colors <- c("#c6c7c9", "#d15034", "#0c0d0f", "#f1ae2d")
EFsex_blinedays +
colors <- c("#d15034", "#0c0d0f", "#c6c7c9", "#f1ae2d")
Fig_LE_sex_blineday6_general <- EFsex_blinedays +
stat_summary(fun = "mean", size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se, geom = "errorbar", alpha=1, width=0.05, aes(colour = sex, fill = sex))+
scale_color_manual(values = colors)+
......@@ -449,6 +463,9 @@ geom_jitter(alpha = 0.5,width = 0.1) + labs(x = "positions", y = "foraging score
LE_Bday6 <- lmer(foraging.score~ sex + trials + sex:trials + (1|rat_ID),df.LE_Bday6)
eta_squared(LE_Bday6)
Fig_LE_sex_blineday6_general
ggsave('C:/Users/xiamen/Desktop/modified robogator/result figs/Fig_LE_sex_blineday6_general.svg', plot = Fig_LE_sex_blineday6_general, device = 'svg',dpi = 300)
```
## LE rat, success rate
......@@ -506,11 +523,13 @@ eta_squared(mod.score_LE_60_leaving)
```
## leaving figure
```{r}
LE_Rday1_leaving <- ggplot(df.LE_Rday1, aes(x=trials, y=leaving.score, group=restriction, colour=restriction, shape=sex))
LE_Rday1_leaving <- ggplot(df.LE_Rday1, aes(x=trials, y=leaving.score, group=restriction, colour=restriction))
colors <- c("#c6c7c9", "#d15034", "#0c0d0f", "#f1ae2d")
LE_Rday1_leaving + stat_summary(fun = "mean", size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd')+
Fig_LE_leaving <- LE_Rday1_leaving + stat_summary(fun = "mean", size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd')+
stat_summary(fun.data = mean_se, geom = "errorbar", alpha=1, width=0.05, aes(colour = restriction, fill = restriction))+ scale_color_manual(values = colors)+ scale_y_continuous(breaks = seq(0, 7, by = 1))+
geom_jitter(alpha = 0.5,width = 0.1)+ labs(x = "positions", y = "leaving score") + theme_minimal()
Fig_LE_leaving
ggsave('C:/Users/xiamen/Desktop/modified robogator/result figs/Fig_LE_leaving.svg', plot = Fig_LE_leaving, device = 'svg',dpi = 300)
```
## approaching
......@@ -540,17 +559,19 @@ approaching_emm_trials_sex
## approaching figure_restriction
```{r}
LE_Rday1_approaching <- ggplot(df.LE_Rday1, aes(x=trials, y=approaching.score, group=restriction, colour=restriction, shape=sex))
LE_Rday1_approaching <- ggplot(df.LE_Rday1, aes(x=trials, y=approaching.score, group=restriction, colour=restriction))
colors <- c("#c6c7c9", "#d15034", "#0c0d0f", "#f1ae2d")
LE_Rday1_approaching + stat_summary(fun = "mean", size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd')+
Fig_LE_approaching <- LE_Rday1_approaching + stat_summary(fun = "mean", size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd')+
stat_summary(fun.data = mean_se, geom = "errorbar", alpha=1, width=0.05, aes(colour = restriction, fill = restriction))+
scale_color_manual(values = colors)+
scale_y_continuous(breaks = seq(0, 7, by = 1))+
geom_jitter(alpha = 1,width = 0.1)+theme_minimal()
Fig_LE_approaching
ggsave('C:/Users/xiamen/Desktop/modified robogator/result figs/Fig_LE_approaching.svg', plot = Fig_LE_approaching, device = 'svg',dpi = 300)
```
## approaching figure_sex
## approaching figure_restriction_sex
```{r}
LE_Rday1_approaching <- ggplot(df.LE_Rday1, aes(x=trials, y=approaching.score, group=sex, colour=sex, shape=sex))
LE_Rday1_approaching <- ggplot(restriction45, aes(x=trials, y=approaching.score, group=sex, colour=sex, shape=sex))
colors <- c("#c6c7c9", "#d15034", "#0c0d0f", "#f1ae2d")
LE_Rday1_approaching + stat_summary(fun = "mean", size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd')+
stat_summary(fun.data = mean_se, geom = "errorbar", alpha=1, width=0.05, aes(colour = sex, fill = sex))+
......@@ -575,10 +596,24 @@ eta_squared(mod.score_LE_45_backing)
mod.score_LE_60_backing<- lmer(backing.score~ + sex + trials + sex:trials + (1|rat_ID), df.LE_Rday1_60)
eta_squared(mod.score_LE_60_backing)
```
## backing figure
## backing figure_restriction
```{r}
LE_Rday1_backing <- ggplot(df.LE_Rday1, aes(x=food.distance.cm, y=backing.score, group=restriction, colour=restriction, shape=sex))
LE_Rday1_backing + stat_summary(fun = "mean", colour = "darkgrey", size = 0.5, geom = "line", fun.min = 'sd', fun.max = 'sd')+
stat_summary(fun.data = mean_se, geom = "ribbon", alpha=0.3, aes(colour = restriction, fill = restriction))+
geom_jitter(alpha = 1,width = 0.1)+theme_minimal()
LE_Rday1_backing <- ggplot(df.LE_Rday1, aes(x=trials, y=backing.score, group=restriction, colour=restriction))
colors <- c("#c6c7c9", "#d15034", "#0c0d0f", "#f1ae2d")
LE_Rday1_backing + stat_summary(fun = "mean", size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd')+
stat_summary(fun.data = mean_se, geom = "errorbar", alpha=1, width=0.05, aes(colour = sex, fill = sex))+
scale_color_manual(values = colors)+
scale_y_continuous(breaks = seq(0, 7, by = 1))+
geom_jitter(alpha = 1,width = 0.1)+theme_minimal()
```
## backing figure_restriction_sex
```{r}
LE_Rday1_backing_restriction_sex <- ggplot(restriction60, aes(x=trials, y=backing.score, group=sex, colour=sex))
colors <- c("#c6c7c9", "#d15034", "#0c0d0f", "#f1ae2d")
LE_Rday1_backing_restriction_sex + stat_summary(fun = "mean", size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd')+
stat_summary(fun.data = mean_se, geom = "errorbar", alpha=1, width=0.05, aes(colour = sex, fill = sex))+
scale_color_manual(values = colors)+
scale_y_continuous(breaks = seq(0, 7, by = 1))+
geom_jitter(alpha = 1,width = 0.1)+theme_minimal()
```
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment