consider add more visualization tool for CellRank2 meets with experimental timepoint (waddington transport)
Closed this issue · 9 comments
...
CellRank2 is great, but when I use the RealTimeKernel, I found very limited visualization functions for me to visualize my computing transition matrix. There were only RandomWalk and "single" flow.
I wonder if the development team could provide more APIs or functions to visualize the transition flow between clusters, at least not "single" flow one by one, but all cluster flows in one figure with color indicating IN/OUT direction and bandwidth indicating the flow mass size. Just like the figure below, which was published in 1. Marjanovic, N. D. et al. Emergence of a High-Plasticity Cell State during Lung Cancer Evolution. Cancer Cell 38, 229-246.e13 (2020).
Or could you please give the user a tutorial on extracting the transition matrix and performing visualization analysis on our own?
Thanks in advance
This is a great idea and we've been thinking about this for some time - unfortunately, we don't have the bandwith to implement this ourselves currently. Contributions from your side would be very welcome :)
@LiuCanidk, every kernel has the attribute transition_matrix
so you can easily use it to generate plots or perform a different analysis on it.
I'll close this issue for now to keep the issues tractable.
@LiuCanidk, every kernel has the attribute
transition_matrix
so you can easily use it to generate plots or perform a different analysis on it.
Sorry for opening this issue again, I have tried to save the transition matrix as a .csv or .txt file and expect to perform personalized analysis but I found the csv looked strange, and I am not familar with python, so I would like to ask for help.
this is a part of the transition matrix that I exported with pd.DataFrame(tmk.transition_matrix).to_csv("OT_transition_matrix.csv")
and as you see, it is not matrix-like with clear rows and columns. Besides, what looks more strange is that for cell indexed with 0, there are only a few rows (which I understand as the potential cells that can be transitioned into from cell 0 to cell X). And there is a strange break, characterized by two colons. And the cell indices change adruptly from 20000+ to 8000+.
for some cells, e.g., cell 3 in the screen shot above, there are no breaks, and it seems normal.
I know the transition matrix is in the form of sparse matrix. But I doubt the way I exported it may miss some transition information (the whole .csv file is only about 80M size with 70000+ cells). So I wonder how I can export the transition matrix into a type that I am familar with, e.g., txt or csv file, so that I can visualize the transition more clearly with R code, and most importantly, exporting without information loss.
Any advice would be greatly appreciated!
Also, if not private, can you tell me how you calculate the single flow from one state to another state based on the transition matrix? i.e., how can I get the data for plotting the single flow on my own? So that I can utilize the data to perform individualized visualization
@LiuCanidk, every kernel has the attribute
transition_matrix
so you can easily use it to generate plots or perform a different analysis on it.Sorry for opening this issue again, I have tried to save the transition matrix as a .csv or .txt file and expect to perform personalized analysis but I found the csv looked strange, and I am not familar with python, so I would like to ask for help.
this is a part of the transition matrix that I exported with
pd.DataFrame(tmk.transition_matrix).to_csv("OT_transition_matrix.csv")
and as you see, it is not matrix-like with clear rows and columns. Besides, what looks more strange is that for cell indexed with 0, there are only a few rows (which I understand as the potential cells that can be transitioned into from cell 0 to cell X). And there is a strange break, characterized by two colons. And the cell indices change adruptly from 20000+ to 8000+.for some cells, e.g., cell 3 in the screen shot above, there are no breaks, and it seems normal.
I know the transition matrix is in the form of sparse matrix. But I doubt the way I exported it may miss some transition information (the whole .csv file is only about 80M size with 70000+ cells). So I wonder how I can export the transition matrix into a type that I am familar with, e.g., txt or csv file, so that I can visualize the transition more clearly with R code, and most importantly, exporting without information loss.
Any advice would be greatly appreciated!
For general questions on exporting a matrix in Python, I recommend asking chatGPT first. See how far that gets you, and feel free to get back to us if you cannot solve the issue yourself.
I indeed asked chatGPT, and pd.DataFrame().to_csv
is what I found. Is that your way of exporting matrix? No error occured just the csv file looked strange.
@LiuCanidk, the transition matrix is in sparse format. You can densify it if you want, but I don't recommend it. You should use scipy to save the transition matrix, not pandas.
Thanks, using scipy works for me