Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
WeihangChen0 opened this issue Sep 13, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@WeihangChen0
Copy link

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])
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

@WeihangChen0 WeihangChen0 added the bug Something isn't working label Sep 13, 2024
@michalk8
Copy link
Collaborator

This was fixed in #1214 , I've made a new release (2.0.6), so it should work now!

@WeihangChen0
Copy link
Author

Dear @michalk8! Thank you so much for the update, the plotting issue has been resolved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants