dataana.R 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # load packages and data
  2. library(tidyverse)
  3. library(knitr)
  4. # fitting psychometric function using quickpsy
  5. library(quickpsy)
  6. library(ez)
  7. library(ggplot2)
  8. library(ggsignif)
  9. library(PairedData)
  10. library(cowplot)
  11. library(effsize)
  12. library(dplyr)
  13. library(gtools)
  14. library(bayesplot)
  15. library(gridExtra)
  16. library(plyr)
  17. library(ggpubr)
  18. library(lmerTest) # lmer function
  19. library(car) # contr.Sum function
  20. library(sjPlot) # tab_model function
  21. theme_set(bayesplot::theme_default())
  22. ## define theme for whole report
  23. mytheme <- theme_bw()+theme(panel.border = element_blank(),
  24. panel.grid.major = element_blank(),
  25. panel.grid.minor = element_blank(),
  26. panel.background = element_blank(),
  27. axis.line = element_line(colour = "black"))+
  28. theme(strip.background = element_blank(),
  29. axis.text.x = element_text(color = "black", size = 10),
  30. axis.text.y = element_text(color = "black", size = 10),
  31. axis.title.x = element_text(color = "black", size = 11, vjust = -1),
  32. axis.title.y = element_text(color = "black", size = 11),
  33. plot.title = element_text(color = "black", size = 11),
  34. legend.text=element_text(size=9),axis.ticks.length=unit(.10, "cm"))
  35. colors_plot <- c("#185C9B","#D81E3D")
  36. ##########################################################################
  37. # load behavior data
  38. dat_EEG_exp2 = read.csv('data/allData_exp2_beh.csv')
  39. dat_EEG_exp1 = read.csv('data/allData_exp1_beh.csv')
  40. eeg_dat_all <- data.frame(rbind(dat_EEG_exp1, dat_EEG_exp2))
  41. # load ERP data
  42. allAverageDat_exp1 <- read.csv(paste0(getwd(), '/data/allAverageDat_cnv_exp1.csv'))
  43. allAverageDat_exp2 <- read.csv(paste0(getwd(), '/data/allAverageDat_cnv_exp2.csv'))
  44. data_ica_p2_exp1 <- read.csv(paste0(getwd(), '/data/allAverageDat_pos_exp1.csv'))
  45. data_ica_pos_exp2 <- read.csv(paste0(getwd(), '/data/allAverageDat_pos_exp2.csv'))
  46. # load peak data
  47. exp1_negPeak_lat <- read.csv(paste0(getwd(), '/data/peak_negative_cnv_exp1.csv'))
  48. exp2_negPeak_lat <- read.csv(paste0(getwd(), '/data/peak_negative_cnv_exp2.csv'))
  49. exp1_pos_peaks <- read.csv(paste0(getwd(), '/data/peak_positive_offset_exp1.csv'))
  50. exp2_pos_peaks <- read.csv(paste0(getwd(), '/data/peak_positive_offset_exp2.csv'))
  51. # CNV end-turning point data
  52. turn_exp1= read.csv("data/width_CNV_exp1.csv")
  53. turn_exp2= read.csv("data/width_CNV_exp2.csv")
  54. ## calulate geometric mean
  55. gm_mean = function(x, na.rm=TRUE){
  56. exp(sum(log(x[x > 0]), na.rm=na.rm) / length(x))
  57. }