-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Dear authors,
Thanks for the recent updates. But I still encounter errors in "1_1_Statistics_all_samples_using_txsim":
- AttributeError: module 'xb' has no attribute '_combined';
I then followed "import xb.formatting as xf" from "0_0", to modified as "import xb._combined as x_c" - And then error:
ValueError Traceback (most recent call last)
Cell In[3], line 18
16 except:
17 print('not possible to convert to dense')
---> 18 qlm1=x_c.all_quality_metrics(adata)
19 qlm1.columns=[fl[:-5]]
20 qlm1.loc['area',fl[:-5]]=float(xf.cell_area(adata))
File ~/.conda/envs/Xenium/lib/python3.9/site-packages/xb/_combined.py:19, in all_quality_metrics(adata_sp)
17 metrics['number_of_genes']=number_of_genes(adata_sp)
18 metrics['number_of_cells']=number_of_cells(adata_sp)
---> 19 metrics['pct5_readsxcell']=percentile_5th_reads_cells(adata_sp)
20 metrics['mean_genesxcell']=mean_genes_cells(adata_sp)
21 metrics['pct95_genesxcell']=percentile_95th_genes_cells(adata_sp)
File ~/.conda/envs/Xenium/lib/python3.9/site-packages/xb/_quality_metrics.py:119, in percentile_5th_reads_cells(adata_sp, pipeline_output)
106 def percentile_5th_reads_cells(adata_sp: AnnData,pipeline_output=True):
107 """5th percentile of number of reads/cells in the spatial experiment
108 Parameters
109 ----------
(...)
117 Median_number_of_reads_x_cell
118 """
--> 119 pctile5=np.percentile(np.sum(adata_sp.layers['raw'],axis=1),5)
120 return pctile5
File <__array_function__ internals>:180, in percentile(*args, **kwargs)
File ~/.conda/envs/Xenium/lib/python3.9/site-packages/numpy/lib/function_base.py:4134, in percentile(a, q, axis, out, overwrite_input, method, keepdims, interpolation)
4132 if not _quantile_is_valid(q):
4133 raise ValueError("Percentiles must be in the range [0, 100]")
-> 4134 return _quantile_unchecked(
4135 a, q, axis, out, overwrite_input, method, keepdims)
File ~/.conda/envs/Xenium/lib/python3.9/site-packages/numpy/lib/function_base.py:4383, in _quantile_unchecked(a, q, axis, out, overwrite_input, method, keepdims)
4375 def _quantile_unchecked(a,
4376 q,
4377 axis=None,
(...)
4380 method="linear",
4381 keepdims=False):
4382 """Assumes that q is in [0, 1], and is an ndarray"""
-> 4383 r, k = _ureduce(a,
4384 func=_quantile_ureduce_func,
4385 q=q,
4386 axis=axis,
4387 out=out,
4388 overwrite_input=overwrite_input,
4389 method=method)
4390 if keepdims:
4391 return r.reshape(q.shape + k)
File ~/.conda/envs/Xenium/lib/python3.9/site-packages/numpy/lib/function_base.py:3702, in _ureduce(a, func, **kwargs)
3699 else:
3700 keepdim = (1,) * a.ndim
-> 3702 r = func(a, **kwargs)
3703 return r, keepdim
File ~/.conda/envs/Xenium/lib/python3.9/site-packages/numpy/lib/function_base.py:4552, in _quantile_ureduce_func(a, q, axis, out, overwrite_input, method)
4550 else:
4551 arr = a.copy()
-> 4552 result = _quantile(arr,
4553 quantiles=q,
4554 axis=axis,
4555 method=method,
4556 out=out)
4557 return result
File ~/.conda/envs/Xenium/lib/python3.9/site-packages/numpy/lib/function_base.py:4669, in _quantile(arr, quantiles, axis, method, out)
4667 result_shape = virtual_indexes.shape + (1,) * (arr.ndim - 1)
4668 gamma = gamma.reshape(result_shape)
-> 4669 result = _lerp(previous,
4670 next,
4671 gamma,
4672 out=out)
4673 if np.any(slices_having_nans):
4674 if result.ndim == 0 and out is None:
4675 # can't write to a scalar
File ~/.conda/envs/Xenium/lib/python3.9/site-packages/numpy/lib/function_base.py:4488, in _lerp(a, b, t, out)
4486 diff_b_a = subtract(b, a)
4487 # asanyarray is a stop-gap until gh-13105
-> 4488 lerp_interpolation = asanyarray(add(a, diff_b_a * t, out=out))
4489 subtract(b, diff_b_a * (1 - t), out=lerp_interpolation, where=t >= 0.5)
4490 if lerp_interpolation.ndim == 0 and out is None:
File ~/.conda/envs/Xenium/lib/python3.9/site-packages/numpy/matrixlib/defmatrix.py:218, in matrix.__mul__(self, other)
215 def __mul__(self, other):
216 if isinstance(other, (N.ndarray, list, tuple)) :
217 # This promotes 1-D vectors to row vectors
--> 218 return N.dot(self, asmatrix(other))
219 if isscalar(other) or not hasattr(other, '__rmul__') :
220 return N.dot(self, other)
File <__array_function__ internals>:180, in dot(*args, **kwargs)
ValueError: shapes (1,162033) and (1,1) not aligned: 162033 (dim 1) != 1 (dim 0)
After debug, the error caused by np.percentile(np.sum(adata_sp.layers['raw'],axis=1),5) where np.sum(...,axis=1) return a matrix which is NOT what np.percentile expect. seems like this resolve the error:
np.percentile(np.squeeze(np.asarray(np.sum(adata.layers['raw'],axis=1))),5)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels