我有一个包含数千个样本的csv,应该比较不同处理后的基因表达:
ID U1 U2 U3 H1 H2 H3
1 5.95918 6.07211 6.01437 5.89113 5.89776 5.95443
2 6.56789 5.98897 6.67844 5.78987 6.01789 6.12789
..
Run Code Online (Sandbox Code Playgroud)
我被要求做曼恩·惠特尼(Mann Whitney)u测试,当我使用它时,R正在给我结果:
results <- apply(data,1,function(x){wilcox.test(x[1:3],x[4:6])$pvalue})
Run Code Online (Sandbox Code Playgroud)
但是,我只得到0.1或0.5之类的值。
当我添加时,alternative ="greater"我得到的值为0.35000或0.05000,而一些样本得到的p值为0.14314(这是我可以接受的值)。所以我想知道为什么R给我这样奇怪的pvalues(0.35000,..),以及如何解决它以获得“正常” pvalues。
我正在使用包中的HSD.test函数进行 TukeyHSD 事后测试。该函数工作正常,但我不确定 p 值隐藏在哪里。中的字母表示重要性,但实际的 p 值在哪里?谢谢agricolaeRgroups
library(agricolae)
data(sweetpotato)
model<-aov(yield~virus, data=sweetpotato)
out <- HSD.test(model,"virus", group=TRUE,console=TRUE,
main="Yield of sweetpotato\nDealt with different virus")
Study: Yield of sweetpotato
Dealt with different virus
HSD Test for yield
Mean Square Error: 22.48917
virus, means
yield std r Min Max
cc 24.40000 3.609709 3 21.7 28.5
fc 12.86667 2.159475 3 10.6 14.9
ff 36.33333 7.333030 3 28.0 41.8
oo 36.90000 4.300000 3 32.1 40.4
Alpha: 0.05 ; DF Error: 8
Critical …Run Code Online (Sandbox Code Playgroud) 我正在尝试对数据集的几行进行单向方差分析,然后提取 p_value 以供使用。
这是我所做的:
anova <- function(x) {summary(aov(x ~ bt.factor))[[1]]["Pr(>F)"]}
anv.pval <- apply(golubALL, 1, anova)
Run Code Online (Sandbox Code Playgroud)
使用这个公式,我可以提取 pvalue 但它带有其他元素:
$`1414_at`
Pr(>F)
bt.factor 0.7871
Residuals
Run Code Online (Sandbox Code Playgroud)
结果我想要的只是列表中的这个。我怎么能提取它?
我正在尝试计算与随时变系数的Cox PH模型获得的点估计相关的P值。我编写的函数没有提供正确的P值。我将通过使用生存包中的NCCTG肺癌数据来说明这一点。
# Setup
require(survival)
# Effect of Karnofsky score, linear
fit <- coxph(Surv(time/365.25, status == 2) ~ ph.karno + tt(ph.karno),
lung, tt=function(x, t, ...) {x*t})
Run Code Online (Sandbox Code Playgroud)
功能:
# Same function but now with a P-value in the output
calculate.timeDependentHazard.P <- function(model,time) {
index.1 <- which(names(model$coef)=="ph.karno")
index.2 <- which(names(model$coef)=="tt(ph.karno)")
coef <- model$coef[c(index.1,index.2)]
var <- rbind(c(model$var[index.1,index.1],model$var[index.1,index.2]),
c(model$var[index.2,index.1],model$var[index.2,index.2]))
var.at.time <- t(c(1,time)) %*% var %*% c(1,time)
hazard.at.time <- t(c(1,time)) %*% coef
lower.95 <- hazard.at.time - 1.96*sqrt(var.at.time)
upper.95 <- hazard.at.time + …Run Code Online (Sandbox Code Playgroud) 我有一个data.frame dfP与一列Spearman_p包含的p值(数字数据)。我想用它们代替p值摘要星号。我使用以下代码:
dfP$Spearman_p[dfP$Spearman_p < 0.0001] <- "****"
dfP$Spearman_p[dfP$Spearman_p < 0.001] <- "***"
dfP$Spearman_p[dfP$Spearman_p < 0.01] <- "**"
dfP$Spearman_p[dfP$Spearman_p < 0.05] <- "*"
dfP$Spearman_p[dfP$Spearman_p > 0.05] <- "ns"
Run Code Online (Sandbox Code Playgroud)
但是,这会将所有 <0.05的p值(<0.01的那些)也更改为*(一星)。
我怀疑R在后续步骤中将****视为数字<0.05。那是对的吗?如果是这样,请问我该如何规避?
谢谢。
我正在使用 var.test 并且我想检索 p 值。有什么建议吗?
x <- rnorm(50, mean = 0, sd = 2)
y <- rnorm(30, mean = 1, sd = 1)
var.test(x, y)
Run Code Online (Sandbox Code Playgroud)
比较两个方差的 F 检验
数据:x 和 y F = 5.6877,num df = 49,denom df = 29,p 值 = 3.839e-06 备择 假设:真实方差比不等于 1 95% 置信区间:2.85764 10.70096 样本估计值:比率差异 5.687715
当看着系数的表款它列出.,*,**,或***旁边的P值。
他们在底部指出了这一点(但我发现这实际上使我感到困惑):
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
我的一个模型的P值为0.00506,其中**。但是,根据以上内容,这对我来说没有意义。我认为我已经比实际情况更加混乱了!
因此,在痛苦地简单地做什么的*,**,***的等同于?
我想做以下配对t检验:
str1<-' ENSEMBLE 0.934 0.934 0.934 0.934 '
str2<-' J48 0.934 0.934 0.934 0.934 '
df1 <- read.table(text=scan(text=str1, what='', quiet=TRUE), header=TRUE)
df2 <- read.table(text=scan(text=str2, what='', quiet=TRUE), header=TRUE)
t.test ( df1$ENSEMBLE, df2$J48, mu=0 , alt="two.sided", paired = T, conf.level = 0.95)
Run Code Online (Sandbox Code Playgroud)
我得到以下结果:
Paired t-test
data: df1$ENSEMBLE and df2$J48
t = NaN, df = 3, p-value = NA
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
NaN NaN
sample estimates:
mean of the differences
0 …Run Code Online (Sandbox Code Playgroud) p-value ×8
r ×8
anova ×2
apply ×1
broom ×1
dataframe ×1
function ×1
posthoc ×1
statistics ×1
substitution ×1