mhorlbeck / ScreenProcessing

58 stars 31 forks source link

Running screen_analysis.py return a TypeError #24

Closed yeroslaviz closed 1 year ago

yeroslaviz commented 1 year ago

When running the example from the Demo folder with iPython, I keep getting this error trying to create the plots interactively

In [1]: run screen_analysis.py
In [2]: data = loadData("Demo/Step3/ctx_demo_full")
In [3]: phenotypeHistogram(data=data, phenotype="gamma",replicate = "Rep1")
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 phenotypeHistogram(data=data, phenotype="gamma",replicate = "Rep1")

File ~/ownCloud/ownCloud_projects/AG_Murray/MonikaH/P576_CRISPR/P576_Analysis/ScreenProcessing/screen_analysis.py:266, in phenotypeHistogram(data, phenotype, replicate)
    263 axis.set_ylabel('Number of sgRNAs')
    265 plt.tight_layout()
--> 266 return displayFigure(fig, 'phenotype_hist')

File ~/ownCloud/ownCloud_projects/AG_Murray/MonikaH/P576_CRISPR/P576_Analysis/ScreenProcessing/screen_analysis.py:655, in displayFigure(fig, savetitle)
    653 def displayFigure(fig, savetitle=''):
    654     if plotWithPylab:
--> 655         plt.show(fig)
    657     if plotDirectory != None:
    658         figNums = [int(fileName.split('_fig_')[0]) for fileName in os.listdir(
    659             plotDirectory) if len(fileName.split('_fig_')) >= 2]

File ~/opt/miniconda3/envs/screenProcessing/lib/python3.10/site-packages/matplotlib/pyplot.py:421, in show(*args, **kwargs)
    377 """
    378 Display all open figures.
    379 
   (...)
    418 explicitly there.
    419 """
    420 _warn_if_gui_out_of_main_thread()
--> 421 return _get_backend_mod().show(*args, **kwargs)

TypeError: _Backend.show() takes 1 positional argument but 2 were given

Am I missing somethimg?

I'm working with python 3.10.9.

thanks

Assa

mhorlbeck commented 1 year ago

Hi Assa, this seems like an issue with the matplotlib configuration. Are you using iPython or something else to run this interactively, and does it have a graphical backend set up? I recommend using Jupyter lab, and sometimes that requires the %matplotlib inline command to enable plots to show inline. You can also set screen_analysis to save figures rather than display plots if there is no backend to do interactive plotting.

yeroslaviz commented 1 year ago

I have run the workflow on the command line successfully, but i have a few more question for better understanding of the results, which I have posted in a new issue.

I would appreciate your response to them.

thanks

Assa