diffxpy
diffxpy copied to clipboard
.plot_vs_ttest() throws dask error
when i run .plot_vs_ttest() on my diffxpy object which I got from a wald test, I see the following error.
I looked into this a bit and the culprit seems to be the np.asarray() call on the daskarray here I can run that same line without errors with the np.asarray() removed:
https://github.com/theislab/diffxpy/blob/3689ea88fb18ec3fe0a6e7f7f6033859a378167e/diffxpy/testing/det.py#L1583
this is the content of my waldresults.model_estim.x which is used here:
dask.array<array, shape=(6594, 31449), dtype=float64, chunksize=(6594, 512), chunktype=numpy.ndarray>
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-20-8161315ef952> in <module>
----> 1 dxps_wald.plot_vs_ttest()
~/.local/lib/python3.7/site-packages/diffxpy/testing/det.py in plot_vs_ttest(self, log10, show, save, suffix, return_axs)
888 data=self.model_estim.x / sf,
889 grouping=grouping,
--> 890 gene_names=self.gene_ids,
891 )
892 if log10:
~/.local/lib/python3.7/site-packages/diffxpy/testing/tests.py in t_test(data, grouping, gene_names, sample_description, is_logged, is_sig_zerovar)
861 gene_names=gene_names,
862 is_logged=is_logged,
--> 863 is_sig_zerovar=is_sig_zerovar
864 )
865
~/.local/lib/python3.7/site-packages/diffxpy/testing/det.py in __init__(self, data, sample_description, grouping, gene_names, is_logged, is_sig_zerovar)
1581 var_x1 = np.asarray(np.mean(x1.power(2), axis=0)).flatten().astype(dtype=np.float) - np.square(mean_x1)
1582 else:
-> 1583 var_x0 = np.asarray(np.var(x0, axis=0)).flatten().astype(dtype=np.float)
1584 var_x1 = np.asarray(np.var(x1, axis=0)).flatten().astype(dtype=np.float)
1585 self._var_geq_zero = np.logical_or(
/opt/python/lib/python3.7/site-packages/numpy/core/_asarray.py in asarray(a, dtype, order)
83
84 """
---> 85 return array(a, dtype, copy=False, order=order)
86
87
/opt/python/lib/python3.7/site-packages/dask/array/core.py in __array__(self, dtype, **kwargs)
1335
1336 def __array__(self, dtype=None, **kwargs):
-> 1337 x = self.compute()
1338 if dtype and x.dtype != dtype:
1339 x = x.astype(dtype)
/opt/python/lib/python3.7/site-packages/dask/base.py in compute(self, **kwargs)
164 dask.base.compute
165 """
--> 166 (result,) = compute(self, traverse=False, **kwargs)
167 return result
168
/opt/python/lib/python3.7/site-packages/dask/base.py in compute(*args, **kwargs)
435 keys = [x.__dask_keys__() for x in collections]
436 postcomputes = [x.__dask_postcompute__() for x in collections]
--> 437 results = schedule(dsk, keys, **kwargs)
438 return repack([f(r, *a) for r, (f, a) in zip(results, postcomputes)])
439
/opt/python/lib/python3.7/site-packages/dask/threaded.py in get(dsk, result, cache, num_workers, pool, **kwargs)
82 get_id=_thread_get_id,
83 pack_exception=pack_exception,
---> 84 **kwargs
85 )
86
/opt/python/lib/python3.7/site-packages/dask/local.py in get_async(apply_async, num_workers, dsk, result, cache, get_id, rerun_exceptions_locally, pack_exception, raise_exception, callbacks, dumps, loads, **kwargs)
484 _execute_task(task, data) # Re-execute locally
485 else:
--> 486 raise_exception(exc, tb)
487 res, worker_id = loads(res_info)
488 state["cache"][key] = res
/opt/python/lib/python3.7/site-packages/dask/local.py in reraise(exc, tb)
314 if exc.__traceback__ is not tb:
315 raise exc.with_traceback(tb)
--> 316 raise exc
317
318
/opt/python/lib/python3.7/site-packages/dask/local.py in execute_task(key, task_info, dumps, loads, get_id, pack_exception)
220 try:
221 task, data = loads(task_info)
--> 222 result = _execute_task(task, data)
223 id = get_id()
224 result = dumps((result, id))
/opt/python/lib/python3.7/site-packages/dask/core.py in _execute_task(arg, cache, dsk)
119 # temporaries by their reference count and can execute certain
120 # operations in-place.
--> 121 return func(*(_execute_task(a, cache) for a in args))
122 elif not ishashable(arg):
123 return arg
/opt/python/lib/python3.7/site-packages/dask/core.py in <genexpr>(.0)
119 # temporaries by their reference count and can execute certain
120 # operations in-place.
--> 121 return func(*(_execute_task(a, cache) for a in args))
122 elif not ishashable(arg):
123 return arg
/opt/python/lib/python3.7/site-packages/dask/core.py in _execute_task(arg, cache, dsk)
119 # temporaries by their reference count and can execute certain
120 # operations in-place.
--> 121 return func(*(_execute_task(a, cache) for a in args))
122 elif not ishashable(arg):
123 return arg
/opt/python/lib/python3.7/site-packages/dask/optimization.py in __call__(self, *args)
980 if not len(args) == len(self.inkeys):
981 raise ValueError("Expected %d args, got %d" % (len(self.inkeys), len(args)))
--> 982 return core.get(self.dsk, self.outkey, dict(zip(self.inkeys, args)))
983
984 def __reduce__(self):
/opt/python/lib/python3.7/site-packages/dask/core.py in get(dsk, out, cache)
149 for key in toposort(dsk):
150 task = dsk[key]
--> 151 result = _execute_task(task, cache)
152 cache[key] = result
153 result = _execute_task(out, cache)
/opt/python/lib/python3.7/site-packages/dask/core.py in _execute_task(arg, cache, dsk)
119 # temporaries by their reference count and can execute certain
120 # operations in-place.
--> 121 return func(*(_execute_task(a, cache) for a in args))
122 elif not ishashable(arg):
123 return arg
/opt/python/lib/python3.7/site-packages/dask/utils.py in apply(func, args, kwargs)
28 def apply(func, args, kwargs=None):
29 if kwargs:
---> 30 return func(*args, **kwargs)
31 else:
32 return func(*args)
/opt/python/lib/python3.7/site-packages/dask/array/reductions.py in moment_chunk(A, order, sum, numel, dtype, computing_meta, **kwargs)
635 with np.errstate(divide="ignore", invalid="ignore"):
636 u = total / n
--> 637 xs = [sum((A - u) ** i, dtype=dtype, **kwargs) for i in range(2, order + 1)]
638 M = np.stack(xs, axis=-1)
639 return {"total": total, "n": n, "M": M}
/opt/python/lib/python3.7/site-packages/dask/array/reductions.py in <listcomp>(.0)
635 with np.errstate(divide="ignore", invalid="ignore"):
636 u = total / n
--> 637 xs = [sum((A - u) ** i, dtype=dtype, **kwargs) for i in range(2, order + 1)]
638 M = np.stack(xs, axis=-1)
639 return {"total": total, "n": n, "M": M}
/opt/python/lib/python3.7/site-packages/numpy/lib/mixins.py in func(self, other)
23 if _disables_array_ufunc(other):
24 return NotImplemented
---> 25 return ufunc(self, other)
26 func.__name__ = '__{}__'.format(name)
27 return func
/opt/python/lib/python3.7/site-packages/sparse/_coo/core.py in __array_ufunc__(self, ufunc, method, *inputs, **kwargs)
1659
1660 if method == "__call__":
-> 1661 result = elemwise(ufunc, *inputs, **kwargs)
1662 elif method == "reduce":
1663 result = COO._reduce(ufunc, *inputs, **kwargs)
/opt/python/lib/python3.7/site-packages/sparse/_coo/umath.py in elemwise(func, *args, **kwargs)
46 """
47
---> 48 return _Elemwise(func, *args, **kwargs).get_result()
49
50
/opt/python/lib/python3.7/site-packages/sparse/_coo/umath.py in __init__(self, func, *args, **kwargs)
444
445 self._check_broadcast()
--> 446 self._get_fill_value()
447
448 def get_result(self):
/opt/python/lib/python3.7/site-packages/sparse/_coo/umath.py in _get_fill_value(self)
538 ):
539 raise ValueError(
--> 540 "Performing a mixed sparse-dense operation that would result in a dense array. "
541 "Please make sure that func(sparse_fill_values, ndarrays) is a constant array."
542 )
ValueError: Performing a mixed sparse-dense operation that would result in a dense array. Please make sure that func(sparse_fill_values, ndarrays) is a constant array.