Closed wangjiawen2013 closed 1 year ago
Hi, I'm actually out of office for the next ten days so I'm not too sure why streamplot is not working on your data. The function does not really use dataframe as input but rather just the embedding (as ndarray) and the via object
On Mon, 19 Dec 2022, 13:48 jiawen wang, @.***> wrote:
Hi, When I ran streamplot on my own data, an error occured: IndexError: boolean index did not match indexed array along dimension 0; dimension is 18166 but corresponding boolean dimension is 29. But streamplot worked well on toydataset. Can you help ? Does it relate to cell barcode (it's like ATGCAAAAATGC-1 in my data, not integer)? In [5]: via.via_streamplot(v0, embedding) /home/wangjw/programs/miniconda3/envs/py37/lib/python3.7/site-packages/scipy/sparse/_index.py:125: SparseEfficiencyWarning: Changing the sparsity structure of a csr_matrix is expensive. lil_matrix is more efficient. self._set_arrayXarray(i, j, x) /home/wangjw/programs/miniconda3/envs/py37/lib/python3.7/site-packages/pyVIA/core.py:1030: RuntimeWarning: divide by zero encountered in true_divide T = T.multiply(csr_matrix(1.0 / np.abs(T).sum(1))) # rows sum to one /home/wangjw/programs/miniconda3/envs/py37/lib/python3.7/site-packages/pyVIA/core.py:1056: ImplicitModificationWarning: Trying to modify attribute .obsm of view, initializing view as actual. dX[np.isnan(dX)] = 0 # zero diff in a steady-state
IndexError Traceback (most recent call last) in ----> 1 via.via_streamplot(v0, embedding)
~/programs/miniconda3/envs/py37/lib/python3.7/site-packages/pyVIA/plotting_via.py in via_streamplot(via_coarse, embedding, density_grid, arrow_size, arrow_color, arrow_style, max_length, linewidth, min_mass, cutoff_perc, scatter_size, scatter_alpha, marker_edgewidth, density_stream, smooth_transition, smooth_grid, color_scheme, add_outline_clusters, cluster_outline_edgewidth, gp_color, bg_color, dpi, title, b_bias, n_neighbors_velocity_grid, other_labels, use_sequentially_augmented, cmap_str) 1432 if embedding is None: embedding = via_coarse.embedding 1433 -> 1434 V_emb = via_coarse._velocity_embedding(embedding, smooth_transition,b=b_bias, use_sequentially_augmented=use_sequentially_augmented) 1435 1436 V_emb *=20 #5 https://github.com/ShobiStassen/VIA/issues/5
~/programs/miniconda3/envs/py37/lib/python3.7/site-packages/pyVIA/core.py in _velocity_embedding(self, X_emb, smooth_transition, b, use_sequentially_augmented) 1054 1055 #dX /= np.sqrt(dX.multiply(dX).sum(axis=1).A1)[:, None] -> 1056 dX[np.isnan(dX)] = 0 # zero diff in a steady-state 1057 #neighbor edge weights are used to weight the overall dX or velocity from cell i. 1058 probs = T[i].data
~/programs/miniconda3/envs/py37/lib/python3.7/site-packages/anndata/_core/views.py in setitem(self, idx, value) 33 ) 34 with self._update() as container: ---> 35 container[idx] = value 36 37 @contextmanager
IndexError: boolean index did not match indexed array along dimension 0; dimension is 18166 but corresponding boolean dimension is 29
— Reply to this email directly, view it on GitHub https://github.com/ShobiStassen/VIA/issues/31, or unsubscribe https://github.com/notifications/unsubscribe-auth/AISI4SH3Z27OAIR27T3DJFDWN7SJHANCNFSM6AAAAAATC6BOBA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
I havd found the solution. Yes you're right. I need to convert embedding (ArrayView) to array using embedding=np.array(embedding).
Hi, When I ran streamplot on my own data, an error occured: IndexError: boolean index did not match indexed array along dimension 0; dimension is 18166 but corresponding boolean dimension is 29. But streamplot worked well on toydataset. Can you help ? Does it relate to cell barcode (it's like ATGCAAAAATGC-1 in my data, not integer)? In [5]: via.via_streamplot(v0, embedding) /home/wangjw/programs/miniconda3/envs/py37/lib/python3.7/site-packages/scipy/sparse/_index.py:125: SparseEfficiencyWarning: Changing the sparsity structure of a csr_matrix is expensive. lil_matrix is more efficient. self._set_arrayXarray(i, j, x) /home/wangjw/programs/miniconda3/envs/py37/lib/python3.7/site-packages/pyVIA/core.py:1030: RuntimeWarning: divide by zero encountered in true_divide T = T.multiply(csr_matrix(1.0 / np.abs(T).sum(1))) # rows sum to one /home/wangjw/programs/miniconda3/envs/py37/lib/python3.7/site-packages/pyVIA/core.py:1056: ImplicitModificationWarning: Trying to modify attribute
.obsm
of view, initializing view as actual. dX[np.isnan(dX)] = 0 # zero diff in a steady-stateIndexError Traceback (most recent call last)