cytomining / pycytominer

Python package for processing image-based profiling data
https://pycytominer.readthedocs.io
BSD 3-Clause "New" or "Revised" License
76 stars 34 forks source link

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

Open arka2696 opened 3 days ago

arka2696 commented 3 days ago

Confirmation

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

d33bs commented 2 days ago

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!

arka2696 commented 1 day ago

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 commented 1 day ago

Thanks @arka2696, glad to hear!

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