aertslab / pycisTopic

pycisTopic is a Python module to simultaneously identify cell states and cis-regulatory topics from single cell epigenomics data.
Other
58 stars 12 forks source link

Issue with run_cgs_models_mallet [BUG - but maybe not directly pycistopic?] #84

Closed dagarfield closed 1 year ago

dagarfield commented 1 year ago

Describe the bug Python (via a jupyter notebook) is throwing an error I have not seen before with run_cgs_models_mallet. I can confirm that the binary is accessible to python (tested via a call using os.system), so that isn't the issue. It seems to trace down to an iPython function ast_parse

To Reproduce Here's what I ran

path_to_mallet_binary='mallet'
#path_to_mallet_binary = "~/mambaforge/envs/pycistopic/bin/mallet"
# Run models
models=run_cgs_models_mallet(path_to_mallet_binary,
                    cistopic_obj2,
                    #n_topics=[2,5,10,15,20,25,30,35,40,45,50],
                    n_topics = [2,10]
                    n_cpu=7,
                    n_iter=200,
                    random_state=42,
                    alpha=50,
                    alpha_by_topic=True,
                    eta=0.1,
                    eta_by_topic=False,
                    tmp_path=tmpDir, 
                    save_path=None)

Error output And here's what we get

---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
File ~/mambaforge/envs/pycistopic/lib/python3.10/site-packages/IPython/core/compilerop.py:86, in CachingCompiler.ast_parse(self, source, filename, symbol)
     81 def ast_parse(self, source, filename='<unknown>', symbol='exec'):
     82     """Parse code to an AST with the current compiler flags active.
     83 
     84     Arguments are exactly the same as ast.parse (in the standard library),
     85     and are passed to the built-in compile function."""
---> 86     return compile(source, filename, symbol, self.flags | PyCF_ONLY_AST, 1)

SyntaxError: invalid syntax. Perhaps you forgot a comma? (3039137152.py, line 10)

Expected behavior Should return topic models from Mallet, I would hope.

Version (please complete the following information):

Additional context This may well be beyond scope, but if you've any insights or suggestions, I'd appreciate them. Thanks!

dagarfield commented 1 year ago

I left out a comma and didn't notice....oops. Let that be a lesson to all readers to double check your syntax before posting....

dagarfield commented 1 year ago

Note, however, that os.environ['MALLET_MEMORY'] = '100G' doesn't seem to work, though manually adjusting the memory in the Java executable did. More documentation there would be helpful. Cheers.