我正在尝试使用Plotly绘制小提琴图:
x = ['00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '10', '10', '10', '10', '10', '10', '10', '10', '10', '10', '10', '10', '10', '10', '
10', '10', '10', '10', '10', '10', '11', '11', '11', '11', '11', '11', '11', '11', '11', '11', '11', '11', '11', '11']
y = [0.952380952381, 0.965277777778, 1.0, 0.989166666667, 1.0, 1.0, 0.958333333333, 0.947916666667, 0.885416666667, 0.979166666667, 1.0, 1.0, 1.0, 1.0, 0.989583333333, 0.802083333333, 0.828125, 0.881944444444, 1.0, 1.0, 0.927083333333, 0.791666666667, 1.0, 0.979166666667, 0.9
65773809524, 0.427083333333, -3.5527136788e-15, 0.0, 0.0, 0.0, -1.7763568394e-15, 0.770833333333, 0.479166666667, 0.444444444444, 0.666666666667, 0.395833333333, 0.489583333333, 0.458333333333, 0.375, 0.447916666667, 0.458333333333, 0.470833333333, 0.449652777778, 0.40625
, 0.03125, 0.0, 0.194444444444, 0.0, 0.0, 0.0, 0.0104166666667, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
这些被传递到模块visualizer.py
中的以下函数:
def violin(x, y, name, path):
data = pd.DataFrame(dict(Y = y, X = x))
print(data)
fig = ff.create_violin(data, data_header = 'X', group_header = 'Y')
plotly.plot(fig, filename = os.path.join(path, 'violin_' + name + '.html'), auto_open = False)
其他参数无关紧要,因为它们仅指定输出位置。
它抛出一个奇怪的堆栈轨迹,抱怨输入矩阵奇异:
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/share/Codes/NebulousSerendipity/src/python/kmer/programming.py", line 421, in <module>
getattr(sys.modules[__name__], c.job).launch(resume_from_reduce = c.resume_from_reduce)
File "/share/Codes/NebulousSerendipity/src/python/kmer/programming.py", line 386, in launch
job.execute()
File "kmer/map_reduce.py", line 74, in execute
self.load_inputs()
File "/share/Codes/NebulousSerendipity/src/python/kmer/programming.py", line 411, in load_inputs
visualizer.violin(x, y, 'LP_' + self.batch_file_prefix, self.get_current_job_directory(), x_label = 'real genotype', y_label = 'LP value')
File "kmer/visualizer.py", line 58, in violin
fig = ff.create_violin(data, data_header = 'LP', group_header = 'Zygosity')
File "/share/Codes/NebulousSerendipity/venv2/local/lib/python2.7/site-packages/plotly/figure_factory/_violin.py", line 621, in create_violin
height, width, title
File "/share/Codes/NebulousSerendipity/venv2/local/lib/python2.7/site-packages/plotly/figure_factory/_violin.py", line 228, in violin_no_colorscale
rugplot=rugplot)
File "/share/Codes/NebulousSerendipity/venv2/local/lib/python2.7/site-packages/plotly/figure_factory/_violin.py", line 175, in violinplot
pdf = scipy_stats.gaussian_kde(vals)
File "/share/Codes/NebulousSerendipity/venv2/local/lib/python2.7/site-packages/scipy/stats/kde.py", line 172, in __init__
self.set_bandwidth(bw_method=bw_method)
File "/share/Codes/NebulousSerendipity/venv2/local/lib/python2.7/site-packages/scipy/stats/kde.py", line 499, in set_bandwidth
self._compute_covariance()
File "/share/Codes/NebulousSerendipity/venv2/local/lib/python2.7/site-packages/scipy/stats/kde.py", line 510, in _compute_covariance
self._data_inv_cov = linalg.inv(self._data_covariance)
File "/share/Codes/NebulousSerendipity/venv2/local/lib/python2.7/site-packages/scipy/linalg/basic.py", line 976, in inv
raise LinAlgError("singular matrix")
numpy.linalg.linalg.LinAlgError: singular matrix
此代码通常可以使用,但此特定输入似乎有问题。该怎么办?