diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 9fd8d8f..d6dec23 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -65,5 +65,17 @@ You can do this with `R -e 'reticulate::py_discover_config(required_module = "ph +Output of `phateR::check_pyphate_version()`: + +
+ +``` +Please run `phateR::check_pyphate_version()` and paste the results here. + +You can do this with `R -e 'phateR::check_pyphate_version()'` +``` + +
+ **Additional context** Add any other context about the problem here. diff --git a/.gitignore b/.gitignore index 807ea25..23274fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .Rproj.user .Rhistory .RData +phateR_*.tar.gz + diff --git a/DESCRIPTION b/DESCRIPTION index 09e997c..43c9bfb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phateR Title: PHATE - Potential of Heat-Diffusion for Affinity-Based Transition Embedding -Version: 1.0.0.999 +Version: 1.0.4 Authors@R: c(person("Krishnan", "Srinivasan", email = "krishnan.srinivasan@yale.edu", role = c("aut")), person(given = 'Scott', family = 'Gigante', email = 'scott.gigante@yale.edu', role = 'cre', comment = c(ORCID = '0000-0002-4544-2764'))) Description: PHATE is a tool for visualizing high dimensional single-cell data @@ -21,7 +21,8 @@ Imports: stats, graphics, reticulate (>= 1.8), - ggplot2 + ggplot2, + memoise Suggests: gridGraphics, cowplot diff --git a/NAMESPACE b/NAMESPACE index 5d45e33..3530e8b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,4 +13,6 @@ export(library.size.normalize) export(phate) import(Matrix) importFrom(ggplot2,ggplot) +importFrom(memoise,memoise) +importFrom(reticulate,py_discover_config) importFrom(utils,packageVersion) diff --git a/R/phate.R b/R/phate.R index c8f337c..1b4750e 100644 --- a/R/phate.R +++ b/R/phate.R @@ -232,7 +232,7 @@ phate <- function(data, ndim = 2, knn = 5, } } if (is.null(operator)) { - operator <- pyphate$PHATE(n_components = ndim, + operator <- pyphate()$PHATE(n_components = ndim, knn = knn, decay = decay, t = t, @@ -256,7 +256,7 @@ phate <- function(data, ndim = 2, knn = 5, out <- operator$von_neumann_entropy(t_max = t.max) t <- out[[1]] h <- out[[2]] - t.opt <- pyphate$vne$find_knee_point(h, t) + t.opt <- pyphate()$vne$find_knee_point(h, t) graphics::plot(t, h, type = "l", xlab = "t", ylab = "Von Neumann Entropy", diff --git a/R/utils.R b/R/utils.R index f1c0632..0808079 100644 --- a/R/utils.R +++ b/R/utils.R @@ -54,15 +54,11 @@ failed_pyphate_import <- function(e) { } load_pyphate <- function() { + py_config <- try(reticulate::py_discover_config(required_module = "phate")) delay_load = list(on_load=check_pyphate_version, on_error=failed_pyphate_import) # load - if (is.null(pyphate)) { - # first time load - result <- try(pyphate <<- reticulate::import("phate", delay_load = delay_load)) - } else { - # already loaded - result <- try(reticulate::import("phate", delay_load = delay_load)) - } + pyphate <- try(reticulate::import("phate", delay_load = delay_load)) + pyphate } #' Install PHATE Python Package @@ -106,7 +102,8 @@ install.phate <- function(envname = "r-reticulate", method = "auto", pyphate <- NULL +#' @importFrom reticulate py_discover_config +#' @importFrom memoise memoise .onLoad <- function(libname, pkgname) { - py_config <- reticulate::py_discover_config(required_module = "phate") - load_pyphate() + pyphate <<- memoise::memoise(load_pyphate) } diff --git a/README.Rmd b/README.Rmd index a7efc7b..fedd622 100644 --- a/README.Rmd +++ b/README.Rmd @@ -22,10 +22,9 @@ knitr::opts_chunk$set( [![Twitter](https://img.shields.io/twitter/follow/KrishnaswamyLab.svg?style=social&label=Follow)](https://twitter.com/KrishnaswamyLab) [![Github Stars](https://img.shields.io/github/stars/KrishnaswamyLab/PHATE.svg?style=social&label=Stars)](https://github.com/KrishnaswamyLab/PHATE/) -This R package provides an implementation of the -[PHATE dimensionality reduction and visualization method](https://www.biorxiv.org/content/early/2017/12/01/120378). +This R package provides an implementation of the [PHATE dimensionality reduction and visualization method](https://www.nature.com/articles/s41587-019-0336-3). -For a thorough overview of the PHATE visualization method, please see the [bioRxiv preprint](https://www.biorxiv.org/content/early/2017/12/01/120378) +For a thorough overview of the PHATE visualization method, please see the [Nature Biotechnology publication](https://www.nature.com/articles/s41587-019-0336-3). For our Python and Matlab implementations, please see [KrishnaswamyLab/PHATE](https://github.com/KrishnaswamyLab/PHATE). @@ -165,6 +164,10 @@ ggplot(tree.phate, aes(x=PHATE1, y=PHATE2, color=tree.data$branches)) + To be consistent with common dimensionality reductions such as PCA (`stats::prcomp`) and t-SNE (`Rtsne::Rtsne`), we require that cells (observations) be rows and genes (features) be columns of your input data. + - **Can I run PHATE with Seurat?** + +PHATE was removed from Seurat in version 3. You can install a version of Seurat with `RunPHATE` included by following the instructions at . + * **I have installed PHATE in Python, but phateR says it is not installed!** Check your `reticulate::py_discover_config("phate")` and compare it to the version of Python in which you installed PHATE (run `which python` and `which pip` in a terminal.) Chances are `reticulate` can't find the right version of Python; you can fix this by adding the following line to your `~/.Renviron`: @@ -175,5 +178,5 @@ You can read more about `Renviron` at . +Please let us know of any issues at the [GitHub repository](https://github.com/KrishnaswamyLab/phateR/issues). If you have any questions or require assistance using PHATE, please read the documentation at or by running `help(phateR::phate)` or contact us at . diff --git a/README.md b/README.md index 542ca0f..68ea2e4 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,10 @@ Stars](https://img.shields.io/github/stars/KrishnaswamyLab/PHATE.svg?style=socia This R package provides an implementation of the [PHATE dimensionality reduction and visualization -method](https://www.biorxiv.org/content/early/2017/12/01/120378). +method](https://www.nature.com/articles/s41587-019-0336-3). For a thorough overview of the PHATE visualization method, please see -the [bioRxiv -preprint](https://www.biorxiv.org/content/early/2017/12/01/120378) +the [Nature Biotechnology publication](https://www.nature.com/articles/s41587-019-0336-3). For our Python and Matlab implementations, please see [KrishnaswamyLab/PHATE](https://github.com/KrishnaswamyLab/PHATE). @@ -203,6 +202,10 @@ To be consistent with common dimensionality reductions such as PCA (observations) be rows and genes (features) be columns of your input data. + - **Can I run PHATE with Seurat?** + +PHATE was removed from Seurat in version 3. You can install a version of Seurat with `RunPHATE` included by following the instructions at . + - **I have installed PHATE in Python, but phateR says it is not installed\!** @@ -222,5 +225,6 @@ You can read more about `Renviron` at Please let us know of any issues at the [GitHub repository](https://github.com/KrishnaswamyLab/phateR/issues). If you have any questions or require assistance using PHATE, please read the -documentation by running `help(phateR::phate)` or contact us at +documentation at +or by running `help(phateR::phate)` or contact us at .