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

IndexError: index 0 is out of bounds for dimension 1 with size 0 #191

Closed
YingYa opened this issue Apr 12, 2023 · 4 comments
Closed

IndexError: index 0 is out of bounds for dimension 1 with size 0 #191

YingYa opened this issue Apr 12, 2023 · 4 comments
Assignees
Labels
bug Something isn't working user question User question about a specific dataset
Milestone

Comments

@YingYa
Copy link

YingYa commented Apr 12, 2023

Hi, I am running into IndexError and ValueError errors for some samples after traning.

I run the following command with us.gcr.io/broad-dsde-methods/cellbender:20230403:
cellbender remove-background --input test2.RawMatrix.h5ad --output test2.RawMatrix.remove_background.round01.h5 --cuda --posterior-batch-size 64 --z-dim 20 --z-layers 100 --total-droplets-included 80000 --empty-drop-training-fraction 0.4 --training-fraction 0.8 --learning-rate 0.00005

And get this error message:

cellbender:remove-background: Posterior not currently included in checkpoint.
cellbender:remove-background: Computing posterior noise count probabilities in mini-batches...
cellbender:remove-background: Saved posterior as ./test2.RawMatrix.remove_background.round01_posterior.npz
cellbender:remove-background: Added posterior object to checkpoint file.
cellbender:remove-background: Unable to save all plots.
cellbender:remove-background: Traceback (most recent call last):
File "/software/cellbender/cellbender/remove_background/run.py", line 183, in save_output_plots
fig = plot_summary(loss=inferred_model.loss, umi_counts=counts, p=p, z=z)
File "/software/cellbender/cellbender/remove_background/run.py", line 245, in plot_summary
plt.plot(z_pca[:, 0], z_pca[:, 1],
IndexError: index 0 is out of bounds for dimension 1 with size 0

cellbender:remove-background: Saved cell barcodes in ./test2.RawMatrix.remove_background.round01_cell_barcodes.csv
cellbender:remove-background: Computing target noise counts per gene for MCKP estimator
Traceback (most recent call last):
File "/opt/conda/bin/cellbender", line 33, in
sys.exit(load_entry_point('cellbender', 'console_scripts', 'cellbender')())
File "/software/cellbender/cellbender/base_cli.py", line 112, in main
cli_dict[args.tool].run(args)
File "/software/cellbender/cellbender/remove_background/cli.py", line 181, in run
main(args)
File "/software/cellbender/cellbender/remove_background/cli.py", line 226, in main
run_remove_background(args)
File "/software/cellbender/cellbender/remove_background/run.py", line 132, in run_remove_background
compute_output_denoised_counts_reports_metrics(
File "/software/cellbender/cellbender/remove_background/run.py", line 299, in compute_output_denoised_counts_reports_metrics
noise_target_fun_per_cell = compute_mean_target_removal_as_function(
File "/software/cellbender/cellbender/remove_background/posterior.py", line 1625, in compute_mean_target_removal_as_function
mean_noise_csr = estimator.estimate_noise(
File "/software/cellbender/cellbender/remove_background/estimation.py", line 134, in estimate_noise
result = apply_function_dense_chunks(noise_log_prob_coo=noise_log_prob_coo,
File "/software/cellbender/cellbender/remove_background/estimation.py", line 410, in apply_function_dense_chunks
for coo, row in chunked_iterator(coo=noise_log_prob_coo):
File "/software/cellbender/cellbender/remove_background/estimation.py", line 366, in chunked_iterator
for i in range(0, coo.row.max(), batch_size):
File "/opt/conda/lib/python3.8/site-packages/numpy/core/_methods.py", line 40, in _amax
return umr_maximum(a, axis, None, out, keepdims, initial, where)
ValueError: zero-size array to reduction operation maximum which has no identity

The UMI curve was posted here:
image

@sjfleming
Copy link
Member

sjfleming commented Apr 14, 2023

So this dataset looks like it might be more problematic. What is your belief about the number of cells in this experiment? I cannot see by eye where the cells are and where they empty droplets are. Unless you're doing something very unusual, I'd say this might be a QC failure.

Now, that being said, you still should not be getting these kinds of errors from the code, so I will fix that. Thanks for reporting!

sjfleming added a commit that referenced this issue Apr 14, 2023
@sjfleming sjfleming self-assigned this Apr 14, 2023
@sjfleming sjfleming added the bug Something isn't working label Apr 14, 2023
@sjfleming sjfleming added this to the v0.3.0 milestone Apr 14, 2023
sjfleming added a commit that referenced this issue Apr 14, 2023
* Memory profiling script for MCKP estimator

* Check for zero cells found: closes #191

* Fix some issues in report

* Chunked MCKP estimator is working

* Add args to WDL and add miniwdl check github action
@sjfleming sjfleming mentioned this issue Apr 14, 2023
@YingYa
Copy link
Author

YingYa commented Apr 16, 2023

Hi @sjfleming, I am analyzing some single nuclear sequencing experiments, the expected cell for our experiment is about 10k cells, the targeting 100k cells is very very overloaded.

Yes, this sample looks like QC failure. I am trying to filter artifacts that this sample may be kept for the following analysis.

@sjfleming
Copy link
Member

sjfleming commented Apr 18, 2023

Hi @YingYa , I have made an attempt to fix this bug, but now the code will give you a RuntimeError that says "No cells found" instead of this confusing IndexError and ValueError.

The problem here is that CellBender did not find any cells, and I do not think it will find cells even after the minor code fixes I've recently added, since I suspect there might not be any cells present in this experiment. It looks like a sample where it's possible that all the nuclei accidentally lysed or something, and all you've got left is ambient RNA.

I do think that this is a QC failure, and unfortunately CellBender cannot really do much with these kinds of samples.

@sjfleming sjfleming added the user question User question about a specific dataset label Apr 18, 2023
@YingYa
Copy link
Author

YingYa commented Apr 19, 2023

Hi @sjfleming, thanks for your help. I will check this sample again, and maybe a new experiment of this sample for comparing.

@YingYa YingYa closed this as completed Apr 19, 2023
@sjfleming sjfleming mentioned this issue Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working user question User question about a specific dataset
Projects
None yet
Development

No branches or pull requests

2 participants