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

[ERROR] ValueError: Buffer dtype mismatch, expected 'const float' but got 'unsigned int' #280

Closed
brauliovaldebenitomaturana opened this issue Oct 24, 2023 · 2 comments

Comments

@brauliovaldebenitomaturana

Hi!

I've been using Pegasus, and from time to time I run into the following error when calling highly_variable_features:

Traceback (most recent call last):
  File "Pegasus-Pipeline.py", line 249, in <module>
    pg.highly_variable_features(data_pre, batch="Channel", n_top=5000)
  File "/sc/arion/work/t/miniconda3/envs/pec_pegasusenv/lib/python3.8/site-packages/pegasusio/decorators.py", line 12, in wrapper_timer
    result = func(*args, **kwargs)
  File "/sc/arion/work/t/miniconda3/envs/pec_pegasusenv/lib/python3.8/site-packages/pegasus/tools/hvf_selection.py", line 292, in highly_variable_features
    select_hvf_pegasus(data, batch, n_top=n_top, span=span) 
  File "/sc/arion/work/t/miniconda3/envs/pec_pegasusenv/lib/python3.8/site-packages/pegasus/tools/hvf_selection.py", line 54, in select_hvf_pegasus
    estimate_feature_statistics(data, batch)
  File "/sc/arion/work/t/miniconda3/envs/pec_pegasusenv/lib/python3.8/site-packages/pegasusio/decorators.py", line 12, in wrapper_timer
    result = func(*args, **kwargs)
  File "/sc/arion/work/t/miniconda3/envs/pec_pegasusenv/lib/python3.8/site-packages/pegasus/tools/hvf_selection.py", line 26, in estimate_feature_statistics
    ncells, means, partial_sum = calc_stat_per_batch(data.X, data.obs[batch].values)
  File "/sc/arion/work/t/miniconda3/envs/pec_pegasusenv/lib/python3.8/site-packages/pegasus/tools/utils.py", line 114, in calc_stat_per_batch  
    return calc_stat_per_batch_sparse(X.shape[0], X.shape[1], X.data, X.indices, X.indptr, nbatch, codes)
  File "ext_modules/fast_utils.pyx", line 108, in pegasus.cylib.fast_utils.__pyx_fuse_0_0calc_stat_per_batch_sparse
ValueError: Buffer dtype mismatch, expected 'const float' but got 'unsigned int'

After a few attempts of re-running the script, it eventually works. Any idea as to why this could be occurring in a non-systematic manner?

@hvbakel
Copy link

hvbakel commented Dec 23, 2023

Note that I submitted pull request #281 to address this issue, which addresses the occasional dtype errors in the calc_stat_per_batch_sparse function by ensuring that the matrix X is float32.

@yihming
Copy link
Member

yihming commented Jan 6, 2024

Hi @brauliovaldebenitomaturana and @hvbakel ,

Thanks for reporting this issue. Please see my comments in #281.

To be brief, the reason that this issue happens sometimes is that aggregate_matrices() function didn't have a logic on choosing which count matrix to be the default one in the resulting data object, if the source has multiple count matrices. I've applied such a logic in this PR. Please upgrade your pegasusio package to version 0.8.2.

Sincerely,
Yiming

@yihming yihming closed this as completed Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants