arq5x / poretools

a toolkit for working with Oxford nanopore data
MIT License
241 stars 90 forks source link

couldn't connect to display error #78

Open igordot opened 8 years ago

igordot commented 8 years ago

I am trying to run poretools hist remotely, but it fails due to display error:

INFO:poretools:100 files processed.
INFO:poretools:200 files processed.
INFO:poretools:300 files processed.
INFO:poretools:400 files processed.
INFO:poretools:500 files processed.
INFO:poretools:600 files processed.
INFO:poretools:700 files processed.
INFO:poretools:800 files processed.
X11 connection rejected because of wrong authentication.
Traceback (most recent call last):
  File "/ifs/home/id/.local/bin/poretools", line 9, in <module>
    load_entry_point('poretools==0.5.1', 'console_scripts', 'poretools')()
  File "/ifs/home/id/.local/lib/python2.7/site-packages/poretools-0.5.1-py2.7.egg/poretools/poretools_main.py", line 513, in main
    args.func(parser, args)
  File "/ifs/home/id/.local/lib/python2.7/site-packages/poretools-0.5.1-py2.7.egg/poretools/poretools_main.py", line 53, in run_subtool
    submodule.run(parser, args)
  File "/ifs/home/id/.local/lib/python2.7/site-packages/poretools-0.5.1-py2.7.egg/poretools/hist.py", line 39, in run
    plot_hist(sizes, args)
  File "/ifs/home/id/.local/lib/python2.7/site-packages/poretools-0.5.1-py2.7.egg/poretools/hist.py", line 19, in plot_hist
    plt.hist(sizes, args.num_bins)
  File "/local/apps/python/2.7.3/lib/python2.7/site-packages/matplotlib-1.4.3-py2.7-linux-x86_64.egg/matplotlib/pyplot.py", line 2885, in hist
    ax = gca()
  File "/local/apps/python/2.7.3/lib/python2.7/site-packages/matplotlib-1.4.3-py2.7-linux-x86_64.egg/matplotlib/pyplot.py", line 828, in gca
    ax =  gcf().gca(**kwargs)
  File "/local/apps/python/2.7.3/lib/python2.7/site-packages/matplotlib-1.4.3-py2.7-linux-x86_64.egg/matplotlib/pyplot.py", line 462, in gcf
    return figure()
  File "/local/apps/python/2.7.3/lib/python2.7/site-packages/matplotlib-1.4.3-py2.7-linux-x86_64.egg/matplotlib/pyplot.py", line 435, in figure
    **kwargs)
  File "/local/apps/python/2.7.3/lib/python2.7/site-packages/matplotlib-1.4.3-py2.7-linux-x86_64.egg/matplotlib/backends/backend_tkagg.py", line 81, in new_figure_manager
    return new_figure_manager_given_figure(num, figure)
  File "/local/apps/python/2.7.3/lib/python2.7/site-packages/matplotlib-1.4.3-py2.7-linux-x86_64.egg/matplotlib/backends/backend_tkagg.py", line 89, in new_figure_manager_given_figure
    window = Tk.Tk()
  File "/local/apps/python/2.7.3/lib/python2.7/lib-tk/Tkinter.py", line 1685, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display "localhost:10.0"

I thought that adding --saveas would prevent that, but it doesn't. Is there any way to get around that?

dbtara commented 8 years ago

This seems to be en error related to matplotlib rather then poretools. This happens when you are running a headless system (that is no display connected) or if you are ssh'ing into a system and don't have X-forwarding setup. I was able to get this to run by following the directions given here http://stackoverflow.com/questions/2801882/generating-a-png-with-matplotlib-when-display-is-undefined which basically involved finding the .matplotlibrc and making a setting change to make this permanent.

johnsolk commented 8 years ago

I encountered this same error and fixed by editing the scripts directly (with help from this page), changing the order that matplotlib is imported relative to the other libraries:

/usr/local/lib/python2.7/dist-packages/poretools-.0.5.1-py2.7.egg/poretools/hist.py

import sys
import time

import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as plt

import seaborn as sns
import Fast5File

import logging

/usr/local/lib/python2.7/dist-packages/poretools-.0.5.1-py2.7.egg/poretools/yield_plot.py

import Fast5File
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as plt

import numpy as np
import pandas as pd
import seaborn as sns

#logging
import logging
johnsolk commented 8 years ago

Here's a tutorial I wrote that includes poretools, with this fix in the middle: http://angus.readthedocs.io/en/2016/analyzing_nanopore_data.html

wzylin commented 7 years ago

Hi @ljcohen, do you mean delete the "#" before matplotlib.use('Agg') in both files? I tried, but it still not working. Any suggestion? Thank you!

~/opt/poretools/test_data$ poretools squiggle --saveas pdf 2016_3_4_3507_1_ch13_read1474_strand.fast5 /usr/local/lib/python2.7/dist-packages/IPython/html.py:14: ShimWarning: The IPython.html package has been deprecated. You should import from notebook instead. IPython.html.widgets has moved to ipywidgets. "IPython.html.widgets has moved to ipywidgets.", ShimWarning) Traceback (most recent call last): File "/home/wzylin/opt/poretools/poretools/scripts/poretools", line 5, in poretools.poretools_main.main() File "/home/wzylin/.local/lib/python2.7/site-packages/poretools-0.6.0-py2.7.egg/poretools/poretools_main.py", line 533, in main args.func(parser, args) File "/home/wzylin/.local/lib/python2.7/site-packages/poretools-0.6.0-py2.7.egg/poretools/poretools_main.py", line 55, in run_subtool submodule.run(parser, args) File "/home/wzylin/.local/lib/python2.7/site-packages/poretools-0.6.0-py2.7.egg/poretools/squiggle.py", line 85, in run do_plot_squiggle(args, first_fast5) File "/home/wzylin/.local/lib/python2.7/site-packages/poretools-0.6.0-py2.7.egg/poretools/squiggle.py", line 61, in do_plot_squiggle plot_squiggle(args, fast5.filename, start_times, mean_signals) File "/home/wzylin/.local/lib/python2.7/site-packages/poretools-0.6.0-py2.7.egg/poretools/squiggle.py", line 39, in plot_squiggle grid = sns.FacetGrid(df, row="cat", sharex=False, size=8) File "/home/wzylin/.local/lib/python2.7/site-packages/seaborn-0.7.1-py2.7.egg/seaborn/axisgrid.py", line 307, in init fig, axes = plt.subplots(nrow, ncol, kwargs) File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 1177, in subplots fig = figure(fig_kw) File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 527, in figure kwargs) File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt4agg.py", line 46, in new_figure_manager return new_figure_manager_given_figure(num, thisFig) File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt4agg.py", line 53, in new_figure_manager_given_figure canvas = FigureCanvasQTAgg(figure) File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt4agg.py", line 76, in init FigureCanvasQT.init(self, figure) File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt4.py", line 68, in init** _create_qApp() File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt5.py", line 138, in _create_qApp raise RuntimeError('Invalid DISPLAY variable') RuntimeError: Invalid DISPLAY variable