-
grandjeanlab authoredgrandjeanlab authored
README.Rmd 3.17 KiB
title: "TPH2 KO statistics"
output: github_document
author: "Alex Meng, Joanes Grandjean"
knitr::opts_chunk$set(echo = TRUE, eval=FALSE,warning = FALSE,message=FALSE)
Setup environement
Download DABEST
# you just need to run these once.
install.packages('devtools')
install.pacakges("reshape2")
install.pacakges("wesanderson")
devtools::install_github("ACCLAB/dabestr")
devtools::install_github("karthik/wesanderson")
Load pacakges
library(tidyverse)
library(glue)
library(dabestr)
library(wesanderson) # see https://github.com/karthik/wesanderson
library(reshape2)
pal <- wes_palette("Darjeeling1")
Figure 1: Anxiety level in THP2. if necessary, show rest in table
A. experimental diagram B. EPM time in open arm C. EPM total distance
Figure 2: Social behaviour.
A. experimetnal diagram B. Total no contact C. Total no contact over time (as line plot) D. Total mounting % E. Total aggressive %
Figure 3: SHow gene expression left, protein right, anat center? rest is in table.
A. Brain punches location (color-code gene expression / protein) B. IL/PL C. centroid amygdala D. ventral CA1 E. Dorsal raphe
demo dabest in R
#load the table. for other cases, it might help to keep naming consistent between tables, see example. Also, avoid spaces or weird characters in table names.
df <- read_csv('assets/tables/testname_measure.csv', col_types = cols()) %>% melt() %>% dplyr::rename(group = variable) %>% drop_na()
df %>% group_by(group) %>% summarise(mean=round(mean(value),2), sd=round(sd(value),2))
# estimate the p-values using non-parametric test
p_tmp<- c(wilcox.test(df$value[df$group == 'Tph2+/+'], df$value[df$group == 'Tph2+/-'])$p.value, wilcox.test(df$value[df$group == 'Tph2+/+'], df$value[df$group == 'Tph2-/-'])$p.value)
# estimate hedges'g
dabest_hedges <- dabest(df, group, value, idx = c('Tph2+/+','Tph2+/-','Tph2-/-'), paired = FALSE) %>% hedges_g()
#make the plot and save to file
Fig1A<-plot(dabest_hedges, palette = pal, rawplot.ylabel = "EPM open field [%]")
ggsave('assets/figure/fig_Fig1A.svg', plot = Fig1A, device = 'svg',dpi = 300)
#outputs the file to show in the doc.
Fig1A
#outputs table with added p-values for good measure
dabest_hedges$result %>% mutate(p = p_tmp)
what happens if dabest bugs?
#load the table. for other cases, it might help to keep naming consistent between tables, see example. Also, avoid spaces or weird characters in table names.
df <- read_csv('assets/tables/testname_measure.csv', col_types = cols()) %>% melt() %>% rename(group = variable) %>% drop_na()
dabest_hedges <- dabest(df, group, value, idx = c('Tph2+/+','Tph2+/-'), paired = FALSE) %>% hedges_g()
#figure will require post-pocessing to make do.
plot(dabest_hedges, palette = pal)
dabest_hedges <- dabest(df, group, value, idx = c('Tph2+/+','Tph2-/-'), paired = FALSE) %>% hedges_g()
#figure will require post-pocessing to make do.
plot(dabest_hedges, palette = pal)
Finally, you can consider https://rpkgs.datanovia.com/ggpubr/reference/ggarrange.html to make composite figures in R. Happy to help you get started.