123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- ## All GAL4-rescues into one figure
- ## data for each group were calculated by runCetran.r code and saved in one table
- ## groups were added to the table manually
- library(dplyr)
- library("plyr")
- library("ggplot2")
- library(EnvStats)
- allori <- read.csv("03_data/990_processed_data/rescues_buridan_uasonIII_output/output _table_corr.csv",
- dec=",")
- grouping = data.frame(group =unique(allori$group))
- grouping$genorder = c(1:20)
- grouping$order_for_figure = rep(c("a","b","c","d"),5)
- grouping$females = rep(c("w+;;UAS-t-beta-h","t-beta-h",rep("t-beta-h;;UAS-t-beta-h",2)),5)
- grouping$gal4= c(rep("actin-",4),rep("nsyb-",4),rep("tdc1-",4),rep("tdc2-",4),rep("np7088-",4))
- grouping$males2 = rep(rep(c("CS", "Gal4"),2),5)
- grouping=grouping %>% mutate (males =ifelse(males2 !="Gal4",males2 ,paste0(gal4,"Gal4")))
- grouping$males
- all = left_join(allori,grouping)
- #all <- read.csv2("E:/DiffDom manuscript data/TA-rec_homo.csv")
- #attach(all)
- #install.packages("ddply")
- ## speed ####
- call<- ddply(all, .(genorder,group,order_for_figure), summarise, # .()includes all the variables
- N = length(median_speed),
- speeds = mean(median_speed),
- sd = sd(median_speed),
- se = sd(median_speed) / sqrt(length(median_speed)) )
-
- p1=call %>%
- arrange(genorder) %>% # First sort by val. This sort the dataframe but NOT the factor levels
- mutate(group=factor(group, levels=group)) %>%
- ggplot( aes(x=group, y=speeds, fill=order_for_figure)) +
- geom_bar(stat="identity",position=position_dodge(),col="black") +
- geom_errorbar(aes(ymin=speeds-se, ymax=speeds+se),
- width=.2,position=position_dodge(.9)) +
- ylab("Walking Speed [mm/s]") +
- xlab("") + # column fill and legend title/ -lables
- scale_y_continuous(breaks=0:16*4, limits = c(0,30)) +
- scale_fill_manual(values=c("white","grey","grey","lightblue")) + #fill_manual muss nach fill_discrete stehen
- theme(axis.title.x = element_text(size=20), #(face="bold", colour="black")
- axis.title.y = element_text(angle=90,size=20),
- axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
- #axis.line = element_line(colour = "black"),
- panel.grid.major = element_blank(),
- legend.position ="none",
- panel.grid.minor = element_blank(),
- axis.line.x = element_line(color="black", size = 0.5),
- axis.line.y = element_line(color="black", size = 0.5),
- panel.background = element_blank(),
- panel.border = element_blank())
-
- ## fixation ####
- p2=all %>%
- arrange(genorder) %>% # First sort by val. This sort the dataframe but NOT the factor levels
- mutate(group=factor(group,levels = unique(group))) %>%
- ggplot( aes(x=group, y=stripe_deviation, fill=order_for_figure)) +
- geom_boxplot() +
- stat_n_text(size = 2)+
- ylab("Stripe deviation [?]") +
- xlab("") +
- scale_fill_manual(values=c("white","grey","grey","lightblue"),name="") + # column fill and legend title/ -lables
- scale_y_continuous(breaks=0:16*5, limits = c(-10,75)) +
- theme_bw() + # to make background white, has to be before "opts"
- theme(axis.title.x = element_text(size=20), #(face="bold", colour="black")
- axis.title.y = element_text(angle=90,size=20),
- #axis.text.x = element_text(hjust=0.5, size=16),
- axis.line = element_line(colour = "black"),
- panel.grid.major = element_blank(),
- panel.grid.minor = element_blank(),
- legend.position ="none",
- axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
- #panel.grid.major = theme_blank(),
- #panel.grid.minor = theme_blank(),
- #panel.border = theme_blank(),
- #panel.background = theme_blank()
- )
- pdf ("05_figures/fig2/outputfigurerescueIII_2.pdf")
- gridExtra::grid.arrange(p1, p2, nrow = 2)
- dev.off()
- #aSTATISTICS
- sink ("05_figures/fig2/outputfigurerescueIII_stats.txt")
- for (i in c(0:4)){
- #i=0
- data = all %>% filter (group %in% unique(all$group)[(4*i+1):(4*i+4)])
- data =droplevels(data)
- x=aov(data$median_speed~data$group)
- print ("speed")
- print(summary(x))
-
- print(TukeyHSD(x))
- print ("angledev")
- print(pairwise.wilcox.test(data$stripe_deviation,data$group,p.adjust="bonferroni"))
- }
- sink()
|