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

SingleCells parameter sqlite_file string results in AttributeError: 'Connection' object has no attribute 'cursor' with updated Pandas versions #440

Open
1 task done
arka2696 opened this issue Sep 16, 2024 · 4 comments
Labels
bug Something isn't working question Further information is requested

Comments

@arka2696
Copy link

arka2696 commented Sep 16, 2024

Confirmation

  • I can confirm that this question/issue does not fall under any of the existing three issue types currently available.

General question or description

Hello,

I have recently started using Pycytominer for my image-based profiling experiments. While following the Pycytominer tutorial from the pipeline-examples https://github.com/cytomining/pipeline-examples#readme , I encountered an issue when running the profile.ipynb file.

Specifically, I am experiencing an AttributeError during the single-cell aggregation step. After executing the corresponding code block, I receive the following error message:

AttributeError: 'Connection' object has no attribute 'cursor'

I would appreciate any guidance or suggestions you might have to resolve this issue. The screenshots are attched below.
Screenshot 2024-09-16 130644
Screenshot 2024-09-16 130712

Thank you for your time and assistance.

Best regards,
Arka

@arka2696 arka2696 added the question Further information is requested label Sep 16, 2024
@d33bs
Copy link
Member

d33bs commented Sep 16, 2024

Thanks for bringing this up @arka2696 ! I was able to reproduce the error you're seeing and did some investigation here to determine what was happening. It seems that Pandas functionality has changed with pd.DataFrame.read_sql.

We should address this within Pycytominer in order to make sure it is compatible with the latest versions of Pandas. The following SO post illustrates possible ways to address this in addition to discussing why it happens generally: https://stackoverflow.com/a/77949093 .

That said, I believe this could be one possible workaround for you in the meantime:

When setting up the environment for https://github.com/cytomining/pipeline-examples you could try the following modified environment.yml for environment pycytominer-example:

name: pycytominer-example
channels:
- conda-forge
dependencies:
- conda-forge::python=3.11
- conda-forge::pandas=2.0.3
- conda-forge::numpy
- conda-forge::pathlib
- conda-forge::requests
- conda-forge::jupyter
- conda-forge::jupyterlab
- conda-forge::ipykernel
- conda-forge::nb_conda_kernels
- conda-forge::widgetsnbextension
- conda-forge::jupyter_contrib_nbextensions
- conda-forge::matplotlib
- conda-forge::plotnine
- conda-forge::seaborn
- conda-forge::black
- pip:
  - git+https://github.com/cytomining/pycytominer@8e3c28d3b81efd2c241d4c792edfefaa46698115
  - git+https://github.com/cytomining/cytominer-eval@643d3e7fc97464a1b45a4642fa921cc22269b118

This utilizes Pandas 2.0.3 which should allow you to proceed with the example notebook.

Please don't hesitate to reach out with any additional questions or comments - and thanks again for raising the issue for visibility!

@d33bs d33bs added the bug Something isn't working label Sep 16, 2024
@d33bs d33bs changed the title Question: Regarding AttributeError: 'Connection' object has no attribute 'cursor' SingleCells parameter sqlite_file string results in AttributeError: 'Connection' object has no attribute 'cursor' with updated Pandas versions Sep 16, 2024
@arka2696
Copy link
Author

Hi @d33bs Thank you for looking into my error. I have created a new python environment with the updated .yml file and this works fine now.

@d33bs
Copy link
Member

d33bs commented Sep 18, 2024

Thanks @arka2696, glad to hear!

We'll work on addressing the compatibility of later pandas versions to help close this issue.

@d33bs
Copy link
Member

d33bs commented Nov 12, 2024

Confirming this is still not working with later revisions of Pandas (specifically just tested Pandas 2.2.3). It may be worth exploring this solution within Pycytominer to gain compatibility https://stackoverflow.com/a/38333100 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants