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

ValueError: Linkage 'Z' contains negative distances #35

Closed mgb217 closed 1 year ago

mgb217 commented 1 year ago

Hi,

When I test PyWGCNA with your 5xFAD sample data, I got an error "ValueError: Linkage 'Z' contains negative distances" in findModules step. The same error occurred in my own data. Please give me some suggestions. Below is the log file:

pyWGCNA_5xFAD.preprocess() Pre-processing... Detecting genes and samples with too many missing values... Done pre-processing..

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

[15 rows x 7 columns] Selected power to have scale free network is 9. calculating adjacency matrix ... Done..

calculating TOM similarity matrix ... Done..

Traceback (most recent call last): File "", line 1, in File "/home/abc/miniconda3/envs/eqtl/lib/python3.8/site-packages/PyWGCNA/wgcna.py", line 293, in findModules dynamicMods = WGCNA.cutreeHybrid(dendro=self.geneTree, distM=dissTOM, deepSplit=2, pamRespectsDendro=False, File "/home/xukuipeng/miniconda3/envs/eqtl/lib/python3.8/site-packages/PyWGCNA/wgcna.py", line 1265, in cutreeHybrid dendro_height = WGCNA.get_heights(dendro) File "/home/abc/miniconda3/envs/eqtl/lib/python3.8/site-packages/PyWGCNA/wgcna.py", line 1189, in get_heights clusternode = to_tree(Z, True) File "/home/abc/miniconda3/envs/eqtl/lib/python3.8/site-packages/scipy/cluster/hierarchy.py", line 1461, in to_tree is_valid_linkage(Z, throw=True, name='Z') File "/home/abc/miniconda3/envs/eqtl/lib/python3.8/site-packages/scipy/cluster/hierarchy.py", line 2284, in is_valid_linkage raise ValueError('Linkage %scontains negative distances.' % ValueError: Linkage 'Z' contains negative distances.

nargesr commented 1 year ago

Hi,

please try to install the last version of PyWGCNA and try to go through the tutorials again.

if you face the same error again, please send me your input, your code

mgb217 commented 1 year ago

Hi,

please try to install the last version of PyWGCNA and try to go through the tutorials again.

if you face the same error again, please send me your input, your code

mgb217 commented 1 year ago

Hi,

I change a compute node. There is no 'ValueError: Linkage 'Z' contains negative distances'. But I got another error:

import PyWGCNA geneExp = '5xFAD_paper/expressionList.csv' pyWGCNA_5xFAD = PyWGCNA.WGCNA(name='5xFAD',species='mus musculus',geneExpPath=geneExp,outputPath='',save=True) Saving data to be True, checking requirements ... Figure directory does not exist! Creating figure directory! pyWGCNA_5xFAD.preprocess() Pre-processing... Detecting genes and samples with too many missing values... Done pre-processing..

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

[15 rows x 7 columns] 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!