当前位置:网站首页>How to Add P-Values onto Horizontal GGPLOTS
How to Add P-Values onto Horizontal GGPLOTS
2022-07-02 11:49:00 【Xiaoyu 2022】
library(ggpubr)
library(rstatix)
# Transform `dose` into factor variable
df <- ToothGrowth
df$dose <- as.factor(df$dose)
head(df, 3)
# Box plots
bxp <- ggboxplot(df, x = "dose", y = "len", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
# Bar plots showing mean +/- SD
bp <- ggbarplot(df, x = "dose", y = "len", add = "mean_sd", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
stat.test <- df %>% t_test(len ~ dose)
# Box plot
stat.test <- stat.test %>% add_xy_position(x = "dose")
bxp + stat_pvalue_manual(stat.test, label = "p.adj.signif", tip.length = 0.01)
# Bar plot
stat.test <- stat.test %>% add_xy_position(fun = "mean_sd", x = "dose")
bp + stat_pvalue_manual(stat.test, label = "p.adj.signif", tip.length = 0.01)
library(ggpubr)
library(rstatix)
# Transform `dose` into factor variable
df <- ToothGrowth
df$dose <- as.factor(df$dose)
head(df, 3)
# Box plots
bxp <- ggboxplot(df, x = "dose", y = "len", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
# Bar plots showing mean +/- SD
bp <- ggbarplot(df, x = "dose", y = "len", add = "mean_sd", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
stat.test <- stat.test %>% add_xy_position(x = "dose")
bxp +
stat_pvalue_manual(
stat.test, label = "p.adj.signif", tip.length = 0.01,
coord.flip = TRUE
) +
coord_flip()
# Horizontal bar plot with p-values
stat.test <- stat.test %>% add_xy_position(fun = "mean_sd", x = "dose")
bp + stat_pvalue_manual(
stat.test, label = "p.adj.signif", tip.length = 0.01,
coord.flip = TRUE
) +
coord_flip()
library(ggpubr)
library(rstatix)
# Transform `dose` into factor variable
df <- ToothGrowth
df$dose <- as.factor(df$dose)
head(df, 3)
# Box plots
bxp <- ggboxplot(df, x = "dose", y = "len", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
# Bar plots showing mean +/- SD
bp <- ggbarplot(df, x = "dose", y = "len", add = "mean_sd", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
# Using `p.adj` as labels
stat.test <- stat.test %>% add_xy_position(x = "dose")
bxp +
stat_pvalue_manual(
stat.test, label = "p.adj", tip.length = 0.01,
coord.flip = TRUE
) +
coord_flip()
library(ggpubr)
library(rstatix)
# Transform `dose` into factor variable
df <- ToothGrowth
df$dose <- as.factor(df$dose)
head(df, 3)
# Box plots
bxp <- ggboxplot(df, x = "dose", y = "len", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
# Bar plots showing mean +/- SD
bp <- ggbarplot(df, x = "dose", y = "len", add = "mean_sd", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
stat.test <- df %>% t_test(len ~ dose, ref.group = "0.5")
# Vertical box plot with p-values
stat.test <- stat.test %>% add_xy_position(x = "dose")
bxp +
stat_pvalue_manual(stat.test, label = "p.adj", tip.length = 0.01) +
scale_y_continuous(expand = expansion(mult = c(0.05, 0.1)))
library(ggpubr)
library(rstatix)
# Transform `dose` into factor variable
df <- ToothGrowth
df$dose <- as.factor(df$dose)
head(df, 3)
# Box plots
bxp <- ggboxplot(df, x = "dose", y = "len", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
# Bar plots showing mean +/- SD
bp <- ggbarplot(df, x = "dose", y = "len", add = "mean_sd", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
stat.test <- df %>% t_test(len ~ dose, ref.group = "0.5")
# Vertical box plot with p-values
# Vertical bar plot with p-values
stat.test <- stat.test %>% add_xy_position(fun = "mean_sd", x = "dose")
bp +
stat_pvalue_manual(stat.test, label = "p.adj.signif", tip.length = 0.01) +
scale_y_continuous(expand = expansion(mult = c(0.05, 0.1)))
library(ggpubr)
library(rstatix)
# Transform `dose` into factor variable
df <- ToothGrowth
df$dose <- as.factor(df$dose)
head(df, 3)
# Box plots
bxp <- ggboxplot(df, x = "dose", y = "len", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
# Bar plots showing mean +/- SD
bp <- ggbarplot(df, x = "dose", y = "len", add = "mean_sd", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
# Horizontal box plot with p-values
stat.test <- stat.test %>% add_xy_position(x = "dose")
bxp +
stat_pvalue_manual(
stat.test, label = "p.adj", tip.length = 0.01,
coord.flip = TRUE
) +
scale_y_continuous(expand = expansion(mult = c(0.05, 0.1))) +
coord_flip()
library(ggpubr)
library(rstatix)
# Transform `dose` into factor variable
df <- ToothGrowth
df$dose <- as.factor(df$dose)
head(df, 3)
# Box plots
bxp <- ggboxplot(df, x = "dose", y = "len", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
# Bar plots showing mean +/- SD
bp <- ggbarplot(df, x = "dose", y = "len", add = "mean_sd", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
# Horizontal bar plot with p-values
stat.test <- stat.test %>% add_xy_position(fun = "mean_sd", x = "dose")
bp +
stat_pvalue_manual(
stat.test, label = "p.adj", tip.length = 0.01,
coord.flip = TRUE
) +
scale_y_continuous(expand = expansion(mult = c(0.05, 0.1))) +
coord_flip()
library(ggpubr)
library(rstatix)
# Transform `dose` into factor variable
df <- ToothGrowth
df$dose <- as.factor(df$dose)
head(df, 3)
# Box plots
bxp <- ggboxplot(df, x = "dose", y = "len", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
# Bar plots showing mean +/- SD
bp <- ggbarplot(df, x = "dose", y = "len", add = "mean_sd", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
# Show p-values at x = "group2"
stat.test <- stat.test %>% add_xy_position(x = "dose")
bxp +
stat_pvalue_manual(
stat.test, label = "p = {p.adj}", tip.length = 0.01,
coord.flip = TRUE, x = "group2", hjust = 0.4
) +
scale_y_continuous(expand = expansion(mult = c(0.05, 0.2))) +
coord_flip()
library(ggpubr)
library(rstatix)
# Transform `dose` into factor variable
df <- ToothGrowth
df$dose <- as.factor(df$dose)
head(df, 3)
# Box plots
bxp <- ggboxplot(df, x = "dose", y = "len", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
# Bar plots showing mean +/- SD
bp <- ggbarplot(df, x = "dose", y = "len", add = "mean_sd", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
# Make the p-values horizontal using the option angle
stat.test <- stat.test %>% add_xy_position(x = "dose")
bxp +
stat_pvalue_manual(
stat.test, label = "p = {p.adj}", tip.length = 0.01,
coord.flip = TRUE, x = "group2", angle = 90
) +
scale_y_continuous(expand = expansion(mult = c(0.05, 0.1))) +
scale_x_discrete(expand = expansion(mult = c(0.05, 0.3))) +
coord_flip()
边栏推荐
- Wechat applet uses Baidu API to achieve plant recognition
- Cluster Analysis in R Simplified and Enhanced
- CTF record
- Skills of PLC recorder in quickly monitoring multiple PLC bits
- R HISTOGRAM EXAMPLE QUICK REFERENCE
- R HISTOGRAM EXAMPLE QUICK REFERENCE
- vant tabs组件选中第一个下划线位置异常
- The computer screen is black for no reason, and the brightness cannot be adjusted.
- How to Create a Nice Box and Whisker Plot in R
- deepTools对ChIP-seq数据可视化
猜你喜欢
The computer screen is black for no reason, and the brightness cannot be adjusted.
[visual studio 2019] create and import cmake project
CentOS8之mysql基本用法
How to Create a Nice Box and Whisker Plot in R
ESP32音频框架 ESP-ADF 添加按键外设流程代码跟踪
Develop scalable contracts based on hardhat and openzeppelin (II)
Data analysis - Matplotlib sample code
PYQT5+openCV项目实战:微循环仪图片、视频记录和人工对比软件(附源码)
文件操作(详解!)
Power Spectral Density Estimates Using FFT---MATLAB
随机推荐
MySQL comparison operator in problem solving
How to Easily Create Barplots with Error Bars in R
qt 仪表自定义控件
Map set assignment to database
接口调试工具概论
Pyqt5+opencv project practice: microcirculator pictures, video recording and manual comparison software (with source code)
Summary of flutter problems
解决uniapp列表快速滑动页面数据空白问题
What week is a date obtained by QT
[multithreading] the main thread waits for the sub thread to finish executing, and records the way to execute and obtain the execution result (with annotated code and no pit)
On April 17, 2022, the five heart matchmaker team received double good news
RPA进阶(二)Uipath应用实践
Three transparent LED displays that were "crowded" in 2022
动态内存(进阶四)
PHP query distance according to longitude and latitude
可升级合约的原理-DelegateCall
How to Visualize Missing Data in R using a Heatmap
vant tabs组件选中第一个下划线位置异常
How to Create a Beautiful Plots in R with Summary Statistics Labels
Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic