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

这是我的密码:
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)最后,以下是统计测试的结果:
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任何帮助都将不胜感激,谢谢!
发布于 2021-06-11 09:39:05
你的问题来自两个方面:
scipy假设为等方差的情况下)。z = (bigu - meanrank) / sd失败意味着np.sqrt(T * n1 * n2 * (n1+n2+1) / 12.0) = 0,因此在本例中,n1和/或n2是0 (这些是len(x)和len(y))。枕源所以,- 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.如果不是
- 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中的order、box_pairs和dataset中的标签不匹配,那么第二个问题就会发生。这已经在statannotations ( statannot的一个分支)中进行了修补。
https://stackoverflow.com/questions/67905649
复制相似问题