diffxpy icon indicating copy to clipboard operation
diffxpy copied to clipboard

ZeroDivisionError: float division by zero

Open Simran-Sodhi opened this issue 3 years ago • 14 comments

Hi,

I have been getting this error: ZeroDivisionError: float division by zero when trying to run the following code: de.test.wald( data=adata_human, gene_names=adata_human.var_names, formula_loc="~ 1 + palantir_pseudotime_int", factor_loc_totest="palantir_pseudotime_int", as_numeric=["palantir_pseudotime_int"] ) Here is the complete error log: zero_division_error.pdf I am getting the same error even when I use a discrete variable instead of a continuous one and when I use sample single-cell data from the Scanpy datasets (scanpy.datasets.ebi_expression_atlas(accession = "E-GEOD-98816")) ` Current Versions:

  • numpy==1.21.6
  • anndata==0.8.0
  • pandas==1.4.3
  • scanpy==1.9.1
  • diffxpy.api==v0.7.4+21.g12f1286

Could you please look into this? Thanks for your help

Simran-Sodhi avatar Oct 20 '22 09:10 Simran-Sodhi

I've run into the same error when running de.test.versus_rest. Iterations near end and then generates the same above error.

mhgh146 avatar Oct 31 '22 01:10 mhgh146

The same error, hoping an answer.

guangjunyin avatar Nov 01 '22 05:11 guangjunyin

The same error, any clue?

victorsanchezarevalo avatar Nov 02 '22 09:11 victorsanchezarevalo

The same error, any clue?

Snipaste_2022-11-04_15-35-53

guangjunyin avatar Nov 04 '22 07:11 guangjunyin

The same error, any clue? Here is the detailed information.

guangjunyin avatar Nov 04 '22 07:11 guangjunyin

I had exactly the same.

victorsanchezarevalo avatar Nov 08 '22 07:11 victorsanchezarevalo

Same here.

theGreen-Coder avatar Nov 10 '22 19:11 theGreen-Coder

It's weird because the same code works on Collab but not on my computer. Collab: https://colab.research.google.com/drive/1FUZXHNCXtqWlip0jQN1Z9QBJ7JBO5qIR?usp=sharing When I try to run a wald test:

test = de.test.wald(
    data=data,
    formula_loc="~ 1 + condition",
    factor_loc_totest="condition",
)

# Error Terminates the program here on my Mac

summaryTest = test.summary().iloc[:10,:]

It works on Google Collab, but not on my MacOS. When I run it on Google Collab, it also gives me an error (below), but that doesn't stop the execution of my code. And therefore, test is defined, as well as summaryTest.
However, when I run this exact same code on my Mac machine, this happens (below). An exception is thrown and the whole program stops (leaving test undefined, thus leaving also summaryTest undefined).

Error on Google Collab (last line)

Screenshot 2022-11-11 at 09 27 17

Error on my Mac

Screenshot 2022-11-11 at 09 28 07

The only way this works on my Mac is if I ran this line of code before the wald test:
 sc.pp.highly_variable_genes(data, n_top_genes=255, subset = True, flavor = "seurat_v3", batch_key="sample")

theGreen-Coder avatar Nov 11 '22 09:11 theGreen-Coder

Hi,

I have been facing the same problem. Did someone find a solution ?

Alixbonard avatar Apr 17 '23 13:04 Alixbonard

Hello,

same problem here as well. It would be nice an answer trying to shed a light here

pdrofelipe avatar May 18 '23 13:05 pdrofelipe

Hello, I found the solution. The problem is related to the dask package. I downgraded it to dask==2021.4.0. Normally with this version the error becomes a warning. N.B. I use Diffxpy==0.7.4 and batchglm==0.7.4.

Alixbonard avatar May 29 '23 08:05 Alixbonard

Hi, I have the same error, any solution so far?

anndata 0.9.1 diffxpy v0.7.4 matplotlib 3.7.1 numpy 1.24.3 pandas 2.0.2 scanpy 1.9.3 scvi 1.0.0 seaborn 0.12.2 session_info 1.0.0 IPython 8.14.0 jupyter_client 8.2.0 jupyter_core 5.3.0 notebook 6.5.4 Python 3.9.16 | packaged by conda-forge | (main, Feb 1 2023, 21:39:03) [GCC 11.3.0] Linux-6.2.12-arch1-1-x86_64-with-glibc2.37

DieTANG avatar Jun 07 '23 13:06 DieTANG

Hi @DieTANG,

Did you try to downgrade dask ? dask==2021.4.0 worked for me.

Alixbonard avatar Jun 07 '23 15:06 Alixbonard

i have the same issue here, near convergence it give this error, anyone managed? i already have dask==2021.4.0

Marwansha avatar Feb 28 '24 12:02 Marwansha