added boxplot_stat_log.R to generate graphs with log data and stats
This commit is contained in:
parent
550e8b2c50
commit
b8ff7995ac
6 changed files with 249 additions and 10 deletions
|
@ -22,8 +22,16 @@ pdf(output_boxplot_stats, width=22, height=16)
|
|||
#med_names = c("eotaxin3", "il12p70", "itac", "il13")
|
||||
#lf_test = lf_fp_npa[lf_fp_npa$mediator%in%med_names,]
|
||||
|
||||
#baz=cowplot::plot_grid(plotlist=foo, align = 'hv', ncol=2, nrow=2)
|
||||
foo_annot = annotate_figure(foo
|
||||
baz=cowplot::plot_grid(plotlist=foo, align = 'hv', ncol=2, nrow=2)
|
||||
baz
|
||||
|
||||
sam_plot = ggpubr::ggarrange(plotlist = foo
|
||||
, align = "hv"
|
||||
, ncol = 7
|
||||
, nrow = 5
|
||||
, common.legend = T)
|
||||
sam_plot
|
||||
foo_annot = annotate_figure(sam_plot
|
||||
, top = text_grob(my_sample_name
|
||||
, color = "blue"
|
||||
, face = "bold"
|
||||
|
@ -41,3 +49,80 @@ foo_annot = annotate_figure(foo
|
|||
foo_annot
|
||||
dev.off()
|
||||
##################################################################
|
||||
# ind components of function
|
||||
my_sample_name = "SAM"
|
||||
to_remove = c("ifna2a"
|
||||
, "il29")
|
||||
|
||||
lf_fp_sam2 = lf_fp_sam[!lf_fp_sam$mediator%in%to_remove,]
|
||||
lf_fp_sam3 = lf_fp_sam[lf_fp_sam$mediator%in%to_remove,]
|
||||
|
||||
df_test = lf_fp_sam3
|
||||
df_test = lf_fp_sam2
|
||||
table(df_test$mediator)
|
||||
|
||||
p = ggplot(df_test)+ geom_boxplot(aes(x = timepoint
|
||||
, y = value
|
||||
, color = obesity
|
||||
#, palette = c("#00BFC4", "#F8766D")
|
||||
))+
|
||||
scale_colour_manual(values=c("#00BFC4", "#F8766D")) +
|
||||
theme(axis.text.x = element_text(size = 15)
|
||||
, axis.text.y = element_text(size = 15
|
||||
, angle = 0
|
||||
, hjust = 1
|
||||
, vjust = 0)
|
||||
, axis.title.x = element_blank()
|
||||
, axis.title.y = element_blank()
|
||||
, legend.position = "none"
|
||||
, plot.subtitle = element_text(size = 20, hjust = 0.5)
|
||||
, plot.title = element_text(size = 20, hjust = 0.5)) +
|
||||
labs(title = "TEST")
|
||||
p
|
||||
|
||||
#--------
|
||||
# stats
|
||||
#---------
|
||||
to_remove = c("ifna2a"
|
||||
, "il29")
|
||||
lf_fp_sam3 = lf_fp_sam[lf_fp_sam$mediator%in%to_remove,]
|
||||
|
||||
lf_fp_sam4 = lf_fp_sam3[lf_fp_sam3$timepoint == "t3",]
|
||||
table(lf_fp_sam4$timepoint)
|
||||
|
||||
wilcox_test(value~obesity, data = lf_fp_sam4)
|
||||
|
||||
table(lf_fp_sam3$mediator, lf_fp_sam3$timepoint)
|
||||
time = c("t3")
|
||||
lf_fp_sam3 = lf_fp_sam3[!lf_fp_sam3$timepoint%in%time,]
|
||||
table(lf_fp_sam3$mediator, lf_fp_sam3$timepoint)
|
||||
|
||||
med = c("il29")
|
||||
time2 = c("t2")
|
||||
|
||||
lf_fp_sam3 = lf_fp_sam3[!lf_fp_sam3$mediator%in%med && lf_fp_sam3$timepoint%in%time2,]
|
||||
table(lf_fp_sam3$mediator, lf_fp_sam3$timepoint)
|
||||
|
||||
df_test = lf_fp_sam3
|
||||
|
||||
|
||||
table(df_test$mediator)
|
||||
|
||||
|
||||
stat_df <- df_test %>%
|
||||
group_by(timepoint, mediator) %>%
|
||||
wilcox_test(value ~ obesity, paired = F) %>%
|
||||
add_significance("p")
|
||||
stat_df$p_format = round(stat_df$p, digits = 3)
|
||||
|
||||
|
||||
stat_df <- stat_df %>%
|
||||
add_xy_position(x = "timepoint", dodge = 0.8)
|
||||
p2 = p + stat_pvalue_manual(stat_df
|
||||
#, y.position = max_y
|
||||
, label = "{p_format} {p.signif}"
|
||||
, hide.ns = T
|
||||
, tip.length = 0)+
|
||||
scale_y_continuous(expand = expansion(mult = c(0.05, 0.25)))
|
||||
|
||||
p2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue