train model
blast = cb.blast.BLAST(models, train) #.build_empirical()
this work well,but when I interpret it return error
test_pred = blast.query(test)
[INFO] Cell BLAST: Projecting to latent space...
[INFO] Cell BLAST: Doing nearest neighbor search...
[INFO] Cell BLAST: Merging hits across models...
[INFO] Cell BLAST: Computing posterior distribution distances...
ValueError Traceback (most recent call last)
Cell In[18], line 1
----> 1 test_pred = blast.query(test)
File e:\gcuda\env\lib\site-packages\Cell_BLAST\blast.py:875, in BLAST.query(self, query, n_neighbors, store_dataset, n_jobs, random_seed)
872 else:
873 utils.logger.info("Computing posterior distribution distances...")
874 query_posterior = np.stack(
--> 875 joblib.Parallel(n_jobs=min(n_jobs, len(self)), backend="loky")(
876 joblib.delayed(model.inference)(
877 query, n_posterior=self.n_posterior, random_seed=random_seed
878 )
879 for model in self.models
880 ),
881 axis=1,
882 ) # n_cells * n_models * n_posterior_samples * latent_dim
883 ref_posterior = np.stack(
884 self._get_posterior(n_jobs, random_seed, idx=hitsu)
885 ) # n_cells * n_models * n_posterior_samples * latent_dim
886 distance_metric = DISTANCE_METRIC_ACROSS_MODELS[self.distance_metric]
File e:\gcuda\env\lib\site-packages\joblib\parallel.py:1918, in Parallel.call(self, iterable)
1916 output = self._get_sequential_output(iterable)
1917 next(output)
-> 1918 return output if self.return_generator else list(output)
1920 # Let's create an ID that uniquely identifies the current call. If the
1921 # call is interrupted early and that the same instance is immediately
1922 # re-used, this id will be used to prevent workers that were
1923 # concurrently finalizing a task from the previous call to run the
1924 # callback.
1925 with self._lock:
File e:\gcuda\env\lib\site-packages\joblib\parallel.py:1847, in Parallel._get_sequential_output(self, iterable)
1845 self.n_dispatched_batches += 1
1846 self.n_dispatched_tasks += 1
-> 1847 res = func(*args, **kwargs)
1848 self.n_completed_tasks += 1
1849 self.print_progress()
File e:\gcuda\env\lib\site-packages\Cell_BLAST\directi.py:530, in DIRECTi.inference(self, adata, batch_size, n_posterior, progress_bar, priority, random_seed)
528 if priority == "speed":
529 if scipy.sparse.issparse(x):
--> 530 xrep = x.tocsr()[np.repeat(np.arange(x.shape[0]), n_posterior)]
531 else:
532 xrep = np.repeat(x, n_posterior, axis=0)
File e:\gcuda\env\lib\site-packages\scipy\sparse_index.py:83, in IndexMixin.getitem(self, key)
81 return self._get_arrayXint(row, col)
82 elif isinstance(col, slice):
---> 83 return self._get_arrayXslice(row, col)
84 else: # row.ndim == 2
85 if isinstance(col, INT_TYPES):
File e:\gcuda\env\lib\site-packages\scipy\sparse_csr.py:217, in _csr_base._get_arrayXslice(self, row, col)
215 col = np.arange(*col.indices(self.shape[1]))
216 return self._get_arrayXarray(row, col)
--> 217 return self._major_index_fancy(row)._get_submatrix(minor=col)
File e:\gcuda\env\lib\site-packages\scipy\sparse_compressed.py:708, in _cs_matrix._major_index_fancy(self, idx)
705 np.cumsum(row_nnz, out=res_indptr[1:])
707 nnz = res_indptr[-1]
--> 708 res_indices = np.empty(nnz, dtype=idx_dtype)
709 res_data = np.empty(nnz, dtype=self.dtype)
710 csr_row_index(
711 M,
712 indices,
(...)
717 res_data
718 )
ValueError: negative dimensions are not allowed
train model
blast = cb.blast.BLAST(models, train) #.build_empirical()
this work well,but when I interpret it return error
test_pred = blast.query(test)
[INFO] Cell BLAST: Projecting to latent space...
[INFO] Cell BLAST: Doing nearest neighbor search...
[INFO] Cell BLAST: Merging hits across models...
[INFO] Cell BLAST: Computing posterior distribution distances...
ValueError Traceback (most recent call last)
Cell In[18], line 1
----> 1 test_pred = blast.query(test)
File e:\gcuda\env\lib\site-packages\Cell_BLAST\blast.py:875, in BLAST.query(self, query, n_neighbors, store_dataset, n_jobs, random_seed)
872 else:
873 utils.logger.info("Computing posterior distribution distances...")
874 query_posterior = np.stack(
--> 875 joblib.Parallel(n_jobs=min(n_jobs, len(self)), backend="loky")(
876 joblib.delayed(model.inference)(
877 query, n_posterior=self.n_posterior, random_seed=random_seed
878 )
879 for model in self.models
880 ),
881 axis=1,
882 ) # n_cells * n_models * n_posterior_samples * latent_dim
883 ref_posterior = np.stack(
884 self._get_posterior(n_jobs, random_seed, idx=hitsu)
885 ) # n_cells * n_models * n_posterior_samples * latent_dim
886 distance_metric = DISTANCE_METRIC_ACROSS_MODELS[self.distance_metric]
File e:\gcuda\env\lib\site-packages\joblib\parallel.py:1918, in Parallel.call(self, iterable)
1916 output = self._get_sequential_output(iterable)
1917 next(output)
-> 1918 return output if self.return_generator else list(output)
1920 # Let's create an ID that uniquely identifies the current call. If the
1921 # call is interrupted early and that the same instance is immediately
1922 # re-used, this id will be used to prevent workers that were
1923 # concurrently finalizing a task from the previous call to run the
1924 # callback.
1925 with self._lock:
File e:\gcuda\env\lib\site-packages\joblib\parallel.py:1847, in Parallel._get_sequential_output(self, iterable)
1845 self.n_dispatched_batches += 1
1846 self.n_dispatched_tasks += 1
-> 1847 res = func(*args, **kwargs)
1848 self.n_completed_tasks += 1
1849 self.print_progress()
File e:\gcuda\env\lib\site-packages\Cell_BLAST\directi.py:530, in DIRECTi.inference(self, adata, batch_size, n_posterior, progress_bar, priority, random_seed)
528 if priority == "speed":
529 if scipy.sparse.issparse(x):
--> 530 xrep = x.tocsr()[np.repeat(np.arange(x.shape[0]), n_posterior)]
531 else:
532 xrep = np.repeat(x, n_posterior, axis=0)
File e:\gcuda\env\lib\site-packages\scipy\sparse_index.py:83, in IndexMixin.getitem(self, key)
81 return self._get_arrayXint(row, col)
82 elif isinstance(col, slice):
---> 83 return self._get_arrayXslice(row, col)
84 else: # row.ndim == 2
85 if isinstance(col, INT_TYPES):
File e:\gcuda\env\lib\site-packages\scipy\sparse_csr.py:217, in _csr_base._get_arrayXslice(self, row, col)
215 col = np.arange(*col.indices(self.shape[1]))
216 return self._get_arrayXarray(row, col)
--> 217 return self._major_index_fancy(row)._get_submatrix(minor=col)
File e:\gcuda\env\lib\site-packages\scipy\sparse_compressed.py:708, in _cs_matrix._major_index_fancy(self, idx)
705 np.cumsum(row_nnz, out=res_indptr[1:])
707 nnz = res_indptr[-1]
--> 708 res_indices = np.empty(nnz, dtype=idx_dtype)
709 res_data = np.empty(nnz, dtype=self.dtype)
710 csr_row_index(
711 M,
712 indices,
(...)
717 res_data
718 )
ValueError: negative dimensions are not allowed