python - tkinter RuntimeError when using matplotlib in a snakemake workflow (no GUI needed) -


i use snakemake workflow management tool, , in 1 of workflows, added piece of python code uses matplotlib (via pandas) generate figures, and, seems, tkinter, because following error message displayed:

error in atexit._run_exitfuncs: traceback (most recent call last):   file "/home/bli/lib/python3.6/tkinter/__init__.py", line 767, in after_cancel     data = self.tk.call('after', 'info', id) runtimeerror: main thread not in main loop 

no more traceback appears, don't know causing error.

my ~/.config/matplotlib/matplotlibrc contains following:

backend      : tkagg 

this answer says following:

tkinter intended run in single thread. is, tkinter gui calls should originate single thread (usually, not necessarily, main thread).

my code doesn't open gui, , running snakemake 1 processor (or think: did not use option -j).

it seems snakemake doesn't mind error, , figures generated , seem normal.

what happening?

i'm not sure help, here piece of workflow running when error message displayed:

def plot_ma(res):     fig, ax = plt.subplots()     status, group in res.groupby('status'):         group.plot.scatter(x="basemean", y="lfcmle", s=2, logx=true, c=status2colour[status], label=status, ax=ax)   rule plot_ma_plot:     input:         deseq_results = rules.differential_expression.output.deseq_results,     output:         ma_plot = opj(mapping_dir, aligner, "mapped_c_elegans", counter, "deseq2", "{contrast}", "{orientation}_{biotype}", "ma.pdf"),     run:         if test_na_file(input.deseq_results):             warnings.warn(                 "no deseq2 results %s_%s_%s. making dummy output." % (                     wildcards.contrast, wildcards.orientation, wildcards.biotype))             outfile in output:                 shell(f"echo 'na' > {outfile}")         else:             res = pd.read_table(input.deseq_results, index_col=0)             save_plot(                 output.ma_plot, plot_ma, res,                 title="ma-plot %s, %s_%s" % (                     wildcards.contrast, wildcards.orientation, wildcards.biotype)) 

test_na_file , save_plot defined in external modules, follows:

def save_plot(outfile, plot_func, *args, title=none, format=none, **kwargs):     """*format* needed when using multiple pages output."""     plot_func(*args, **kwargs)     if title not none:         plt.gcf().suptitle(title)     if format none:         plt.savefig(outfile)     else:         plt.savefig(outfile, format=format) 

and

def test_na_file(fname):     open(fname, "r") f:         firstline = f.readline().strip()     return firstline == "na" 


Comments

Popular posts from this blog

Add new key value to json node in java -

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

javascript - Highcharts Synchronized charts with missing data points -