playing with display
This commit is contained in:
parent
2634aeeb84
commit
c26171d12c
1 changed files with 52 additions and 41 deletions
93
boxplot.R
93
boxplot.R
|
@ -78,11 +78,6 @@ stat.test <- stat.test %>%
|
||||||
bxp + stat_pvalue_manual(
|
bxp + stat_pvalue_manual(
|
||||||
stat.test, label = "p", tip.length = 0
|
stat.test, label = "p", tip.length = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
################################
|
################################
|
||||||
lf_test2 = lf[order(lf$mediator),] # 2 meds
|
lf_test2 = lf[order(lf$mediator),] # 2 meds
|
||||||
lf_test2 = lf_test2[1:798,]
|
lf_test2 = lf_test2[1:798,]
|
||||||
|
@ -98,7 +93,6 @@ stat.test <- lf_test2 %>%
|
||||||
|
|
||||||
stat.test
|
stat.test
|
||||||
|
|
||||||
|
|
||||||
bxp <- ggboxplot(lf_test2, x = "timepoint", y = "value",
|
bxp <- ggboxplot(lf_test2, x = "timepoint", y = "value",
|
||||||
color = "obesity", palette = c("#00BFC4", "#F8766D")) +
|
color = "obesity", palette = c("#00BFC4", "#F8766D")) +
|
||||||
facet_wrap(~mediator, scales = "free_y")
|
facet_wrap(~mediator, scales = "free_y")
|
||||||
|
@ -116,45 +110,62 @@ str(lf_comp)
|
||||||
|
|
||||||
p2 = ggplot(lf_test_comp, aes(x = timepoint, y = value, fill = obesity )) +
|
p2 = ggplot(lf_test_comp, aes(x = timepoint, y = value, fill = obesity )) +
|
||||||
geom_boxplot(width = 0.5)
|
geom_boxplot(width = 0.5)
|
||||||
p2 + stat_compare_means(comparisons = my_comparisons
|
p2
|
||||||
, method = "wilcox.test"
|
|
||||||
, paired = F
|
|
||||||
, label = "p.format")
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# Output plots as one pdf
|
# Output plots as one pdf
|
||||||
cat("Output plots will be in:", output_boxplot)
|
cat("Output plots will be in:", output_boxplot)
|
||||||
pdf(output_boxplot, width=15, height=12)
|
pdf(output_boxplot, width = 25, height = 15)
|
||||||
|
|
||||||
y_value = "value"
|
#stats data
|
||||||
my_title1 = "Boxplots"
|
str(lf)
|
||||||
|
stat.test <- lf %>%
|
||||||
|
group_by(timepoint, mediator) %>%
|
||||||
|
wilcox_test(value ~ obesity, paired = F) %>%
|
||||||
|
#adjust_pvalue(method = "bonferroni") %>%
|
||||||
|
#add_significance("p.adj")
|
||||||
|
add_significance("p")
|
||||||
|
stat.test
|
||||||
|
|
||||||
|
bxp <- ggboxplot(lf, x = "timepoint", y = "value",
|
||||||
|
color = "obesity", palette = c("#00BFC4", "#F8766D")) +
|
||||||
|
facet_wrap(~mediator, nrow = 7, ncol = 5, scales = "free_y", shrink = T)+
|
||||||
|
scale_y_log10()
|
||||||
|
bxp
|
||||||
|
|
||||||
|
bxp + stat.test <- stat.test %>%
|
||||||
|
add_xy_position(x = "timepoint", dodge = 0.8)
|
||||||
|
|
||||||
|
bxp + stat_pvalue_manual(stat.test, label = "p.signif", tip.length = 0)
|
||||||
|
|
||||||
p1 = ggplot(lf, aes(x = factor(timepoint), y = eval(parse(text=y_value)), fill = factor(obesity) )) +
|
dev.off()
|
||||||
scale_fill_manual(values=c("#00BFC4", "#F8766D")) +
|
|
||||||
facet_wrap(~ mediator, nrow = 9, ncol = 4, scales = "free_y") +
|
######output
|
||||||
geom_boxplot(width = 0.5, outlier.colour = NA) +
|
|
||||||
#geom_point(position = position_jitterdodge(dodge.width=0.5)
|
# Output plots as one pdf
|
||||||
# , aes(colours = factor(obesity))) +
|
cat("Output plots will be in:", output_boxplot)
|
||||||
theme(axis.text.x = element_text(size = 15)
|
pdf(output_boxplot, width = 20, height = 15)
|
||||||
, axis.text.y = element_text(size = 15
|
my_title1 = "Boxplots: serum"
|
||||||
, angle = 0
|
|
||||||
, hjust = 1
|
bxp <- ggboxplot(lf, x = "timepoint", y = "value",
|
||||||
, vjust = 0)
|
color = "obesity", palette = c("#00BFC4", "#F8766D")) +
|
||||||
, axis.title.x = element_text(size = 15)
|
facet_wrap(~mediator, nrow = 7, ncol = 5, scales = "free_y", shrink = T)+
|
||||||
, axis.title.y = element_text(size = 15)
|
scale_y_log10()
|
||||||
, plot.title = element_text(size = 20, hjust = 0.5)
|
|
||||||
, strip.text.x = element_text(size = 15, colour = "black")
|
bxp + theme(axis.text.x = element_text(size = 15)
|
||||||
, legend.title = element_text(color = "black", size = 10)
|
, axis.text.y = element_text(size = 15
|
||||||
, legend.text = element_text(size = 15)
|
, angle = 0
|
||||||
, legend.direction = "vertical") +
|
, hjust = 1
|
||||||
labs(title = my_title1
|
, vjust = 0)
|
||||||
, x = ""
|
, axis.title.x = element_text(size = 15)
|
||||||
, y = "Levels")+
|
, axis.title.y = element_text(size = 15)
|
||||||
stat_compare_means(comparisons = my_comparisons
|
, plot.title = element_text(size = 20, hjust = 0.5)
|
||||||
, method = "wilcox.test"
|
, strip.text.x = element_text(size = 15, colour = "black")
|
||||||
, paired = F
|
, legend.title = element_text(color = "black", size = 20)
|
||||||
, label = "p.format")
|
, legend.text = element_text(size = 15)
|
||||||
#p1
|
, legend.direction = "horizontal") +
|
||||||
shift_legend2(p1)
|
labs(title = my_title1
|
||||||
|
, x = ""
|
||||||
|
, y = "Levels (Log10)")
|
||||||
|
#shift_legend2(bxp)
|
||||||
dev.off()
|
dev.off()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue