mortazavilab / PyWGCNA

PyWGCNA is a Python package designed to do Weighted Gene Correlation Network analysis (WGCNA)
https://academic.oup.com/bioinformatics/advance-article/doi/10.1093/bioinformatics/btad415/7218311
MIT License
194 stars 47 forks source link

pyWGCNA.findModules()—— sys.exit("Error!") #39

Closed ZivTQ closed 1 year ago

ZivTQ commented 1 year ago

Hi Thanks for providing PyWGCNA. I am running using my data. In the step pyWGCNA.findModules(), I got Error Calculating 29 module eigengenes in given set... ..principal component calculation for module black failed with the following error: ..hub genes will be used instead of principal components. An exception has occurred, use %tb to see the full traceback.

SystemExit: Error!

`SystemExit Traceback (most recent call last) Input In [6], in <cell line: 1>() ----> 1 pyWGCNA.findModules()

File ~\AppData\Roaming\Python\Python39\site-packages\PyWGCNA\wgcna.py:300, in WGCNA.findModules(self, **kwargs) 297 self.datExpr.var['dynamicColors'] = WGCNA.labels2colors(labels=dynamicMods) 299 # Calculate eigengenes --> 300 MEList = WGCNA.moduleEigengenes(expr=self.datExpr.to_df(), colors=self.datExpr.var['dynamicColors']) 302 self.MEs = MEList['eigengenes'] 303 if 'MEgrey' in self.MEs.columns:

File ~\AppData\Roaming\Python\Python39\site-packages\PyWGCNA\wgcna.py:2036, in WGCNA.moduleEigengenes(expr, colors, impute, nPC, align, excludeGrey, grey, subHubs, softPower, scaleVar, trapErrors) 2034 if not check: 2035 if not trapErrors: -> 2036 sys.exit("Error!") 2037 print(" ..ME calculation of module", modulename, "failed with the following error:", flush=True) 2038 print(" ", pc, " ..the offending module has been removed.", flush=True)

SystemExit: Error!`

The running log as following: Run WGCNA... pickSoftThreshold: calculating connectivity for given powers... will use block size 3104 Power SFT.R.sq slope truncated R.sq mean(k) median(k)
0 1 0.019005 0.439419 0.944844 1583.917996 1554.807821 \ 1 2 0.06366 -0.584601 0.929494 670.43699 652.433442
2 3 0.309456 -1.103302 0.942454 354.841864 335.688239
3 4 0.463625 -1.258173 0.934568 214.286872 195.668517
4 5 0.551524 -1.377 0.910081 141.322811 123.364176
5 6 0.665052 -1.332488 0.935139 99.308738 82.414462
6 7 0.808912 -1.275045 0.99298 73.223957 57.040702
7 8 0.861059 -1.346268 0.995675 56.071326 40.420707
8 9 0.899288 -1.39177 0.995843 44.268053 29.410026
9 10 0.915354 -1.439295 0.99548 35.840468 21.702019
10 11 0.930287 -1.462413 0.99669 29.635947 16.249537
11 13 0.94553 -1.491679 0.996215 21.327587 9.572117
12 15 0.95332 -1.479453 0.996157 16.193779 5.931626
13 17 0.954481 -1.464538 0.993863 12.811008 3.774937
14 19 0.953151 -1.434312 0.988609 10.466524 2.496161

     max(k)  

0 2757.869438
1 1459.46165
2 910.290623
3 627.926617
4 477.597429
5 375.88095
6 308.184438
7 269.243033
8 238.667545
9 217.831659
10 200.730955
11 174.80621
12 156.010401
13 141.336406
14 129.549861
Selected power to have scale free network is 10. calculating adjacency matrix ... Done..

calculating TOM similarity matrix ... Done..

Going through the merge tree... ..cutHeight not given, setting it to 0.994 ===> 99% of the (truncated) height range in dendro. Done..

Calculating 29 module eigengenes in given set... ..principal component calculation for module black failed with the following error: ..hub genes will be used instead of principal components. An exception has occurred, use %tb to see the full traceback.

SystemExit: Error!

thanks

nargesr commented 1 year ago

Hi,

Can you share with me your pickle file or a subset of your data that gave you this error?

ZivTQ commented 1 year ago

Hi, This is the data link: https://ftp.ncbi.nlm.nih.gov/geo/series/GSE44nnn/GSE44183/suppl/GSE44183_human_expression_mat.txt.gz

thank you

jerviedog commented 1 year ago

Hi, I had the same problem when I tried to replicate the example in quick start.

The session info was:

session_info.show()

PyWGCNA NA session_info 1.0.0

Python 3.9.16 (main, May 17 2023, 23:02:07) [GCC 10.2.0] Linux-4.9.0-6-amd64-x86_64-with-glibc2.24

Session information updated at 2023-05-18 13:00

The error was:

pyWGCNA_5xFAD.findModules() Run WGCNA... pickSoftThreshold: calculating connectivity for given powers... will use block size 1876 Power SFT.R.sq slope truncated R.sq mean(k) median(k) max(k) 0 1 0.368857 -0.481613 0.701585 2444.750756 2260.416614 5665.102661 1 2 0.7253 -0.99165 0.886361 840.665489 673.081241 3009.058821 2 3 0.791986 -1.194264 0.946969 385.685335 258.451265 1916.810605 3 4 0.835392 -1.3419 0.968446 207.404152 113.456087 1332.762771 4 5 0.853842 -1.472183 0.973346 123.232581 54.784481 984.036824 5 6 0.870673 -1.553348 0.979584 78.455923 28.47124 752.959999 6 7 0.886736 -1.600869 0.986635 52.572016 15.594822 591.514192 7 8 0.896672 -1.639343 0.992373 36.65884 9.454046 475.817182 8 9 0.903531 -1.677747 0.994643 26.397061 6.024431 389.237531 9 10 0.906045 -1.706474 0.995895 19.521431 3.975959 322.823838 10 11 0.905582 -1.731076 0.994806 14.767291 2.623921 270.867416 11 13 0.914482 -1.751347 0.997466 8.941254 1.205108 196.222414 12 15 0.912684 -1.771227 0.994189 5.759987 0.568044 146.575349 13 17 0.912188 -1.774908 0.990829 3.905403 0.273242 112.189052 14 19 0.907649 -1.774186 0.989457 2.766824 0.135454 87.594344 Selected power to have scale free network is 9. calculating adjacency matrix ... Done..

calculating TOM similarity matrix ... Done..

Going through the merge tree... ..cutHeight not given, setting it to 0.996 ===> 99% of the (truncated) height range in dendro. Done..

Calculating 22 module eigengenes in given set... ..principal component calculation for module black failed with the following error: ..hub genes will be used instead of principal components. Error!

nargesr commented 1 year ago

Hi @ZivTQ,

I was able to run PyWGCNA on your data without getting any error. I would check if you have the latest version of PyWGCNA and maybe create new environment and install PyWGCNA from scratch.

Also make sure that you pass your data correctly, i.e you have to transpose your matrix I attached my code to make sure you pass your input correctly:

import PyWGCNA
import pandas as pd

tpm = pd.read_csv('GSE44183_human_expression_mat.txt', sep='\t', index_col=0).T

test = PyWGCNA.WGCNA(name='test',
                     species='human', ## check this one 
                     geneExp=tpm, 
                     outputPath='',
                     save=True)

test.preprocess()
test.findModules()
nargesr commented 1 year ago

Hi @jerviedog,

according to your session info, it seems you don't the latest version of the PyWGCNA

jerviedog commented 1 year ago

Hi @nargesr

Maybe you are right. But I just cloned the repo and installed PyWGCNA by python3.9 -m pip install .

Where can I find the latest version of PyWGCNA?

Thanks a lot.

jerviedog commented 1 year ago

Hi, @nargesr

I uninstalled PyWGCNA and reinstalled PyWGCNA by python3.9 -m pip install PyWGCNA==1.16.8

I still got the same error.

It is weird that the version of PyWGCNA is still 1.0.0 (shown by session_info.show()); but the pip freeze shows that the PyWGCNA version is 1.6.8.

nargesr commented 1 year ago

Hi @jerviedog,

1.2.3 is the latest version, so hopefully installing that will solve your problem but if you still get that error maybe it's good to check the version of other packages I used from here

ZivTQ commented 1 year ago

Hi @ZivTQ,

I was able to run PyWGCNA on your data without getting any error. I would check if you have the latest version of PyWGCNA and maybe create new environment and install PyWGCNA from scratch.

Also make sure that you pass your data correctly, i.e you have to transpose your matrix I attached my code to make sure you pass your input correctly:

import PyWGCNA
import pandas as pd

tpm = pd.read_csv('GSE44183_human_expression_mat.txt', sep='\t', index_col=0).T

test = PyWGCNA.WGCNA(name='test',
                     species='human', ## check this one 
                     geneExp=tpm, 
                     outputPath='',
                     save=True)

test.preprocess()
test.findModules()