theislab / diffxpy

Differential expression analysis for single-cell RNA-seq data.
https://diffxpy.rtfd.io
BSD 3-Clause "New" or "Revised" License
191 stars 23 forks source link

ZeroDivisionError: float division by zero #220

Open Simran-Sodhi opened 1 year ago

Simran-Sodhi commented 1 year ago

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:

Could you please look into this? Thanks for your help

mhgh146 commented 1 year ago

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

guangjunyin commented 1 year ago

The same error, hoping an answer.

victorsanchezarevalo commented 1 year ago

The same error, any clue?

guangjunyin commented 1 year ago

The same error, any clue?

Snipaste_2022-11-04_15-35-53
guangjunyin commented 1 year ago

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

victorsanchezarevalo commented 1 year ago

I had exactly the same.

theGreen-Coder commented 1 year ago

Same here.

theGreen-Coder commented 1 year ago

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")

Alixbonard commented 1 year ago

Hi,

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

pdrofelipe commented 1 year ago

Hello,

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

Alixbonard commented 1 year ago

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.

DieTANG commented 1 year ago

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

Alixbonard commented 1 year ago

Hi @DieTANG,

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

Marwansha commented 7 months ago

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