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

Replacement of / Alternative to the ForceAtlas2 package #32

Open
jasonleongbio opened this issue Jul 21, 2024 · 0 comments
Open

Replacement of / Alternative to the ForceAtlas2 package #32

jasonleongbio opened this issue Jul 21, 2024 · 0 comments

Comments

@jasonleongbio
Copy link

Dear developers of PAGA,

I'm recently new to PAGA and thanks so much for developing this wonderful tool! I was following the tutorials (the official and some other tutorials elsewhere), but could not reproduce the figure where the ForceAtlas2 algorithm was used to visualize the data in low-dimensional space.

The warning message said:

drawing single-cell graph using layout 'fa'
WARNING: Package 'fa2' is not installed, falling back to layout 'fr'.To use the faster and better ForceAtlas2 layout, install package 'fa2' (`pip install fa2`).
    finished: added
    'X_draw_graph_fr', graph_drawing coordinates (adata.obsm) (0:00:04)

I tried to follow the instruction, but could not successfully install the fa2 package (even after installing/updating additional dependency packages such as setuptools). I realized that this has been repetitively discussed in the original ForceAtlas2 repository (such as here). Indeed many people (not only in the bioinformatics field but also the others) encountered the very same problem.

(My environment is macOS, mamba virtual environment, Python 3.11, Scanpy 1.10, but these do not matter so much, as I show below.)

An alternative was to use a modified version by the community, called the fa2_modified. I installed it by

pip install -U fa2_modified

(Probably can be installed via conda-forge as well)

Having this installed does not automatically replace the use of fa2 in PAGA, so I additionally went to manually modify the tools/_draw_graph.py script in the Scanpy package installed in my virtual environment (line 138):

    # see whether fa2 is installed
    if layout == "fa":
        try:
            #from fa2 import ForceAtlas2
            from fa2_modified import ForceAtlas2
        except ImportError:
            logg.warning(
                "Package 'fa2' is not installed, falling back to layout 'fr'."
                "To use the faster and better ForceAtlas2 layout, "
                "install package 'fa2' (`pip install fa2`)."
            )
            layout = "fr"

After replacing the fa2 with fa2_modified, which is much easier to install, now I can run the ForceAtlas2 layout with PAGA, and reproduce the same result shown in the tutorial.

Hope this can help the team and the community improve the tool.

Best,
Jason Leong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant