我正在使用seaborn 绘制一些生物学数据。
我想要一个基因相对于另一个基因的分布(在约 300 名患者中表达),并且以下代码工作正常。
graph = sns.jointplot(x='Gene1', y='Gene2', data=data, kind='reg')
我喜欢该图为我提供了良好的线性拟合以及 PearsonR 和 P 值。
但是,我想以对数刻度绘制数据,这是此类基因数据通常表示的方式。
我在网上查看了一些解决方案,但它们都摆脱了我的 PearsonR 值或线性拟合,或者它们看起来不太好。例如,下面显示了一种实现。它不显示拟合线或统计数据。
mybins=np.logspace(0, np.log(100), 100)
g = sns.JointGrid(data1, data2, data, xlim=[.5, 1000000],
ylim=[.1, 10000000])
g.plot_marginals(sns.distplot, color='blue', bins=mybins)
g = g.plot(sns.regplot, sns.distplot)
g = g.annotate(stats.pearsonr)
ax = g.ax_joint
ax.set_xscale('log')
ax.set_yscale('log')
g.ax_marg_x.set_xscale('log')
g.ax_marg_y.set_yscale('log')
这效果很好。最后,我决定将表值转换为log(x)
,因为这使得图表在短期内更容易缩放和可视化。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)