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

Providing init to the phateR implementation only saves up time if only the parameter t is changing but not other parameters? #143

Open
erzakiev opened this issue Apr 16, 2024 · 1 comment
Labels

Comments

@erzakiev
Copy link

I was hoping on saving some time on computation as each time phateR::phate runs, ~75% of time goes to PCA and KNN graph calculation:

Calculating PHATE...
  Running PHATE on 52398 observations and 32344 variables.
  Calculating graph and diffusion operator...
    Calculating PCA...
    Calculated PCA in 143.55 seconds.
    Calculating KNN search...
    Calculated KNN search in 53.70 seconds.
    Calculating affinities...
    Calculated affinities in 75.59 seconds.
  Calculated graph and diffusion operator in 273.90 seconds.
  Calculating landmark operator...
    Calculating SVD...
    Calculated SVD in 48.39 seconds.
    Calculating KMeans...
    Calculated KMeans in 13.31 seconds.
  Calculated landmark operator in 65.04 seconds.
  Calculating optimal t...
    Automatically selected t = 23
  Calculated optimal t in 4.87 seconds.
  Calculating diffusion potential...
  Calculated diffusion potential in 0.93 seconds.
  Calculating metric MDS...
  Calculated metric MDS in 4.46 seconds.
Calculated PHATE in 349.23 seconds.

In case of a fixed knn and re-calculation of the map with different parameters of e.g. decay or gamma, this is a purely redundant overhead that could be avoided. I thought passing to init a previous phate object with at least the same knn parameters would help the issue, but apparently the only place where it speeds up the things is when we recompute using a different t.

If i want to avoid to recalculate PCA and KNN graph each time, should i pass a pre-computed affinity matrix to the data variable, as instructed in the man page of phateR::phate? If so, can I use knn graph, generated by Seurat's FindNeighbors function for that purpose?

Thank you in advance.

@erzakiev
Copy link
Author

can I use knn graph, generated by Seurat's FindNeighbors function for that purpose?

When doing so, I encounter a cryptic error message 'ValueError: assignment destination is read-only':

> phateR::phate(data = as.matrix(pbmc3k@graphs$RNA_nn),
 knn.dist.method='precomputed')
Calculating PHATE...
  Running PHATE on precomputed affinity matrix with 52398 observations.
  Calculating graph and diffusion operator...
  Calculated graph and diffusion operator in 1.98 seconds.
Calculated PHATE in 1.98 seconds.
Error in py_call_impl(callable, call_args$unnamed, call_args$named) : 
  ValueError: assignment destination is read-only

Can you point me to where i can start to scratch the surface of the problem, please?

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

No branches or pull requests

1 participant