Skip to content

scv.tl.velocity_graph(adata, n_jobs=8) get error setting an array element with a sequence. #15

Description

@TangentDeng

Hi, great module!
I get a issue like this

scv.tl.velocity_graph(adata, n_jobs=8)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[16], line 1
----> 1 scv.tl.velocity_graph(vel0, n_jobs=8)

File [~/miniconda3/envs/deepvelo/lib/python3.9/site-packages/scvelo/tools/velocity_graph.py:363](http://192.168.2.10:8001/user/dengzhen/lab/tree/code_old/newcode/miniconda3/envs/deepvelo/lib/python3.9/site-packages/scvelo/tools/velocity_graph.py#line=362), in velocity_graph(data, vkey, xkey, tkey, basis, n_neighbors, n_recurse_neighbors, random_neighbors_at_max, sqrt_transform, variance_stabilization, gene_subset, compute_uncertainties, approx, mode_neighbors, copy, n_jobs, backend)
    359 n_jobs = get_n_jobs(n_jobs=n_jobs)
    360 logg.info(
    361     f"computing velocity graph (using {n_jobs}/{os.cpu_count()} cores)", r=True
    362 )
--> 363 vgraph.compute_cosines(n_jobs=n_jobs, backend=backend)
    365 adata.uns[f"{vkey}_graph"] = vgraph.graph
    366 adata.uns[f"{vkey}_graph_neg"] = vgraph.graph_neg

File [~/miniconda3/envs/deepvelo/lib/python3.9/site-packages/scvelo/tools/velocity_graph.py:175](http://192.168.2.10:8001/user/dengzhen/lab/tree/code_old/newcode/miniconda3/envs/deepvelo/lib/python3.9/site-packages/scvelo/tools/velocity_graph.py#line=174), in VelocityGraph.compute_cosines(self, n_jobs, backend)
    172 n_obs = self.X.shape[0]
    174 # TODO: Use batches and vectorize calculation of dX in self._calculate_cosines
--> 175 res = parallelize(
    176     self._compute_cosines,
    177     range(self.X.shape[0]),
    178     n_jobs=n_jobs,
    179     unit="cells",
    180     backend=backend,
    181 )()
    182 uncertainties, vals, rows, cols = map(_flatten, zip(*res))
    184 vals = np.hstack(vals)

File [~/miniconda3/envs/deepvelo/lib/python3.9/site-packages/scvelo/core/_parallelize.py:138](http://192.168.2.10:8001/user/dengzhen/lab/tree/code_old/newcode/miniconda3/envs/deepvelo/lib/python3.9/site-packages/scvelo/core/_parallelize.py#line=137), in parallelize.<locals>.wrapper(*args, **kwargs)
    126     pbar, queue, thread = None, None, None
    128 res = Parallel(n_jobs=n_jobs, backend=backend)(
    129     delayed(callback)(
    130         *((i, cs) if use_ixs else (cs,)),
   (...)
    135     for i, cs in enumerate(collections)
    136 )
--> 138 res = np.array(res) if as_array else res
    139 if thread is not None:
    140     thread.join()

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (8, 4) + inhomogeneous part.

I search that upgrade the scvelo can solve the issue. However, upgraded scvelo are not match deepvelo in other issue. How to deal with it? THANKS

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions