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

Woltka classify errors with tiny samples #216

Open
ElDeveloper opened this issue Dec 7, 2024 · 0 comments · May be fixed by #217
Open

Woltka classify errors with tiny samples #216

ElDeveloper opened this issue Dec 7, 2024 · 0 comments · May be fixed by #217

Comments

@ElDeveloper
Copy link
Contributor

I encountered an issue where samples with very few counts through woltka classify, which result in empty tables, trigger an error due to a call to numpy.vectorize. It would be great if this scenario produced an empty table instead of raising an error. The full traceback is provided below.

Traceback

Number of features before collapsing: 3.
Reading mapping file: orf-to-protein.map.xz... Done.
Traceback (most recent call last):
  File "/scratch/conda-envs/7002191ebcbec84d5c12599c4ceeb789_/bin/woltka", line 10, in <module>
    sys.exit(cli())
  File "/scratch/conda-envs/7002191ebcbec84d5c12599c4ceeb789_/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/scratch/conda-envs/7002191ebcbec84d5c12599c4ceeb789_/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/scratch/conda-envs/7002191ebcbec84d5c12599c4ceeb789_/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/scratch/conda-envs/7002191ebcbec84d5c12599c4ceeb789_/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/scratch/conda-envs/7002191ebcbec84d5c12599c4ceeb789_/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/scratch/conda-envs/7002191ebcbec84d5c12599c4ceeb789_/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/scratch/conda-envs/7002191ebcbec84d5c12599c4ceeb789_/lib/python3.10/site-packages/woltka/cli.py", line 234, in collapse_cmd
    collapse_wf(**kwargs)
  File "/scratch/conda-envs/7002191ebcbec84d5c12599c4ceeb789_/lib/python3.10/site-packages/woltka/tools.py", line 270, in collapse_wf
    round_table(table, digits or None)
  File "/scratch/conda-envs/7002191ebcbec84d5c12599c4ceeb789_/lib/python3.10/site-packages/woltka/table.py", line 447, in round_table
    round_biom(table, digits)
  File "/scratch/conda-envs/7002191ebcbec84d5c12599c4ceeb789_/lib/python3.10/site-packages/woltka/biom.py", line 195, in round_biom
    tmd.data = np.vectorize(f)(tmd.data).astype('float64')
  File "/scratch/conda-envs/7002191ebcbec84d5c12599c4ceeb789_/lib/python3.10/site-packages/numpy/lib/_function_base_impl.py", line 2470, in __ca
ll__
    return self._call_as_normal(*args, **kwargs)
  File "/scratch/conda-envs/7002191ebcbec84d5c12599c4ceeb789_/lib/python3.10/site-packages/numpy/lib/_function_base_impl.py", line 2463, in _cal
l_as_normal
    return self._vectorize_call(func=func, args=vargs)
  File "/scratch/conda-envs/7002191ebcbec84d5c12599c4ceeb789_/lib/python3.10/site-packages/numpy/lib/_function_base_impl.py", line 2548, in _vec
torize_call
    ufunc, otypes = self._get_ufunc_and_otypes(func=func, args=args)
  File "/scratch/conda-envs/7002191ebcbec84d5c12599c4ceeb789_/lib/python3.10/site-packages/numpy/lib/_function_base_impl.py", line 2504, in _get
_ufunc_and_otypes
    raise ValueError('cannot call `vectorize` on size 0 inputs '
ValueError: cannot call `vectorize` on size 0 inputs unless `otypes` is set

Minimal example

Outside of woltka classify, I was able to trace this to Numpy erroring with an empty matrix here.

minimal example

python

from woltka.biom import round_biom
import biom
x = biom.Table(data=[], observation_ids=[], sample_ids=[])
round_biom(x)
ElDeveloper added a commit to ElDeveloper/woltka that referenced this issue Dec 9, 2024
@ElDeveloper ElDeveloper linked a pull request Dec 9, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant