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

'DataFrame' object has no attribute 'append' #258

Open
rubickkkkk opened this issue Apr 2, 2024 · 2 comments
Open

'DataFrame' object has no attribute 'append' #258

rubickkkkk opened this issue Apr 2, 2024 · 2 comments

Comments

@rubickkkkk
Copy link

ERROR:AttributeError: 'DataFrame' object has no attribute 'append'

I am reporting a problem with GSEApy==1.1.2, Pandas==2.1.4 , and Python==3.11.6
system as follows:

I use the code as follow:

result = adata_mi.uns['dea_lei_mi'] groups = result['names'].dtype.names for group in groups : degs = pd.DataFrame({ key: result[key][group] for key in ['names','scores', 'pvals','pvals_adj','logfoldchanges']}) degs_sig = degs[degs.pvals_adj < 0.05] degs_up = degs_sig[degs_sig.logfoldchanges > 0] degs_dw = degs_sig[degs_sig.logfoldchanges < 0] enr_dw = gp.enrichr(degs_dw["names"].tolist(), gene_sets=['GO_Biological_Process_2023'], outdir=None)

and reporting the error:

`AttributeError Traceback (most recent call last)
/tmp/ipykernel_941722/3709642233.py in ?()
6 degs = pd.DataFrame({ key: result[key][group] for key in ['names','scores', 'pvals','pvals_adj','logfoldchanges']})
7 degs_sig = degs[degs.pvals_adj < 0.05]
8 degs_up = degs_sig[degs_sig.logfoldchanges > 0]
9 degs_dw = degs_sig[degs_sig.logfoldchanges < 0]
---> 10 enr_dw = gp.enrichr(degs_dw["names"].tolist(),
11 gene_sets=['GO_Biological_Process_2023'],
12 outdir=None)
13 enr_dw.res2d.Term = enr_dw.res2d.Term.str.split(" (GO").str[0]

/home/test/anaconda3/envs/scrna/lib/python3.11/site-packages/gseapy/enrichr.py in ?(gene_list, gene_sets, organism, description, outdir, background, cutoff, format, figsize, top_term, no_plot, verbose)

/home/test/anaconda3/envs/scrna/lib/python3.11/site-packages/gseapy/enrichr.py in ?(self)
423 "{}.background.genes.txt".format(self.background),
424 ),
425 )
426 self._logger.info(
--> 427 "Using all annotated genes with GO_ID as background: %s" % self.background
428 )
429 # input id type: entrez or gene_name
430 if self._isezid:

/home/test/anaconda3/envs/scrna/lib/python3.11/site-packages/pandas/core/generic.py in ?(self, name)

AttributeError: 'DataFrame' object has no attribute 'append'`

I have already tried to change the append method in enrichr.py , but it didn't work.

as follow:

line 617 :self.results = pd.concat([self.results, res], ignore_index=True)

moreover, as for the type of input gene_list, I have tried 1. degs_dw["names"].tolist() 2. degs_dw.names

@rubickkkkk
Copy link
Author

the code

result = adata_mi.uns['dea_lei_mi']
groups = result['names'].dtype.names
for group in groups :
    degs = pd.DataFrame({ key: result[key][group]  for key in ['names','scores', 'pvals','pvals_adj','logfoldchanges']})
    degs_sig = degs[degs.pvals_adj < 0.05]
    degs_up = degs_sig[degs_sig.logfoldchanges > 0]
    degs_dw = degs_sig[degs_sig.logfoldchanges < 0]
    enr_dw = gp.enrichr(degs_dw["names"].tolist(),
                    gene_sets=['GO_Biological_Process_2023'],
                    outdir=None)

@zqfang
Copy link
Owner

zqfang commented Apr 2, 2024

Can you send me the full error message output?

The error message is in line 426, not line 617. (BTW, you should not change line 617)

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

2 participants