文章目录

  • 前言
  • 一、T 检验和wilcoxon秩和检验,怎么选?
  • 二、T 检验
    • 1. 单一样本t检验
    • 2. 配对样本t检验
    • 3. 独立样本t检验
    • 4. 检验方向
    • 4. 用R语言来做t检验
  • 三、wilcoxon秩和检验
  • 四、可视化画图(boxplot 箱图)

前言

所谓显著性差异,就是证明数据的差异不是偶然发生的。生信分析中九成以上的问题,本质上就是寻找差异或者证明差异。


一、T 检验和wilcoxon秩和检验,怎么选?

简单的说,T检验主要关注样本平均数的差异,而wilcoxon秩和检验是基于样本内数据的秩(排序)与值,关注中位数的差异。T检验的前提是数据正态分布,如何判断,见R语言检验数据正态分布。

二、T 检验

1. 单一样本t检验

单一样本t检验(One-sample t test),是用来比较一组数据和一个特定数值有无显著性差异。应用场景:20个肿瘤样本中,判断某个基因X测序后来的count数是否高于、低于还是等于25(前提是count符合正态分布)。

2. 配对样本t检验

配对样本t检验(paired-samples t test),要求两组数据每对之间要有一定的对应关系。比如:(1)同一组样本在处理前后的平均值有无显著性差异(这个好理解,处理前样本与处理后对应,比如一个人饭前饭后的体重)。(2)癌和癌旁(一定是对应的样本)某些特征的显著性差异。(3)有配对关系的样本,用不同处理方式处理。

3. 独立样本t检验

独立样本t检验(independent t test),比较两组独立数据有无显著性差异。应用场景:(1)TCGA数据库中的肿瘤样本与正常样本(他们来自不同patients,与癌与癌旁不一样)。(2)不同分子分型的肿瘤样本比较。

4. 检验方向

单尾检验和双尾检验的区别在于是否拒绝H0标准。单尾需要选择方向,假设包含一个<小于符号,则使用左尾;假设包含一个>大于符号,则使用右尾。双尾检验即拒绝域一分为二位于数据集的两侧,两侧各占α/2,总和为α。

4. 用R语言来做t检验

# One sample t test : 单一样本t检验
# Comparison of an observed mean with a
# a theoretical mean
t.test(x, mu=0)
# Paired t test :配对样本t检验
t.test(x, y, paired=TRUE)
# Independent t test:独立样本t检验
# Comparison of the means of two independent samples (x & y)
t.test(x, y)
# Paired t test
t.test(x, y, paired=TRUE)

Arguments
x
a (non-empty) numeric vector of data values.

y
an optional (non-empty) numeric vector of data values.

alternative
a character string specifying the alternative hypothesis, must be one of “two.sided” (default), “greater” or “less”. You can specify just the initial letter.

mu
a number indicating the true value of the mean (or difference in means if you are performing a two sample test).

paired
a logical indicating whether you want a paired t-test.

var.equal
a logical variable indicating whether to treat the two variances as being equal. If TRUE then the pooled variance is used to estimate the variance otherwise the Welch (or Satterthwaite) approximation to the degrees of freedom is used.

alternative是用来假设方向的参数。“two.sided”, “less”, “greater” 双尾 左尾 右尾
t.test(x, y, alternative=c(“two.sided”, “less”, “greater”))
双尾,左尾,右尾,假设不同,P值不同,得出的显著性结论不同。

> t.test(1:10, y = c(7:20, 200))Welch Two Sample t-testdata:  1:10 and c(7:20, 200)
t = -1.6329, df = 14.165, p-value = 0.1245
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:-47.242900   6.376233
sample estimates:
mean of x mean of y 5.50000  25.93333 > t.test(1:10, y = c(7:20, 200), alternative = "less")Welch Two Sample t-testdata:  1:10 and c(7:20, 200)
t = -1.6329, df = 14.165, p-value = 0.06226
alternative hypothesis: true difference in means is less than 0
95 percent confidence interval:-Inf 1.588745
sample estimates:
mean of x mean of y 5.50000  25.93333 > t.test(1:10, y = c(7:20, 200), alternative = "great")Welch Two Sample t-testdata:  1:10 and c(7:20, 200)
t = -1.6329, df = 14.165, p-value = 0.9377
alternative hypothesis: true difference in means is greater than 0
95 percent confidence interval:-42.45541       Inf
sample estimates:
mean of x mean of y 5.50000  25.93333 

三、wilcoxon秩和检验

直接上马

