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

Problems with figures generated by scv.pl.velocity_graph(adata) #996

Closed
ETAOIK opened this issue Feb 1, 2023 Discussed in #995 · 7 comments
Closed

Problems with figures generated by scv.pl.velocity_graph(adata) #996

ETAOIK opened this issue Feb 1, 2023 Discussed in #995 · 7 comments
Labels
bug Something isn't working plotting Plotting-related

Comments

@ETAOIK
Copy link

ETAOIK commented Feb 1, 2023

Discussed in #995

Originally posted by ETAOIK February 1, 2023
Hi, I am new to scVelo application and I have some problems during studying the tutorial 'Velocity graph and pseudotime' in https://scvelo.readthedocs.io/en/stable/VelocityBasics/,
In my output, cell-to-cell transitions didn't overlap with the umap clusters plot like following(Fig.1),
scv.pl.velocity_graph(adata,threshold=0.2)
emmm
only set arrows=True could made it like the following(Fig.2), and in this situation edges_on_top=None didn't works
threshold0

also, the the velocity graph generated by scv.pl.velocity_graph(adata) is quite small and the legend is quite big(Fig.3)
x, y = scv.utils.get_cell_transitions(adata, basis='umap', starting_cell=70)
ax = scv.pl.velocity_graph(adata, c='lightgrey', edge_width=.05, show=False)
ax = scv.pl.scatter(adata, x=x, y=y, s=120, c='ascending', cmap='gnuplot', ax=ax)
emmm2

My question is how to deal with it. Any help is greatly appreciated!

@River366
Copy link

River366 commented Feb 2, 2023

In fact, I had the same problem.

  • [ Versions ]
    anndata 0.8.0
    scanpy 1.9.1
    PIL 9.4.0
    asttokens NA
    backcall 0.2.0
    beta_ufunc NA
    binom_ufunc NA
    cffi 1.15.1
    colorama 0.4.6
    comm 0.1.2
    cycler 0.10.0
    cython_runtime NA
    dateutil 2.8.2
    debugpy 1.6.6
    decorator 5.1.1
    executing 1.2.0
    h5py 3.8.0
    hypergeom_ufunc NA
    igraph 0.10.4
    invgauss_ufunc NA
    ipykernel 6.21.0
    jedi 0.18.2
    joblib 1.2.0
    kiwisolver 1.4.4
    leidenalg 0.9.1
    llvmlite 0.39.1
    louvain 0.8.0
    matplotlib 3.6.3
    mpl_toolkits NA
    natsort 8.2.0
    nbinom_ufunc NA
    ncf_ufunc NA
    nct_ufunc NA
    ncx2_ufunc NA
    numba 0.56.4
    numexpr 2.8.3
    numpy 1.23.5
    packaging 23.0
    pandas 1.5.3
    parso 0.8.3
    pexpect 4.8.0
    pickleshare 0.7.5
    pkg_resources NA
    platformdirs 2.6.2
    prompt_toolkit 3.0.36
    psutil 5.9.4
    ptyprocess 0.7.0
    pure_eval 0.2.2
    pydev_ipython NA
    pydevconsole NA
    pydevd 2.9.5
    pydevd_file_utils NA
    pydevd_plugins NA
    pydevd_tracing NA
    pygments 2.14.0
    pyparsing 3.0.9
    pytz 2022.7.1
    scipy 1.10.0
    scvelo 0.2.5
    session_info 1.0.0
    setuptools 66.1.1
    setuptools_scm NA
    six 1.16.0
    skewnorm_ufunc NA
    sklearn 1.2.1
    stack_data 0.6.2
    texttable 1.6.7
    threadpoolctl 3.1.0
    tornado 6.2
    traitlets 5.9.0
    typing_extensions NA
    wcwidth 0.2.6
    zipp NA
    zmq 25.0.0
    IPython 8.9.0
    jupyter_client 8.0.2
    jupyter_core 5.2.0
    Python 3.8.15 | packaged by conda-forge | (default, Jan 26 2023, 10:47:49) [GCC 11.3.0]
    Linux-5.15.0-58-generic-x86_64-with-glibc2.10

@WeilerP WeilerP mentioned this issue Feb 2, 2023
@ETAOIK
Copy link
Author

ETAOIK commented Feb 4, 2023

I modified the source codes, and found one solution, although it didn't solve the problems fundamentally (cause if you didn't set arrows=True, the changes would not work), so here is my solution:
modify the codes of /scvelo-master/scvelo/plotting/velocity_graph like following (Line 83)

  1. change the zorder from 0 to 2 (let the zorder bigger than that of edges) first,
  2. and then add fontsize and figsize parameters statements (Set according to your needs):

Before changed:
ax = scatter(adata, layer=layer, color=color, size=size, ax=ax, zorder=0, **kwargs)
After changed:
ax = scatter(adata, layer=layer, color=color, size=size, ax=ax, zorder=2, fontsize=10,figsize=(8,6), **kwargs)

velocity graph and transition plot before changes:
debug1
debug2

velocity graph and transition plot after changes:
win!
the following plot should add one more zorder statement (zorder=3)
x, y = scv.utils.get_cell_transitions(adata, basis='umap', starting_cell=70)
ax = modified_velocity_graph(adata, arrows=True, c='lightgrey', edge_width=.05, show=False)
ax = scv.pl.scatter(adata, x=x, y=y, s=120, c='ascending', cmap='gnuplot', ax=ax, zorder=3)
拿下!

Although this solution could generate the correct figures, it only works in the situation of setting arrows=True, setting arrows=False will still lead to the wrong layer overlapping. And I would like to mention, setting arrows=True will cost more time (more computing power is cost in the process of computing directed graph?). I don't know how to correct it fundamentally, but at least now, we have the correct output figures. Hope it would be solved fundamentally asap. Thanks all

@joe-jhou2
Copy link

It works! Thanks.

@River366
Copy link

River366 commented Feb 7, 2023

Dear author, thanks for your help!

@dburkhardt
Copy link

@adamgayoso @WeilerP just an FYI this is still an open issue. The is a workaround that involved patching the package, but it's incomplete (e.g. doesn't work with arrows=True)

@argearriojas
Copy link

The latest versions of matplotlib break the velocity_graph method. Downgrading to matplotlib==3.5.3 fixes this issue for me.

Until this compatibility issue is fixed, I would suggest adding version constraints to the requirements.txt file, or at least put a list of tested versions in the README file. This would also be relevant for versions of numpy and pandas that are currently incompatible with scvelo.

@WeilerP WeilerP added bug Something isn't working plotting Plotting-related labels Dec 2, 2023
@WeilerP
Copy link
Member

WeilerP commented Dec 3, 2023

Fixed by #1162.

@WeilerP WeilerP closed this as completed Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plotting Plotting-related
Projects
None yet
Development

No branches or pull requests

6 participants