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

change geom_jitter to facet_wrap to beautify the figs

parent 39990cd2
No related branches found
No related tags found
No related merge requests found
......@@ -220,15 +220,15 @@ anova(ESPND140,ESPND140_sex)
##plot
```{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 <- ggplot(df.SD_Rday1, aes(x=trials, y=foraging.score, group=rat_ID))
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)+
geom_line(color="gray", alpha=0.2)+
stat_summary(fun = "mean", aes(group = age, color= age), size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se, aes(group=age, color = age), geom = "errorbar", alpha=1, width=0.05)+
scale_color_manual(values = c("#7fc97f", "#fdc086"))+
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()
labs(x = "positions", y = "foraging score") + theme_minimal() + facet_wrap(~ age, ncol = 2)
Fig_SD_foraging
ggsave('C:/Users/xiamen/Desktop/modified robogator/result figs/SD_foraging.svg', plot = Fig_SD_foraging, device = 'svg',dpi = 300)
```
......@@ -365,101 +365,102 @@ anova(ESrestriction60,ESrestriction60_sex)
##plot-restriction
```{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 <- ggplot(df.LE_Rday1, aes(x=trials, y=foraging.score, group=rat_ID))
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)+
geom_line(color="gray", alpha=0.2)+
stat_summary(fun = "mean", aes(group = restriction, color= restriction), size = 1, geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se, aes(group=restriction, color = restriction), geom = "errorbar", alpha=1, width=0.05)+
scale_color_manual(values = c("#7fc97f", "#fdc086"))+
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()
labs(x = "positions", y = "foraging score") + theme_minimal() + facet_wrap(~restriction, ncol = 2)
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 <- ggplot(PND70, aes(x=trials, y=foraging.score, group=rat_ID))
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)+
geom_line(color="gray", alpha=0.2)+
stat_summary(fun = "mean", size = 1, aes(group = sex, color= sex), geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se, geom = "errorbar", aes(group=sex, color = sex), alpha=1, width=0.05)+
scale_color_manual(values = c("#7fc97f", "#fdc086"))+
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()
labs(x = "positions", y = "foraging score") + theme_minimal() + facet_wrap(~ sex, ncol = 2)
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 <- ggplot(PND140, aes(x=trials, y=foraging.score, group=rat_ID))
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)+
geom_line(color="gray", alpha=0.2)+
stat_summary(fun = "mean", size = 1,aes(group = sex, color= sex),geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se,aes(group = sex, color= sex),geom = "errorbar", alpha=1, width=0.05)+
scale_color_manual(values = c("#7fc97f", "#fdc086"))+
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()
labs(x = "positions", y = "foraging score") + theme_minimal() + facet_wrap(~ sex, ncol = 2)
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 <- ggplot(restriction45, aes(x=trials, y=foraging.score, group=rat_ID))
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)+
geom_line(color="gray", alpha=0.2)+
stat_summary(fun = "mean", size = 1, aes(group = sex, color= sex),geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se, aes(group = sex, color= sex),geom = "errorbar", alpha=1, width=0.05)+
scale_color_manual(values = c("#7fc97f", "#fdc086"))+
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()
labs(x = "positions", y = "foraging score") + theme_minimal() + facet_wrap(~ sex, ncol = 2)
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 <- ggplot(restriction60, aes(x=trials, y=foraging.score, group=rat_ID))
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)+
geom_line(color="gray", alpha=0.2)+
stat_summary(fun = "mean", size = 1, aes(group = sex, color= sex), geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se, aes(group = sex, color= sex), geom = "errorbar", alpha=1, width=0.05)+
scale_color_manual(values = c("#7fc97f", "#fdc086"))+
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()
labs(x = "positions", y = "foraging score") + theme_minimal() + facet_wrap(~ sex, ncol = 2)
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("#d15034", "#0c0d0f", "#c6c7c9", "#f1ae2d")
p_LE_foraging <- ggplot(df.LE_Rday1, aes(x=trials, y=foraging.score, group=rat_ID))
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)+
geom_line(color="gray", alpha=0.2)+
stat_summary(fun = "mean", size = 1, aes(group = sex, color= sex), geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se, aes(group = sex, color= sex), geom = "errorbar", alpha=1, width=0.05)+
scale_color_manual(values = c("#7fc97f", "#fdc086"))+
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()
labs(x = "positions", y = "foraging score") + theme_minimal() + facet_wrap(~ sex, ncol = 2)
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("#d15034", "#0c0d0f", "#c6c7c9", "#f1ae2d")
EFsex_blinedays <- ggplot(df.LE_Bday6, aes(x=trials, y=foraging.score, group=rat_ID))
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)+
geom_line(color="gray", alpha=0.2)+
stat_summary(fun = "mean", size = 1, aes(group = sex, color= sex), geom = "line", fun.min = 'sd', fun.max = 'sd') +
stat_summary(fun.data = mean_se, aes(group = sex, color= sex), geom = "errorbar", alpha=1, width=0.05)+
scale_color_manual(values = c("#7fc97f", "#fdc086"))+
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()
labs(x = "positions", y = "foraging score") + theme_minimal() + facet_wrap(~ sex, ncol = 2)
LE_Bday6 <- lmer(foraging.score~ sex + trials + sex:trials + (1|rat_ID),df.LE_Bday6)
eta_squared(LE_Bday6)
......@@ -523,11 +524,15 @@ 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))
colors <- c("#c6c7c9", "#d15034", "#0c0d0f", "#f1ae2d")
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()
LE_Rday1_leaving <- ggplot(df.LE_Rday1, aes(x=trials, y=leaving.score, group=rat_ID))
Fig_LE_leaving <- LE_Rday1_leaving +
geom_line(color="gray", alpha=0.2)+
stat_summary(fun = "mean", size = 1, aes(group = restriction, color= restriction), geom = "line", fun.min = 'sd', fun.max = 'sd')+
stat_summary(fun.data = mean_se, aes(group = restriction, color= restriction), geom = "errorbar", alpha=1, width=0.05) +
scale_color_manual(values = c("#7fc97f", "#fdc086"))+
scale_y_continuous(breaks = seq(0, 7, by = 1))+
labs(x = "positions", y = "leaving score") + theme_minimal() + facet_wrap(~ restriction, ncol = 2)
Fig_LE_leaving
ggsave('C:/Users/xiamen/Desktop/modified robogator/result figs/Fig_LE_leaving.svg', plot = Fig_LE_leaving, device = 'svg',dpi = 300)
```
......@@ -559,25 +564,29 @@ 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))
colors <- c("#c6c7c9", "#d15034", "#0c0d0f", "#f1ae2d")
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)+
LE_Rday1_approaching <- ggplot(df.LE_Rday1, aes(x=trials, y=approaching.score, group=rat_ID))
Fig_LE_approaching <- LE_Rday1_approaching +
geom_line(color="gray", alpha=0.2)+
stat_summary(fun = "mean", size = 1, aes(group = restriction, color= restriction), geom = "line", fun.min = 'sd', fun.max = 'sd')+
stat_summary(fun.data = mean_se, aes(group = restriction, color= restriction), geom = "errorbar", alpha=1, width=0.05)+
scale_color_manual(values = c("#7fc97f", "#fdc086"))+
scale_y_continuous(breaks = seq(0, 7, by = 1))+
geom_jitter(alpha = 1,width = 0.1)+theme_minimal()
theme_minimal() + facet_wrap(~ restriction, ncol = 2)
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_restriction_sex
```{r}
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))+
scale_color_manual(values = colors)+
LE_Rday1_approaching <- ggplot(restriction45, aes(x=trials, y=approaching.score, group=rat_ID))
LE_Rday1_approaching +
geom_line(color="gray", alpha=0.2)+
stat_summary(fun = "mean", size = 1, aes(group = sex, color= sex), geom = "line", fun.min = 'sd', fun.max = 'sd')+
stat_summary(fun.data = mean_se, aes(group = sex, color= sex), geom = "errorbar", alpha=1, width=0.05)+
scale_color_manual(values = c("#7fc97f", "#fdc086"))+
scale_y_continuous(breaks = seq(0, 7, by = 1))+
geom_jitter(alpha = 1,width = 0.1)+theme_minimal()
theme_minimal() + facet_wrap(~ sex, ncol = 2)
```
##in addition, if backing is needed
......
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