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

Error with future package integration #260

Open
lict99 opened this issue Nov 22, 2024 · 1 comment
Open

Error with future package integration #260

lict99 opened this issue Nov 22, 2024 · 1 comment

Comments

@lict99
Copy link

lict99 commented Nov 22, 2024

I'd like to express my appreciation for the CellChat package, which has been instrumental in facilitating inference, visualization, and analysis of cell-cell communication from single-cell and spatially resolved transcriptomics.

However, I encountered an issue when using the future package to accelerate computing. Specifically, setting the plan to "multisession" without specifying the number of workers results in an error message: Error in rep(no, length.out = len) : attempt to replicate an object of type 'closure'.

Upon further investigation and debugging, I found that the issue stems from the following statement in your package:

my.sapply <- ifelse(
  test = future::nbrOfWorkers() == 1,
  yes = sapply,
  no = future.apply::future_sapply
)

This statement uses ifelse() to determine which function to use based on the number of workers. However, as you noted, this approach may not be suitable due to the vectorized nature of ifelse(). To resolve this issue, I suggest replacing it with a simple conditional assignment:

my.sapply <- if (future::nbrOfWorkers() == 1) sapply else future.apply::future_sapply

This change should prevent the error from occurring when using "multisession" mode without specifying the number of workers.

If you're short on time, I'd be happy to create a pull request with this fix. Otherwise, thank you for your attention to this matter.

@sqjin
Copy link
Member

sqjin commented Dec 12, 2024

@lict99 Thanks. Your suggestion looks good. I will update it. @suye0620 Can you let me know your thoughts on this issue?

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

2 participants