broadinstitute / wot

A software package for analyzing snapshots of developmental processes
https://broadinstitute.github.io/wot/
BSD 3-Clause "New" or "Revised" License
140 stars 34 forks source link

AttributeError: 'csr_matrix' object has no attribute 'A' while calling plot_single_flow #108

Closed WeihangChen0 closed 2 months ago

WeihangChen0 commented 2 months ago

Dear Developer of Cellrank2, After building a WOT model from adata, I was trying to run plot_single_flow for a cluster and below is the code I used:

rtk = cr.kernels.RealTimeKernel.from_wot(adata, path="tmaps/", time_key="days") rtk = rtk.compute_transition_matrix() rtk.plot_single_flow(cluster = "0", cluster_key = "leiden_res1", time_key = "days", min_flow = 0.15, remove_empty_clusters = True, ascending = False, save = "probmassflow_wot_cluster0.tiff", time_points = [0,7])

It returns an error message of

File "", line 1, in File "/opt/conda/lib/python3.10/site-packages/cellrank/kernels/_utils.py", line 184, in require_tmat return wrapped(*args, **kwargs) File "/opt/conda/lib/python3.10/site-packages/cellrank/kernels/_base_kernel.py", line 151, in plot_single_flow fp = fp.prepare(cluster, clusters, time_points) File "/opt/conda/lib/python3.10/site-packages/cellrank/kernels/utils/_tmat_flow.py", line 140, in prepare self._flow = self.compute_flow(time_points, cluster) File "/opt/conda/lib/python3.10/site-packages/cellrank/kernels/utils/_tmat_flow.py", line 197, in compute_flow flow = callback(t1, t2) File "/opt/conda/lib/python3.10/site-packages/cellrank/kernels/utils/_tmat_flow.py", line 181, in cluster_helper df = pd.DataFrame(subset.A if sp.issparse(subset) else subset).sum(0) AttributeError: 'csr_matrix' object has no attribute 'A'

Versions: python==3.10 scanpy==1.10.2 cellrank==2.0.5 anndata==0.10.9 numpy==1.26.4 pandas==2.2.2