library(tidyverse)
library(ggplot2)
library(ggbeeswarm)
library(plotrix)
library(car)
library(rstatix)
library(SimComp)
library(readxl)
library(dplyr)
dataset_exp_3_double_imprint <- read_excel (path = "/mnt/c/Users/Toshiya Matsushima/OneDrive/R projects/BM_project/data analysis using Rstudio/BM_project_dataset.xlsx", sheet = "exp_3_double_imprint")
dataset_exp_3_double_imprint
dataset_exp_3_double_imprint_ctrl <- filter(dataset_exp_3_double_imprint, drug == "00_ctrl")
dataset_exp_3_double_imprint_vpa <- filter(dataset_exp_3_double_imprint, drug == "01_vpa")
dataset_exp_3_double_imprint_keta <- filter(dataset_exp_3_double_imprint, drug == "02_keta")
dataset_exp_3_double_imprint_tubo <- filter(dataset_exp_3_double_imprint, drug == "04_tubo")
dataset_exp_3_double_imprint_ctrl
dataset_exp_3_double_imprint_vpa
dataset_exp_3_double_imprint_keta
dataset_exp_3_double_imprint_tubo
NA
dataset_exp_3_double_imprint %>%
group_by (drug) %>%
get_summary_stats(bm)
fig <- ggplot(data = dataset_exp_3_double_imprint, mapping = aes(x = drug, y = bm))+
geom_hline(yintercept=0, linetype = "dotted")+
geom_boxplot()+
geom_point(shape=16, size=3, colour="black")+
# geom_beeswarm(shape=16, size=3, colour="black")+
ylim(-600, 600)+
theme_classic()
fig
ggsave(plot = fig, filename = "exp_3_bm_vs_drug.png", dpi = 300, height = 10, width = 7, units = "cm")
dataset_exp_3_double_imprint %>%
anova_test(bm ~ drug)
Coefficient covariances computed by hccm()
ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges
1 drug 3 43 3.755 0.018 * 0.208
fit_exp3_bm_drug <- lm(bm ~ drug, data = dataset_exp_3_double_imprint)
summary (fit_exp3_bm_drug)
Call:
lm(formula = bm ~ drug, data = dataset_exp_3_double_imprint)
Residuals:
Min 1Q Median 3Q Max
-497.58 -130.08 11.42 118.31 455.42
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 145.80 52.24 2.791 0.00781 **
drug01_vpa -18.22 78.37 -0.232 0.81729
drug02_keta -172.30 82.61 -2.086 0.04296 *
drug04_tubo -235.00 82.61 -2.845 0.00678 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 202.3 on 43 degrees of freedom
Multiple R-squared: 0.2076, Adjusted R-squared: 0.1523
F-statistic: 3.755 on 3 and 43 DF, p-value: 0.01758
car::Anova(fit_exp3_bm_drug)
Anova Table (Type II tests)
Response: bm
Sum Sq Df F value Pr(>F)
drug 461236 3 3.7552 0.01758 *
Residuals 1760515 43
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
fig <- ggplot(data = dataset_exp_3_double_imprint, mapping = aes(x = drug, y = imprint_1))+
geom_hline(yintercept=0, linetype = "dotted")+
geom_boxplot()+
geom_point(shape=16, size=3, colour="black")+
ylim(-600, 600)+
theme_classic()
fig
ggsave(plot = fig, filename = "exp_3_imprint1_vs_drug.png", dpi = 300, height = 10, width = 7, units = "cm")
dataset_exp_3_double_imprint %>%
anova_test(imprint_1 ~ drug)
Coefficient covariances computed by hccm()
ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges
1 drug 3 43 2.596 0.065 0.153
fit_exp3_imprint_1 <- lm(imprint_1 ~ drug, data = dataset_exp_3_double_imprint)
summary (fit_exp3_imprint_1)
Call:
lm(formula = imprint_1 ~ drug, data = dataset_exp_3_double_imprint)
Residuals:
Min 1Q Median 3Q Max
-485.1 -156.6 26.4 174.4 406.2
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 37.13 59.77 0.621 0.5377
drug01_vpa -213.05 89.66 -2.376 0.0220 *
drug02_keta -201.53 94.51 -2.132 0.0387 *
drug04_tubo -60.33 94.51 -0.638 0.5266
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 231.5 on 43 degrees of freedom
Multiple R-squared: 0.1533, Adjusted R-squared: 0.09428
F-statistic: 2.596 on 3 and 43 DF, p-value: 0.06465
car::Anova(fit_exp3_imprint_1)
Anova Table (Type II tests)
Response: imprint_1
Sum Sq Df F value Pr(>F)
drug 417382 3 2.596 0.06465 .
Residuals 2304481 43
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
fit_exp3_imprint_1_bm <- lm(imprint_1 ~ drug * bm, data = dataset_exp_3_double_imprint)
summary (fit_exp3_imprint_1_bm)
Call:
lm(formula = imprint_1 ~ drug * bm, data = dataset_exp_3_double_imprint)
Residuals:
Min 1Q Median 3Q Max
-405.51 -121.52 18.37 130.59 408.40
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -128.6864 72.0850 -1.785 0.082007 .
drug01_vpa -1.7390 99.4170 -0.017 0.986134
drug02_keta -36.8073 98.1233 -0.375 0.709609
drug04_tubo 104.6133 103.3479 1.012 0.317660
bm 1.1373 0.3286 3.462 0.001317 **
drug01_vpa:bm -1.4939 0.4161 -3.591 0.000911 ***
drug02_keta:bm -1.1786 0.4706 -2.505 0.016545 *
drug04_tubo:bm -1.1471 0.5003 -2.293 0.027323 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 208.6 on 39 degrees of freedom
Multiple R-squared: 0.3764, Adjusted R-squared: 0.2645
F-statistic: 3.363 on 7 and 39 DF, p-value: 0.00668
car::Anova(fit_exp3_imprint_1_bm)
Anova Table (Type II tests)
Response: imprint_1
Sum Sq Df F value Pr(>F)
drug 408946 3 3.1321 0.036347 *
bm 23074 1 0.5302 0.470892
drug:bm 584028 3 4.4730 0.008583 **
Residuals 1697379 39
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
fig <- ggplot(data = dataset_exp_3_double_imprint, mapping = aes(x = drug, y = imprint_2))+
geom_hline(yintercept=0, linetype = "dotted")+
geom_boxplot()+
geom_point(shape=16, size=3, colour="black")+
ylim(-600, 600)+
theme_classic()
fig
ggsave(plot = fig, filename = "exp_3_imprint2_vs_drug.png", dpi = 300, height = 10, width = 7, units = "cm")
dataset_exp_3_double_imprint %>%
anova_test(imprint_2 ~ drug)
Coefficient covariances computed by hccm()
ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges
1 drug 3 43 2.693 0.058 0.158
fit_exp3_imprint_2 <- lm(imprint_2 ~ drug, data = dataset_exp_3_double_imprint)
summary (fit_exp3_imprint_2)
Call:
lm(formula = imprint_2 ~ drug, data = dataset_exp_3_double_imprint)
Residuals:
Min 1Q Median 3Q Max
-807.75 -84.13 33.87 168.45 387.25
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 487.13 68.66 7.095 9.38e-09 ***
drug01_vpa -277.38 102.99 -2.693 0.0100 *
drug02_keta -194.93 108.56 -1.796 0.0796 .
drug04_tubo -91.23 108.56 -0.840 0.4053
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 265.9 on 43 degrees of freedom
Multiple R-squared: 0.1582, Adjusted R-squared: 0.09942
F-statistic: 2.693 on 3 and 43 DF, p-value: 0.0579
car::Anova(fit_exp3_imprint_2)
Anova Table (Type II tests)
Response: imprint_2
Sum Sq Df F value Pr(>F)
drug 571217 3 2.6927 0.0579 .
Residuals 3040582 43
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
fit_exp3_imprint_2_bm <- lm(imprint_2 ~ drug*bm, data = dataset_exp_3_double_imprint)
summary (fit_exp3_imprint_2_bm)
Call:
lm(formula = imprint_2 ~ drug * bm, data = dataset_exp_3_double_imprint)
Residuals:
Min 1Q Median 3Q Max
-734.26 -109.08 36.03 127.18 622.30
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 470.3160 93.4620 5.032 1.13e-05 ***
drug01_vpa -320.8333 128.8993 -2.489 0.0172 *
drug02_keta -179.5913 127.2220 -1.412 0.1660
drug04_tubo -103.0923 133.9960 -0.769 0.4463
bm 0.1153 0.4260 0.271 0.7880
drug01_vpa:bm 0.3570 0.5394 0.662 0.5120
drug02_keta:bm -0.1710 0.6101 -0.280 0.7807
drug04_tubo:bm -0.4368 0.6486 -0.673 0.5046
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 270.5 on 39 degrees of freedom
Multiple R-squared: 0.21, Adjusted R-squared: 0.06819
F-statistic: 1.481 on 7 and 39 DF, p-value: 0.2026
car::Anova(fit_exp3_imprint_2_bm)
Anova Table (Type II tests)
Response: imprint_2
Sum Sq Df F value Pr(>F)
drug 567241 3 2.5844 0.06698 .
bm 33363 1 0.4560 0.50348
drug:bm 153844 3 0.7009 0.55722
Residuals 2853376 39
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#Correlations among BM, imprint_1 and imprint_2
fig <- ggplot(data = dataset_exp_3_double_imprint, mapping = aes(x=bm, y=imprint_1, color=drug))+
geom_point(shape=16, size=3)+
geom_vline(xintercept=0, linetype = "dotted")+
geom_hline(yintercept=0, linetype = "dotted")+
geom_smooth(method = "lm")+
xlim(-600, 600)+
ylim(-600, 600)+
theme_classic()
fig
`geom_smooth()` using formula 'y ~ x'
ggsave(plot = fig, filename = "exp_3_bm_imprint_1.png", dpi = 300, height = 10, width = 13, units = "cm")
`geom_smooth()` using formula 'y ~ x'
cor_test(dataset_exp_3_double_imprint_ctrl, bm, imprint_1, method = "spearman")
cor_test(dataset_exp_3_double_imprint_vpa, bm, imprint_1, method = "spearman")
cor_test(dataset_exp_3_double_imprint_keta, bm, imprint_1, method = "spearman")
cor_test(dataset_exp_3_double_imprint_tubo, bm, imprint_1, method = "spearman")
fig <- ggplot(data = dataset_exp_3_double_imprint, mapping = aes(x=bm, y=imprint_2, color=drug))+
geom_point(shape=16, size=3)+
geom_vline(xintercept=0, linetype = "dotted")+
geom_hline(yintercept=0, linetype = "dotted")+
geom_smooth(method = "lm")+
xlim(-600, 600)+
ylim(-600, 600)+
theme_classic()
fig
`geom_smooth()` using formula 'y ~ x'
ggsave(plot = fig, filename = "exp_3_bm_imprint_2.png", dpi = 300, height = 10, width = 13, units = "cm")
`geom_smooth()` using formula 'y ~ x'
cor_test(dataset_exp_3_double_imprint_ctrl, bm, imprint_2, method = "spearman")
cor_test(dataset_exp_3_double_imprint_vpa, bm, imprint_2, method = "spearman")
cor_test(dataset_exp_3_double_imprint_keta, bm, imprint_2, method = "spearman")
cor_test(dataset_exp_3_double_imprint_tubo, bm, imprint_2, method = "spearman")
fig <- ggplot(data = dataset_exp_3_double_imprint, mapping = aes(x=imprint_2, y=imprint_1, color=drug))+
geom_point(shape=16, size=3)+
geom_vline(xintercept=0, linetype = "dotted")+
geom_hline(yintercept=0, linetype = "dotted")+
geom_smooth(method = "lm")+
xlim(-600, 600)+
ylim(-600, 600)+
theme_classic()
fig
`geom_smooth()` using formula 'y ~ x'
ggsave(plot = fig, filename = "exp_3_imprint_2_imprint_1.png", dpi = 300, height = 10, width = 13, units = "cm")
`geom_smooth()` using formula 'y ~ x'
cor_test(dataset_exp_3_double_imprint, imprint_1, imprint_2, method = "spearman")
sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8
[6] LC_MESSAGES=C.UTF-8 LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggsci_2.9 pwr_1.3-0 plotly_4.10.0 readxl_1.3.1 SimComp_3.3 rstatix_0.7.0 car_3.0-12
[8] carData_3.0-5 plotrix_3.8-2 ggbeeswarm_0.6.0 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.7 purrr_0.3.4
[15] readr_2.1.1 tidyr_1.1.4 tibble_3.1.6 ggplot2_3.3.5 tidyverse_1.3.1
loaded via a namespace (and not attached):
[1] nlme_3.1-144 fs_1.5.2 lubridate_1.8.0 httr_1.4.2 tools_3.6.3 backports_1.4.1
[7] utf8_1.2.2 R6_2.5.1 vipor_0.4.5 mgcv_1.8-31 DBI_1.1.1 lazyeval_0.2.2
[13] colorspace_2.0-2 withr_2.4.3 tidyselect_1.1.1 compiler_3.6.3 survPresmooth_1.1-11 mratios_1.4.2
[19] cli_3.1.0 rvest_1.0.2 xml2_1.3.3 sandwich_3.0-1 labeling_0.4.2 scales_1.1.1
[25] mvtnorm_1.1-3 digest_0.6.29 rmarkdown_2.11 pkgconfig_2.0.3 htmltools_0.5.2 dbplyr_2.1.1
[31] fastmap_1.1.0 htmlwidgets_1.5.4 rlang_0.4.12 rstudioapi_0.13 jquerylib_0.1.4 generics_0.1.1
[37] farver_2.1.0 zoo_1.8-9 jsonlite_1.7.2 magrittr_2.0.1 Matrix_1.2-18 Rcpp_1.0.7
[43] munsell_0.5.0 fansi_0.5.0 abind_1.4-5 lifecycle_1.0.1 stringi_1.7.6 multcomp_1.4-18
[49] yaml_2.2.1 MASS_7.3-51.5 grid_3.6.3 crayon_1.4.2 lattice_0.20-40 haven_2.4.3
[55] splines_3.6.3 hms_1.1.1 knitr_1.37 pillar_1.6.4 codetools_0.2-16 reprex_2.0.1
[61] glue_1.6.0 evaluate_0.14 data.table_1.14.2 modelr_0.1.8 vctrs_0.3.8 tzdb_0.2.0
[67] cellranger_1.1.0 gtable_0.3.0 assertthat_0.2.1 xfun_0.29 broom_0.7.10 survival_3.1-8
[73] viridisLite_0.4.0 beeswarm_0.4.0 TH.data_1.1-0 ellipsis_0.3.2