首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python、海运、使用statannot的统计分析看起来不太正确

Python、海运、使用statannot的统计分析看起来不太正确
EN

Stack Overflow用户
提问于 2021-06-09 13:59:08
回答 1查看 731关注 0票数 0

我使用statannot对一些基本数据进行统计测试,但是统计测试的结果似乎不正确。也就是说,我的一些比较得出了"P_val=0.000e+00 U_stat=0.000e+00",我认为这是不可能的。我的数据框架和/或代码有什么问题吗?

下面是我使用的数据框架:

这是我的密码:

代码语言:javascript
复制
import pandas as pd
from matplotlib import pyplot as plt
import seaborn as sns
from statannot import add_stat_annotation
import scipy.stats as sp

data = pd.read_excel('Z:/DMF/GROUPS/gr_Veening/Users/Vik/scRNA-seq/FACSAria/Adherence-invasion assays/adherence_invasion_assay_a549-RFP 4-6-21.xlsx',sheet_name="Sheet2", header = 0)

sns.set_theme(style="darkgrid")
ax1 = sns.boxplot(x="Strain", y="adherence_counts", data=data)
x = "Strain"
y = "adherence_counts"
order = ["D39", "D39 Δcps", "19F", "19F ΔcomCDE"]
ax1 = sns.boxplot(data=data, x=x, y=y, order=order)
plt.title("Adherence Assay")
plt.ylabel('CFU/ml')
plt.xlabel('')
ax1.set(xticklabels=["D39", "D39 Δ$\it{cps}$", "19F", "19F Δ$\it{comCDE}$"])
add_stat_annotation(ax1, data=data, x=x, y=y, order=order,
                    box_pairs=[("D39", "19F"), ("D39", "D39 Δcps"), ("D39 Δcps", "19F"), ("19F", "19F ΔcomCDE")],
                    test='Mann-Whitney', text_format='star', loc='inside', verbose=2)

最后,以下是统计测试的结果:

代码语言:javascript
复制
D39 v.s. D39 Δcps: Mann-Whitney-Wilcoxon test two-sided with Bonferroni correction, P_val=0.000e+00 U_stat=0.000e+00
D39 Δcps v.s. 19F: Mann-Whitney-Wilcoxon test two-sided with Bonferroni correction, P_val=1.000e+00 U_stat=2.000e+00
19F v.s. 19F ΔcomCDE: Mann-Whitney-Wilcoxon test two-sided with Bonferroni correction, P_val=7.617e-01 U_stat=8.000e+00
D39 v.s. 19F: Mann-Whitney-Wilcoxon test two-sided with Bonferroni correction, P_val=0.000e+00 U_stat=0.000e+00
C:\Users\Vik\anaconda3\lib\site-packages\scipy\stats\stats.py:7171: RuntimeWarning: divide by zero encountered in double_scalars
  z = (bigu - meanrank) / sd

任何帮助都将不胜感激,谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-06-11 09:39:05

你的问题来自两个方面:

  • 从统计数据来看,在某些情况下(如"D39“与"19F"),一组中的所有项目都比另一组大/小,因此是0U统计量和极值p值。很有可能得到这些结果。它来自于只检查所提供的值的等级(此测试所做的),它有其优点和局限性(+ Mann的测试也不适合如此小的样本大小,特别是在scipy假设为等方差的情况下)。
  • 现在,该行z = (bigu - meanrank) / sd失败意味着np.sqrt(T * n1 * n2 * (n1+n2+1) / 12.0) = 0,因此在本例中,n1和/或n20 (这些是len(x)len(y))。枕源所以,
代码语言:javascript
复制
- There is a bug in `statannot`, because this can happen, silently, if `order` and `box_pair` both refer to a series which does not exist in the dataframe, which I'll correct in `statannotations`. Thank you, then.

如果不是

代码语言:javascript
复制
- However, I cannot reproduce your Warning with a copy of your dataframe. If this were the only bug, you should see a missing box in your plot at the point you showed us.

,您是否可能更新了一些代码,但没有在这里复制最后一个输出?否则,可能会有更多的事情要揭露,请告诉我们。

编辑:正如在讨论中发现的,如果statannot中的orderbox_pairs和dataset中的标签不匹配,那么第二个问题就会发生。这已经在statannotations ( statannot的一个分支)中进行了修补。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67905649

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档