> x <- c(1.83,  0.50,  1.62,  2.48, 1.68, 1.88, 1.55, 3.06, 1.30)
> y <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29)
> wilcox.test(x, y, paired = TRUE, alternative = "greater")Wilcoxon signed rank exact testdata:  x and y
V = 40, p-value = 0.01953
alternative hypothesis: true location shift is greater than 0> wilcox.test(x, y, paired = TRUE, alternative = "less")Wilcoxon signed rank exact testdata:  x and y
V = 40, p-value = 0.9863
alternative hypothesis: true location shift is less than 0> wilcox.test(x, y, paired = TRUE, alternative = "two.sided")Wilcoxon signed rank exact testdata:  x and y
V = 40, p-value = 0.03906
alternative hypothesis: true location shift is not equal to 0> wilcox.test(x, y, paired = F, alternative = "greater")Wilcoxon rank sum test with continuity correctiondata:  x and y
W = 58, p-value = 0.06646
alternative hypothesis: true location shift is greater than 0Warning message:
In wilcox.test.default(x, y, paired = F, alternative = "greater") :无法精確計算带连结的p值

四、可视化画图(boxplot 箱图)

library(ggplot2)
library(ggsignif)
library(ggpubr)
library(RColorBrewer)
A <- c(1.83,  0.50,  1.62,  2.48, 1.68, 1.88, 1.55, 3.06, 1.30)
B <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29)
C <- A+1
D <- B+1
plot_data <- data.frame(A,B,C,D)
require(tidyr)
plot_data <- gather(plot_data)
colnames(plot_data) <- c("group","test_data")#-----------------------
p<- ggplot(data=plot_data)+ geom_boxplot(mapping=aes(x=group,y=test_data,colour = group ), #箱线图alpha = 0.5,size=1.5,width = 0.6)+ geom_jitter(mapping=aes(x=group,y=test_data,colour = group), #散点alpha = 0.3,size=3)+scale_color_manual(limits=c("A","B","C","D"), values=c("#85B22E","#5F80B4","#E29827","#922927"))+ #颜色geom_signif(mapping=aes(x=group,y=test_data), # 不同组别的显著性comparisons = list(c("A", "B"), # 哪些组进行比较c("A", "C"),c("A", "D"),c("B", "C"),c("B", "D"),c("C", "D")),map_signif_level=T, # T显示显著性,F显示p valuetip_length=c(0,0,0,0,0,0,0,0,0,0,0,0), # 修改显著性线两端的长短y_position = c(2.9,3.6,3.8,3.4,3.2,2.9), # 设置显著性线的位置高度size=1, # 修改线的粗细textsize = 4, # 修改显著性标记的大小test = "t.test")+ # 检验的类型theme_classic(  # 主题设置,这个是无线条主题base_line_size = 1 # 坐标轴的粗细)+labs(title="EXAMPLE A",x="",y="test_data")+ # 添加标题,x轴,y轴内容theme(plot.title = element_text(size = 15,colour = "black",hjust = 0.5),axis.title.y = element_text(size = 15, # family = "myFont", color = "black",face = "bold", vjust = 1.9, hjust = 0.5, angle = 90),legend.title = element_text(color="black", # 修改图例的标题size=15, face="bold"),legend.text = element_text(color="black", # 设置图例标签文字size = 10, face = "bold"),axis.text.x = element_text(size = 13,  # 修改X轴上字体大小,color = "black", # 颜色face = "bold", #  face取值:plain普通,bold加粗,italic斜体,bold.italic斜体加粗vjust = 0.5, # 位置hjust = 0.5, angle = 0), #角度axis.text.y = element_text(size = 13,  color = "black",face = "bold", vjust = 0.5, hjust = 0.5, angle = 0) )
p

t检验和wilcoxon秩和检验 判断两组数据间的显著性差异相关推荐

  1. python怎么分析数据差异的方法_如何比较两组数据之间的差异性

    展开全部 1, 首先,分别把这两组数据分别设为x和y,打开SPSS,点击左下角的Variable  View选项卡,e5a48de588b6323131333532363134313032313635 ...

  2. datagrid出现相同两组数据_stata 数据操作基础知识:以一篇论文数据操作为例

    stata 数据操作基础知识:以一篇论文数据操作为例 上节回顾及问题 统计学学习大图景 数据描述 分位数回归 存在的问题: 1.学了就要多使用,哪怕生搬硬套也要多用 2.时间序列的方法,大家可以操作, ...

  3. datagrid出现相同两组数据_数据分析之统计学

    统计学知识 思维导图 第一节 统计学基本原理 数据分析相关概念 一.描述统计 测量尺度 1.定类(nominal) 功能:分类的作用,比如性别 2.定序(ordinal) 功能:分类.排序的作用,比如 ...

  4. 比较两组数据的差异用什么图更直观_试验数据统计中常用的 量,图,和线再也不担心文章的统计用图了!...

    本文来源:小麦研究联盟 今天跟大家详细总结一下我们农业试验数据统计中常用的 量,图,和线. 如果不想看下边长篇大论,请看小编给您总结的懒人包: 标准差: 群体的标准差是群体中所有数据方差的平方根,它衡 ...

  5. 检验两组数据是否显著差异_SPSS非参数两个相关样本检验

    01 原理与方法 两个相关样本检验的方法主要有:Wilcoxon检验.Sign(符号)检验.McNemar检验和Marginal Homogeneity(边际同质性)检验等. Sign(符号)检验 配 ...

  6. excel 两组数据交点_30秒即可完成Excel数据对比,超高效率,快学起来不要犹豫!...

    在工作中,我们很经常需要比对两组甚至以上的Excel数据是否一致,如果数据少的话我们还能够慢慢看,数据要是对的话,用肉眼去看的话恐怕眼睛就可以不要了. 今天小编为大家带来五个能帮我们快速对比Excel ...

  7. 比较两组数据的差异用什么图更直观_你真的懂如何展示数据吗?

    ↑ 关注 + 星标 ~ 有趣的不像个技术号每晚九点,我们准时相约  偶尔应金主爸爸要求改时间  大家好,我是朱小五 如何来展现的你的数据?是你有时不得不去思考的一个问题. 不同的展示方法,其效果往往差 ...

  8. matlab两组数据的相关度,怎么分析两组数据的相关性?比如A=【1 2 3 4 5 6 7 】 B=【2 3 4 5 6 7 8】 最好用MATLAB...

    怎么分析两组数据的相关性?比如A=[1 2 3 4 5 6 7 ] B=[2 3 4 5 6 7 8] 最好用MATLAB 关注:261  答案:2  手机版 解决时间 2021-01-12 04:4 ...

  9. R语言plotly可视化:plotly可视化分裂的分组小提琴图、每个小提琴图内部分为两组数据、每个分组占小提琴图的一半(Split violin plot in R with plotly)

    R语言plotly可视化:plotly可视化分裂的分组小提琴图.每个小提琴图内部分为两组数据.每个分组占小提琴图的一半(Split violin plot in R with plotly) 目录

  10. excel 两组数据交点_初识Python 数据可视化

    ✨  冒号说:发着小光小热的小点点 ✨    "一图胜千言."          ----Arthur Brisbane 听说这个最近很火!在这个信息爆炸的时代,科技虽然使得数据获 ...

最新文章

  1. Debian 9.x “stretch“ 解决 /etc/rc.local 开机启动问题
  2. sdut 1479 数据结构实验之栈与队列九:行编辑器
  3. bootstrap中modal弹出框的使用
  4. android快速打包工具下载,【Android】多渠道打包,其实可以更快
  5. 犹太人从未透露的12个秘密(图)
  6. 【视频】视频文件格式和视频编码
  7. Oracle数据库存储过程 ,去除给定字符串中重复的字符串
  8. web.config 加密/解密
  9. 所有电商API接口,淘宝API接口分类,1688API、拼多多API、京东API
  10. 前端vs图片:2 图片深度、图片分类等基本信息
  11. ElasticSearch 中文同义词实现
  12. 魔方机器人之搭建Python编程环境
  13. echarts-地图使用/配合散点图展示空气质量
  14. uniapp中,H5端使用html2canvas生成海报
  15. 【分子相互作用】基于MATLAB的分子相互作用的表征模型仿真
  16. Python生成器与迭代器
  17. 安卓APP——网页访问(WebView)
  18. CAN总线协议报文浅析
  19. 【无标题】 二手车汽车资质认证 二手车汽车资质认证
  20. 阿里痛斥纵容造假包庇售假是社会公敌,对比四平台打假凸显“阿里力度”

热门文章

  1. labview 编程样式_LabVIEW编程实例:一个简单通用的“关于”对话框模板实现
  2. C++实现华氏温度转为摄氏温度
  3. 关于逻辑关系 “隐含(implies、p-q) 的理解
  4. html显示空间图片,qq空间显示不出来 为什么QQ空间有些图片显示不了
  5. MATLAB | 分形的艺术——(Mandelbrot)曼德勃罗特集合
  6. 什么是局域网?什么是广域网?CCNP是什么证书?电信能提供长途数据线路吗?
  7. 用眼学计算机,专家提醒:电脑使用者要学会科学用眼
  8. python开发_filecmp
  9. Docker端口映射实例
  10. 向量叉积和点积混合运算_叉乘点乘混合运算公式