简体   繁体   English

使用R和GraphPad Prism进行分位数计算

[英]Quantile calculations using R and GraphPad Prism

I'm new in R. Before using R, I used GraphPad Prism 7.0. 我是R语言的新手。在使用R语言之前,我使用了GraphPad Prism 7.0。 Só now I'm trying to compare both as data processors. 现在,我正在尝试将两者作为数据处理器进行比较。 I founded a difference in the quantile calculations, so anyone know why they are differents?? 我在分位数计算中发现了差异,所以有人知道为什么它们是不同的吗?

In R i have 在R我有

par(pty="s", cex.axis=1, las=1, cex.lab=1)
a1=c(22.02, 23.83,  26.67,  25.38,  25.49,  23.50,  25.90,  24.89, 25)
a2=c(21.49, 22.67,  24.62,  24.18,  22.78,  22.56,  24.46,  23.79, 25)
a3=c(20.33, 21.67,  24.67,  22.45,  22.29,  21.95,  20.49,  21.81, 25)
boxplot(a1,a2,a3, names=c("a1","a2","a3"), ylab="Valor", ylim=c(20,28))

在此处输入图片说明

And the quantiles for a3 are a3的分位数是

quantile(a3)
   0%   25%   50%   75%  100% 
20.33 21.67 21.95 22.45 25.00

Plotting the same data in GraphPad Prism: 在GraphPad Prism中绘制相同的数据:

Graph Family: Column Box & whiskers Plot: tukey 图族:圆柱盒和晶须图:tukey

I get 我懂了

在此处输入图片说明

And the quantiles are 分位数是

在此处输入图片说明

Why they are differents (Particulary a3)?? 为什么它们不同(特别是a3)?

Why R recognize 4 outliers in a3 and GraphPad does not? 为什么R在a3中识别出4个离群值而GraphPad无法识别?

Suggestions?? 建议?

As @lmo says, R has many ways to calculate quantiles. 正如@lmo所说,R有许多计算分位数的方法。 By default, R uses the type=7 . 默认情况下,R使用type=7 GraphPad uses a method equivalent to type=6 in R. So the way I founded was GraphPad使用等效于R中type=6的方法。所以我建立的方式是

par(pty="s", cex.axis=1, las=1, cex.lab=1)
a1=c(22.02, 23.83,  26.67,  25.38,  25.49,  23.50,  25.90,  24.89, 25)
a2=c(21.49, 22.67,  24.62,  24.18,  22.78,  22.56,  24.46,  23.79, 25)
a3=c(20.33, 21.67,  24.67,  22.45,  22.29,  21.95,  20.49,  21.81, 25)
boxplot(
  quantile(a1,type=6),
  quantile(a2,type=6),
  quantile(a3,type=6), 
  names=c("a1","a2","a3"), ylab="Valor", ylim=c(20,28))

在此处输入图片说明

And

> quantile(a1,type=6)
    0%    25%    50%    75%   100% 
22.020 23.665 25.000 25.695 26.670 
> quantile(a2,type=6)
    0%    25%    50%    75%   100% 
21.490 22.615 23.790 24.540 25.000 
> quantile(a3,type=6)
   0%   25%   50%   75%  100% 
20.33 21.08 21.95 23.56 25.00

Same as GraphPad 与GraphPad相同

Answering the question how to use different quantile calculations in a boxplot: 回答如何在箱图中使用不同的分位数计算的问题:

This is easy with ggplot2. 使用ggplot2很容易。

DF <- data.frame(a1, a2, a3)
DF <- stack(DF)

quants <- tapply(DF$values, list(DF$ind), quantile, type = 6)
quants <- as.data.frame(do.call(rbind, quants))
quants$g <- rownames(quants)

library(ggplot2)
ggplot(quants, aes(x = g, lower = `25%`, 
                   middle = `50%`, upper = `75%`,
                   ymin = `0%`, ymax = `100%`)) +
  geom_boxplot(stat = "identity")

结果图

You can then customize this plot further as explained in many ggplot2 tutorials. 然后,您可以按照许多ggplot2教程中的说明进一步自定义此图。

PS: However, I would use R's default boxplot stats since these try to reproduce Tukey's boxplot. PS:但是,我将使用R的默认箱形图统计信息,因为它们试图重现Tukey的箱形图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM