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
217 stars 53 forks source link

Cannot save WGCNA object #124

Closed victorsanchezarevalo closed 1 month ago

victorsanchezarevalo commented 1 month ago

wgcna.saveWGCNA() Saving WGCNA as WGCNA.p TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str' Cell In[10], line 1 ----> 1 wgcna.saveWGCNA() Hide Traceback File ~/miniconda3/envs/pywgcna/lib/python3.10/site-packages/PyWGCNA/wgcna.py:2754, in WGCNA.saveWGCNA(self) 2749 """ 2750 Saves the current WGCNA in pickle format with the .p extension 2751 """ 2752 print(f"{BOLD}{OKBLUE}Saving WGCNA as {self.name}.p{ENDC}") -> 2754 picklefile = open(self.outputPath + self.name + '.p', 'wb') 2755 pickle.dump(self, picklefile) 2756 picklefile.close()

nargesr commented 1 month ago

can you tell me if you modify the outputPath at any point or not?

what is the type of outputPath and name?

I believe you'll need to convert the outputPath that you used to a string before you save the object.

I may be able to fix it for the next release as well so it doesn't need to be string but I wanted to make sure that causes the error before making any changes

victorsanchezarevalo commented 1 month ago

Hi,

In the script that I have sent you it is defined the outputPath, let me now if you see any mistake, please.

Best

Victor

nargesr commented 1 month ago

so if you look at the WGCNA API doc, the outputPath should be string but in the script you have it as a pathlib.PosixPath and that cause the error.

you can fix it by converting the outputPath to string but I also released a new version yesterday to accept pathlib.PosixPath as well as string. so it's up to you if you want to upgrade your PyWGNCA package or change the type of your outputPath.

If you still have this problem, please reopen this issue.