-
Notifications
You must be signed in to change notification settings - Fork 16
Description
When I run hs_results = hs.compute_autocorrelations(), I met en error as follows:
AttributeError Traceback (most recent call last)
Cell In[78], line 2
1 # 计算基因自相关性
----> 2 hs_results = hs.compute_autocorrelations()
File /home/yujh5/miniconda3/envs/scanpy/lib/python3.12/site-packages/hotspot/hotspot.py:436, in Hotspot.compute_autocorrelations(self, jobs)
412 def compute_autocorrelations(self, jobs=1):
413 """Perform feature selection using local autocorrelation
414
415 In addition to returning output, this also stores the output
(...)
434
435 """
--> 436 return self._compute_hotspot(jobs)
File /home/yujh5/miniconda3/envs/scanpy/lib/python3.12/site-packages/hotspot/hotspot.py:397, in Hotspot._compute_hotspot(self, jobs)
370 def _compute_hotspot(self, jobs=1):
371 """Perform feature selection using local autocorrelation
372
373 In addition to returning output, this also stores the output
(...)
394
395 """
--> 397 results = compute_hs(
398 self.counts,
399 self.neighbors,
400 self.weights,
401 self.umi_counts,
402 self.model,
403 genes=self.adata.var_names,
404 centered=True,
405 jobs=jobs,
406 )
408 self.results = results
410 return self.results
File /home/yujh5/miniconda3/envs/scanpy/lib/python3.12/site-packages/hotspot/local_stats.py:218, in compute_hs(counts, neighbors, weights, num_umi, model, genes, centered, jobs)
213 def _map_fun(vals):
214 return _compute_hs_inner(
215 vals, neighbors, weights, num_umi, model, centered, Wtot2, D
216 )
--> 218 results = list(tqdm(map(_map_fun, data_iter()), total=counts.shape[0]))
220 results = pd.DataFrame(results, index=genes, columns=["G", "EG", "stdG", "Z", "C"])
222 results["Pval"] = norm.sf(results["Z"].values)
File /home/yujh5/miniconda3/envs/scanpy/lib/python3.12/site-packages/tqdm/std.py:1181, in tqdm.iter(self)
1178 time = self._time
1180 try:
-> 1181 for obj in iterable:
1182 yield obj
1183 # Update and possibly print the progressbar.
1184 # Note: does not call self.update(1) for speed optimisation.
File /home/yujh5/miniconda3/envs/scanpy/lib/python3.12/site-packages/hotspot/local_stats.py:184, in compute_hs..data_iter()
182 vals = counts[i]
183 if issparse(vals):
--> 184 vals = np.asarray(vals.A).ravel()
185 vals = vals.astype("double")
186 yield vals
AttributeError: 'csc_matrix' object has no attribute 'A'
How to solve this problem