xiaoyeye / TFvelo

39 stars 4 forks source link

ValueError: need at least one array to concatenate #10

Open AcetylCoALab opened 5 months ago

AcetylCoALab commented 5 months ago

In my data, RNA splices and unsplices are missing. Running python TFvelo_run_my.py --dataset_name myscRNA works fine and generates pp.h5ad and rc.h5ad When running TFvelo_demo in jupyter, the first part of the data processing works fine, but the final drawing fails Code: def show_adata(adata, save_name, show_all=0): if show_all: for i in range(int((len(adata.var_names)-1)/20)+1): genes2show = adata.var_names[i20: (i+1)20] TFv.pl.velocity(adata, genes2show, ncols=4, add_outline=True, layers='na', dpi=150, fontsize=15)#, save='WXy'+savename+''+str(i)) #layers='all' if len(adata.obs['clusters'].cat.categories) > 10: legend_loc = 'right margin' else: legend_loc = 'on data' cutoff_perc = 20 TFv.pl.velocity_embedding_stream(adata, vkey='velocity', use_derivative=False, density=2, basis='umap', \ cutoff_perc=cutoff_perc, smooth=0.5, fontsize=20, recompute=True, \ legend_loc=legend_loc)#, save='embeddingstream'+save_name) #

return

TFv.tl.velocity_graph(adata_copy, basis=None, vkey='velocity', xkey='M_total') adata_copy.uns['clusters_colors'] = adata.uns['clusters_colors'] show_adata(adata_copy, save_name='velo', show_all=1)

data_type_tostr(adata_copy) print(adata_copy) adata_copy.write(result_path + 'TFvelo.h5ad') Error message: computing velocity graph (using 1/40 cores)

ValueError Traceback (most recent call last) Cell In[8], line 17 11 TFv.pl.velocity_embedding_stream(adata, vkey='velocity', use_derivative=False, density=2, basis='umap', \ 12 cutoff_perc=cutoff_perc, smooth=0.5, fontsize=20, recompute=True, \ 13 legend_loc=legend_loc)#, save='embeddingstream'+save_name) # 15 return ---> 17 TFv.tl.velocity_graph(adata_copy, basis=None, vkey='velocity', xkey='M_total') 18 adata_copy.uns['clusters_colors'] = adata.uns['clusters_colors'] 19 show_adata(adata_copy, save_name='velo', show_all=1)

File ~/software_install/TFvelo/TFvelo/tools/velocity_graph.py:360, 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) 356 n_jobs = get_n_jobs(n_jobs=n_jobs) 357 logg.info( 358 f"computing velocity graph (using {n_jobs}/{os.cpu_count()} cores)", r=True 359 ) --> 360 vgraph.compute_cosines(n_jobs=n_jobs, backend=backend) 362 adata.uns[f"{vkey}_graph"] = vgraph.graph 363 adata.uns[f"{vkey}_graph_neg"] = vgraph.graph_neg

File ~/software_install/TFvelo/TFvelo/tools/velocity_graph.py:183, in VelocityGraph.compute_cosines(self, n_jobs, backend) 174 res = parallelize( 175 self._compute_cosines, 176 range(self.X.shape[0]), (...) 179 backend=backend, 180 )() 181 uncertainties, vals, rows, cols = map(_flatten, zip(*res)) --> 183 vals = np.hstack(vals) 184 vals[np.isnan(vals)] = 0 186 self.graph, self.graph_neg = vals_to_csr( 187 vals, rows, cols, shape=(n_obs, n_obs), split_negative=True 188 )

File <__array_function__ internals>:5, in hstack(*args, **kwargs)

File ~/miniconda3/envs/TFvelo_env/lib/python3.8/site-packages/numpy/core/shape_base.py:345, in hstack(tup) 343 return _nx.concatenate(arrs, 0) 344 else: --> 345 return _nx.concatenate(arrs, 1)

File <__array_function__ internals>:5, in concatenate(*args, **kwargs)

ValueError: need at least one array to concatenate

This may be due to the fact that my data does not provide velocity data. According to the paper's description, the method can complete the inference when velocity information is missing. Hence, how do I need to modify the code to complete the calculation?