ZeroDivisionError: integer division or modulo by zero
simonekats opened this issue · comments
masks = palantir.presults.select_branch_cells(adata, eps=0)
plt.show()
ZeroDivisionError Traceback (most recent call last)
Cell In[545], line 1
----> 1 masks = palantir.presults.select_branch_cells(adata, eps=0)
2 plt.show()
File ~/anaconda3/lib/python3.10/site-packages/palantir/presults.py:555, in select_branch_cells(ad, pseudo_time_key, fate_prob_key, q, eps, masks_key, save_as_df)
552 n = fate_probs.shape[0]
554 step = n // PSEUDOTIME_RES
--> 555 nsteps = n // step
556 for i in range(nsteps):
557 l, r = i * step, (i + 1) * step
ZeroDivisionError: integer division or modulo by zero
Hi @simonekats,
Thank you for reporting. My guess is that your dataset has a very small number of cells (<500). The best solution would be to increase the number of cells in tour dataset, as results for such a small sample size might vary. As a quick fix to make this work for the given dataset you can run
palantir.presults.PSEUDOTIME_RES = ad.n_obs
before running the selection. I also made a patch that should avoid this error in the future. You can install the patched version now with
pip install --ignore-installed --no-deps 'git+https://github.com/dpeerlab/Palantir'
Please let me know if the issue persist or if we can close this.
The first code solved it thank you so much!