Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local variable 'merge' referenced before assignment #43

Closed
zEpoch opened this issue Jun 7, 2023 · 7 comments
Closed

local variable 'merge' referenced before assignment #43

zEpoch opened this issue Jun 7, 2023 · 7 comments

Comments

@zEpoch
Copy link

zEpoch commented Jun 7, 2023

when running pyWGCNA_5xFAD.runWGCNA()
`---------------------------------------------------------------------------
UnboundLocalError Traceback (most recent call last)
Cell In [8], line 1
----> 1 pyWGCNA_5xFAD.runWGCNA()

File /opt/software/python/lib/python3.8/site-packages/PyWGCNA/wgcna.py:353, in WGCNA.runWGCNA(self)
348 """
349 Preprocess and find modules
350 """
351 WGCNA.preprocess(self)
--> 353 WGCNA.findModules(self)
355 return self

File /opt/software/python/lib/python3.8/site-packages/PyWGCNA/wgcna.py:337, in WGCNA.findModules(self, **kwargs)
334 self.datExpr.var['moduleLabels'] = [colorOrder.index(x) if x in colorOrder else None for x in
335 self.datExpr.var['moduleColors']]
336 # Eigengenes of the new merged modules:
--> 337 self.MEs = merge['newMEs']
339 # Recalculate MEs with color labels
340 self.datME = WGCNA.moduleEigengenes(self.datExpr.to_df(), self.datExpr.var['moduleColors'])['eigengenes']

UnboundLocalError: local variable 'merge' referenced before assignment`

@nargesr
Copy link
Member

nargesr commented Jun 12, 2023

Hi,

Could you give me more information about how you got this error?
for example which version of PyWGCNA did you run?
did you change any default parameters? if yes, which one?
What was your input?

@marie-minaeva
Copy link

Hey,

I encountered the same error. My PyWGCNA version is 1.16.8. Could it be due to the only 1 identified module in the network?
As input, I had the preprocessed sc expression as a pd.DataFrame with genes as columns and cells as rows
Code I run:

exp_mat = pd.read_csv(dataset_path, index_col=0, header=0)
network = PyWGCNA.WGCNA(name='coexpression', geneExp=exp_mat)
network.findModules()
image And the Error I get:
Traceback (most recent call last):
  File "~/.local/lib/python3.10/site-packages/PyWGCNA/wgcna.py", line 337, in findModules
    self.MEs = merge['newMEs']
UnboundLocalError: local variable 'merge' referenced before assignment

@nargesr
Copy link
Member

nargesr commented Jun 20, 2023

Hi,

The latest version is 1.2.4. Please install that one. Also, check the exact version of all the other dependencies here.

If you got the same error please send me your pickle object.

@marie-minaeva
Copy link

Hey!
I tried with the latest version and got the same error. Here is the pickle object:
coexpression.p.tar.gz

@nargesr
Copy link
Member

nargesr commented Jun 27, 2023

Hi @marie-minaeva

I wasn't able to read your pickle file. please make sure that you can read it through PyWGCNA.readWGCNA() and resend it again

@marie-minaeva
Copy link

Hi @nargesr,
Here is the new object. I additionally gzipped since GitHub doesn't allow sending .p files. Thanks!
coexpression.p.gz

@nargesr
Copy link
Member

nargesr commented Aug 1, 2023

Hi,

This is because you ended up with having only one modules.
I'll add warning at the end to avoid this error in future and give you warning instead of that

nargesr added a commit that referenced this issue Aug 14, 2023
@nargesr nargesr closed this as completed Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants