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

Error with function analyseWGCNA() #48

Open
GERMAN00VP opened this issue Jun 21, 2023 · 3 comments
Open

Error with function analyseWGCNA() #48

GERMAN00VP opened this issue Jun 21, 2023 · 3 comments
Labels
improvement generalized functions

Comments

@GERMAN00VP
Copy link

HI I AM TRYING TO FIND THE CORRELATION OF THE MODULES OF MY WGCNA OBJECT WITH THE TRAITS OF MY METADATA , BUT I GET THE FOLLOWING ERROR, DO ANYONE KNOW HOW TO SOLVE IT? THANK YOU.

pyWGCNA_TCGA_PAAD.analyseWGCNA()

Analysing WGCNA...
Calculating module trait relationship ...
Done..

Adding (signed) eigengene-based connectivity (module membership) ...
Done..

plotting module heatmap eigengene...
Done..

plotting module barplot eigengene...

ValueError Traceback (most recent call last)
Cell In[10], line 1
----> 1 pyWGCNA_TCGA_PAAD.analyseWGCNA()

File ~/miniconda3/envs/machine_learning/lib/python3.11/site-packages/PyWGCNA/wgcna.py:447, in WGCNA.analyseWGCNA(self, order, geneList, show)
445 print(f"{OKCYAN}plotting module barplot eigengene...{ENDC}")
446 for module in modules:
--> 447 self.barplotModuleEigenGene(module, metadata, colorBar=metadata[-1], show=True)
448 print("\tDone..\n")
450 if self.save:

File ~/miniconda3/envs/machine_learning/lib/python3.11/site-packages/PyWGCNA/wgcna.py:2946, in WGCNA.barplotModuleEigenGene(self, moduleName, metadata, combine, colorBar, show)
2944 df['all'] = df['all'].apply(lambda x: x[1:])
2945 cat = pd.DataFrame(pd.unique(df['all']), columns=['all'])
-> 2946 cat[metadata] = cat['all'].str.split('_', expand=True)
2947 ybar = df[['all', 'eigengeneExp']].groupby(['all']).mean()['eigengeneExp']
2948 ebar = df[['all', 'eigengeneExp']].groupby(['all']).std()['eigengeneExp']

File ~/miniconda3/envs/machine_learning/lib/python3.11/site-packages/pandas/core/frame.py:3968, in DataFrame.setitem(self, key, value)
3966 self._setitem_frame(key, value)
3967 elif isinstance(key, (Series, np.ndarray, list, Index)):
-> 3968 self._setitem_array(key, value)
3969 elif isinstance(value, DataFrame):
3970 self._set_item_frame_value(key, value)
...
402 else:
403 # Missing keys in columns are represented as -1
404 if len(columns.get_indexer_non_unique(key)[0]) != len(value.columns):

ValueError: Columns must be same length as key

@nargesr
Copy link
Member

nargesr commented Jun 21, 2023

Hi,

did you add your metadata using updateSampleInfo()?
can you tell me what's in the pyWGCNA_TCGA_PAAD.datExpr.obs?

@GERMAN00VP
Copy link
Author

Yes I did update the sample and gene info following all the steps of the quick start tutorial up to the one wich gave me the error. I will upload a photo of the pyWGCNA_TCGA_PAAD.datExpr.obs dataframe and the sample info file so that you can explore the metadata I am using. Thank you for your time and answers.

sampleInfo.csv

image

@nargesr
Copy link
Member

nargesr commented Jun 22, 2023

oh, it's probably because you have a dash in your column name like "Cluster_0"
I will try to fix this problem but meanwhile, if you can change your column names to be dash-free, it will probably solve your problem for now

Thank you for catching that! I'll try to see how I can fix that :)

@nargesr nargesr added the improvement generalized functions label Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement generalized functions
Projects
None yet
Development

No branches or pull requests

2 participants