Skip to content

Commit

Permalink
Make VGAM a suggested package
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Hoffman committed Jun 25, 2018
1 parent 63224eb commit 917d675
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Imports:
Rtsne,
fpc,
ape,
VGAM,
pbapply,
igraph,
RANN,
Expand Down Expand Up @@ -101,6 +100,7 @@ Collate:
RoxygenNote: 6.0.1
Suggests:
gdata,
VGAM,
testthat,
loomR,
phateR,
Expand Down
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,6 @@ importFrom(ROCR,performance)
importFrom(ROCR,prediction)
importFrom(Rcpp,evalCpp)
importFrom(Rtsne,Rtsne)
importFrom(VGAM,tobit)
importFrom(VGAM,vgam)
importFrom(ape,as.phylo)
importFrom(ape,drop.tip)
importFrom(ape,nodelabels)
Expand Down
8 changes: 4 additions & 4 deletions R/differential_expression_internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ DifferentialTobit <- function(x1, x2, lower = 1, upper = Inf) {
#internal function to run Tobit DE test
#credit to Cole Trapnell for this
#
#' @importFrom VGAM vgam tobit
#' @importFrom stats as.formula
#
TobitFitter <- function(x, modelFormulaStr, lower = 1, upper = Inf){
TobitFitter <- function(x, modelFormulaStr, lower = 1, upper = Inf) {
PackageCheck('VGAM')
tryCatch(
expr = return(suppressWarnings(expr = vgam(
expr = return(suppressWarnings(expr = VGAM::vgam(
formula = as.formula(object = modelFormulaStr),
family = tobit(Lower = lower, Upper = upper),
family = VGAM::tobit(Lower = lower, Upper = upper),
data = x
))),
#warning = function(w) { FM_fit },
Expand Down
24 changes: 23 additions & 1 deletion R/utilities_internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,31 @@ LengthCheck <- function(values, cutoff = 0) {
#
MaxN <- function(x, N = 2){
len <- length(x)
if(N > len) {
if (N > len) {
warning('N greater than length(x). Setting N=length(x)')
N <- length(x)
}
sort(x, partial = len - N + 1)[len - N + 1]
}

# Check the existence of a package
#
# @param ... Package names
# @param error If true, throw an error if the package doesn't exist
#
# @return Invisibly returns boolean denoting if the package is installed
#
#' @importFrom utils installed.packages
#
PackageCheck <- function(..., error = TRUE) {
pkgs <- unlist(x = c(...), use.names = FALSE)
package.installed <- pkgs %in% rownames(x = installed.packages())
if (error && any(!package.installed)) {
stop(
"Cannot find ",
paste(pkgs[!package.installed], collapse = ', '),
"; please install"
)
}
invisible(x = package.installed)
}

0 comments on commit 917d675

Please sign in to comment.