Skip to content

Commit

Permalink
improve install warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgigante committed Dec 10, 2019
1 parent 877f87c commit 5fd2314
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Rmagic/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: Rmagic
Type: Package
Title: MAGIC - Markov Affinity-Based Graph Imputation of Cells
Version: 2.0.3
Version: 2.0.3.999
Authors@R: c(person(given = "David", family = "van Dijk", email = "davidvandijk@gmail.com", role = c("aut")),
person(given = 'Scott', family = 'Gigante', email = 'scott.gigante@yale.edu', role = 'cre',
comment = c(ORCID = '0000-0002-4544-2764')))
Expand All @@ -22,5 +22,5 @@ Suggests:
phateR
License: GPL-2 | file LICENSE
LazyData: true
RoxygenNote: 6.1.1
RoxygenNote: 7.0.2
Encoding: UTF-8
1 change: 1 addition & 0 deletions Rmagic/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ S3method(magic,default)
S3method(magic,seurat)
S3method(print,magic)
S3method(summary,magic)
export(check_pymagic_version)
export(install.magic)
export(library.size.normalize)
export(magic)
Expand Down
9 changes: 6 additions & 3 deletions Rmagic/R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ null_equal <- function(x, y) {
}
}

#' Check that the current MAGIC version in Python is up to date.
#'
#' @importFrom utils packageVersion
#' @export
check_pymagic_version <- function() {
pyversion <- strsplit(pymagic$`__version__`, '\\.')[[1]]
rversion <- strsplit(as.character(packageVersion("Rmagic")), '\\.')[[1]]
Expand All @@ -18,12 +21,12 @@ check_pymagic_version <- function() {
if (as.integer(pyversion[1]) < major_version) {
warning(paste0("Python MAGIC version ", pymagic$`__version__`, " is out of date (recommended: ",
major_version, ".", minor_version, "). Please update with pip ",
"(e.g. pip install --upgrade magic-impute) or Rmagic::install.magic()."))
"(e.g. ", reticulate::py_config()$python, " -m pip install --upgrade magic-impute) or Rmagic::install.magic()."))
return(FALSE)
} else if (as.integer(pyversion[2]) < minor_version) {
warning(paste0("Python MAGIC version ", pymagic$`__version__`, " is out of date (recommended: ",
major_version, ".", minor_version, "). Consider updating with pip ",
"(e.g. pip install --upgrade magic-impute) or Rmagic::install.magic()."))
"(e.g. ", reticulate::py_config()$python, " -m pip install --upgrade magic-impute) or Rmagic::install.magic()."))
return(FALSE)
}
return(TRUE)
Expand Down Expand Up @@ -113,7 +116,7 @@ install.magic <- function(envname = "r-reticulate", method = "auto",
error = function(e) {
stop(paste0(
"Cannot locate MAGIC Python package, please install through pip ",
"(e.g. pip install magic-impute) and then restart R."
"(e.g. ", reticulate::py_config()$python, " -m pip install magic-impute) and then restart R."
))
}
)
Expand Down
11 changes: 11 additions & 0 deletions Rmagic/man/check_pymagic_version.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions Rmagic/man/install.magic.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 53 additions & 14 deletions Rmagic/man/magic.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5fd2314

Please sign in to comment.