当前位置:网站首页>How to Add P-Values onto Horizontal GGPLOTS
How to Add P-Values onto Horizontal GGPLOTS
2022-07-02 09:41:00 【小宇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()
边栏推荐
- mysql链表数据存储查询排序问题
- 八大排序汇总
- ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
- On April 17, 2022, the five heart matchmaker team received double good news
- ctf 记录
- ros gazebo相关包的安装
- C # method of obtaining a unique identification number (ID) based on the current time
- 【云原生】2.5 Kubernetes 核心实战(下)
- Bedtools tutorial
- Cluster Analysis in R Simplified and Enhanced
猜你喜欢
What is the relationship between digital transformation of manufacturing industry and lean production
基于Hardhat和Openzeppelin开发可升级合约(一)
【IDEA】使用插件一键逆向生成代码
念念不忘,必有回响 | 悬镜诚邀您参与OpenSCA用户有奖调研
Cluster Analysis in R Simplified and Enhanced
2022年遭“挤爆”的三款透明LED显示屏
可昇級合約的原理-DelegateCall
Compilation errors and printout garbled problems caused by Chinese content in vs2019 code
HOW TO CREATE AN INTERACTIVE CORRELATION MATRIX HEATMAP IN R
RPA advanced (II) uipath application practice
随机推荐
Installation of ROS gazebo related packages
TDSQL|就业难?腾讯云数据库微认证来帮你
【云原生】2.5 Kubernetes 核心实战(下)
亚马逊云科技 Community Builder 申请窗口开启
SSRF
ren域名有价值吗?值不值得投资?ren域名的应用范围有哪些?
基于Hardhat编写合约测试用例
Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
制造业数字化转型和精益生产什么关系
可昇級合約的原理-DelegateCall
Precautions for scalable contract solution based on openzeppelin
Native method merge word
ESP32音频框架 ESP-ADF 添加按键外设流程代码跟踪
基于 Openzeppelin 的可升级合约解决方案的注意事项
SQLite modify column type
Cluster Analysis in R Simplified and Enhanced
PX4 Position_Control RC_Remoter引入
Principe du contrat évolutif - delegatecall
MySQL linked list data storage query sorting problem
Redis exceeds the maximum memory error oom command not allowed when used memory & gt; ' maxmemory'