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

expand dims bug with da.test.wald #114

Open
giovp opened this issue Nov 28, 2020 · 1 comment
Open

expand dims bug with da.test.wald #114

giovp opened this issue Nov 28, 2020 · 1 comment

Comments

@giovp
Copy link
Member

giovp commented Nov 28, 2020

I get this error when running:

test = de.test.wald(
    data=adata.layers['counts'],
    formula_loc="~ 1 + leiden",
    factor_loc_totest="leiden",
    gene_names=adata.var_names,
    sample_description=adata.obs,
)
Details

TypeError Traceback (most recent call last)
in
4 factor_loc_totest="leiden",
5 gene_names=adata.var_names,
----> 6 sample_description=adata.obs
7 )

~/Projects/diffxpy/diffxpy/testing/tests.py in wald(data, factor_loc_totest, coef_to_test, formula_loc, formula_scale, as_numeric, init_a, init_b, gene_names, sample_description, dmat_loc, dmat_scale, constraints_loc, constraints_scale, noise_model, size_factors, batch_size, backend, train_args, training_strategy, quick_scale, dtype, **kwargs)
734 quick_scale=quick_scale,
735 dtype=dtype,
--> 736 **kwargs,
737 )
738

~/Projects/diffxpy/diffxpy/testing/tests.py in _fit(noise_model, data, design_loc, design_scale, design_loc_names, design_scale_names, constraints_loc, constraints_scale, init_model, init_a, init_b, gene_names, size_factors, batch_size, backend, training_strategy, quick_scale, train_args, close_session, dtype)
188 chunk_size_genes=chunk_size_genes,
189 as_dask=backend.lower() in ["numpy"],
--> 190 cast_dtype=dtype
191 )
192

~/Projects/batchglm/batchglm/models/base_glm/input.py in init(self, data, design_loc, design_loc_names, design_scale, design_scale_names, constraints_loc, constraints_scale, size_factors, observation_names, feature_names, chunk_size_cells, chunk_size_genes, as_dask, cast_dtype)
89 chunk_size_genes=chunk_size_genes,
90 cast_dtype=cast_dtype,
---> 91 as_dask=as_dask
92 )
93

~/Projects/batchglm/batchglm/models/base/input.py in init(self, data, observation_names, feature_names, chunk_size_cells, chunk_size_genes, as_dask, cast_dtype)
88 self.x = self.x.astype(cast_dtype)
89
---> 90 self._feature_allzero = np.sum(self.x, axis=0) == 0
91 self.chunk_size_cells = chunk_size_cells
92 self.chunk_size_genes = chunk_size_genes

<array_function internals> in sum(*args, **kwargs)

~/miniconda3/envs/diffxpy/lib/python3.7/site-packages/dask/array/core.py in array_function(self, func, types, args, kwargs)
1423 if da_func is func:
1424 return handle_nonmatching_names(func, args, kwargs)
-> 1425 return da_func(*args, **kwargs)
1426
1427 @Property

~/miniconda3/envs/diffxpy/lib/python3.7/site-packages/dask/array/reductions.py in sum(a, axis, dtype, keepdims, split_every, out)
338 dtype=dtype,
339 split_every=split_every,
--> 340 out=out,
341 )
342 return result

~/miniconda3/envs/diffxpy/lib/python3.7/site-packages/dask/array/reductions.py in reduction(x, chunk, aggregate, axis, keepdims, dtype, split_every, combine, name, out, concatenate, output_size, meta)
155 # The dtype of tmp doesn't actually matter, and may be incorrect.
156 tmp = blockwise(
--> 157 chunk, inds, x, inds, axis=axis, keepdims=True, token=name, dtype=dtype or float
158 )
159 tmp._chunks = tuple(

~/miniconda3/envs/diffxpy/lib/python3.7/site-packages/dask/array/blockwise.py in blockwise(func, out_ind, name, token, dtype, adjust_chunks, new_axes, align_arrays, concatenate, meta, *args, **kwargs)
248 from .utils import compute_meta
249
--> 250 meta = compute_meta(func, dtype, *args[::2], **kwargs)
251 if meta is not None:
252 return Array(graph, out, chunks, meta=meta)

~/miniconda3/envs/diffxpy/lib/python3.7/site-packages/dask/array/utils.py in compute_meta(func, _dtype, *args, **kwargs)
125 if has_keyword(func, "computing_meta"):
126 kwargs_meta["computing_meta"] = True
--> 127 meta = func(*args_meta, **kwargs_meta)
128 except TypeError as e:
129 if (

<array_function internals> in sum(*args, **kwargs)

~/miniconda3/envs/diffxpy/lib/python3.7/site-packages/numpy/core/fromnumeric.py in sum(a, axis, dtype, out, keepdims, initial, where)
2227
2228 return _wrapreduction(a, np.add, 'sum', axis, dtype, out, keepdims=keepdims,
-> 2229 initial=initial, where=where)
2230
2231

~/miniconda3/envs/diffxpy/lib/python3.7/site-packages/numpy/core/fromnumeric.py in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
84 # support a dtype.
85 if dtype is not None:
---> 86 return reduction(axis=axis, dtype=dtype, out=out, **passkwargs)
87 else:
88 return reduction(axis=axis, out=out, **passkwargs)

TypeError: sum() got an unexpected keyword argument 'keepdims'

I feel it's some numpy conflict versions but can't nail it down
I have numpy 1.18

@giovp
Copy link
Member Author

giovp commented Nov 28, 2020

after trying different combinations, this seems to work: scanpy==1.6.0 anndata==0.7.5 umap==0.4.6 numpy==1.18.2 scipy==1.4.1 pandas==1.1.3 scikit-learn==0.23.2 statsmodels==0.11.1 python-igraph==0.8.3 leidenalg==0.8.3

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

1 participant