Skip to content

Commit

Permalink
move some feature-specific pkgs to suggests
Browse files Browse the repository at this point in the history
  • Loading branch information
KasperSkytte committed Dec 6, 2021
1 parent 2f7f09f commit b84cbc0
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 35 deletions.
29 changes: 14 additions & 15 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: mmgenome2
Type: Package
Title: Tools for extracting individual genomes from metagenomes
Description: mmgenome: a toolbox for extracting individual genomes from metagenomes.
Version: 2.2.0
Version: 2.2.1
Date: 2018-01-01
Encoding: UTF-8
Authors@R: c(
Expand Down Expand Up @@ -46,29 +46,28 @@ Imports:
magrittr,
dplyr,
Biostrings,
rstudioapi,
clipr,
digest,
igraph,
ggrepel,
tibble,
tidyr,
stringr,
shiny,
rlang
biocViews:
Biostrings
RoxygenNote: 7.1.1
purrr,
rlang,
plyr,
forcats
remotes:
github::kasperskytte/Rtsne@openmp,
bioc::Biostrings
RoxygenNote: 7.1.2
VignetteBuilder: knitr
Suggests:
testthat,
knitr,
tools,
utils,
vegan,
shiny,
Rtsne,
digest,
plotly,
purrr,
plyr,
forcats
rstudioapi,
clipr,
plotly
URL: https://kasperskytte.github.io/mmgenome2
16 changes: 2 additions & 14 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ importFrom(Biostrings,readDNAStringSet)
importFrom(Biostrings,reverseComplement)
importFrom(Biostrings,width)
importFrom(Biostrings,writeXStringSet)
importFrom(clipr,write_clip)
importFrom(cowplot,plot_grid)
importFrom(data.table,data.table)
importFrom(data.table,fread)
Expand Down Expand Up @@ -53,21 +52,10 @@ importFrom(igraph,graph.data.frame)
importFrom(igraph,layout_with_fr)
importFrom(magrittr,"%<>%")
importFrom(magrittr,"%>%")
importFrom(plyr,ldply)
importFrom(purrr,imap)
importFrom(rlang,quos)
importFrom(rlang,sym)
importFrom(rstudioapi,viewer)
importFrom(shiny,actionButton)
importFrom(shiny,div)
importFrom(shiny,fillPage)
importFrom(shiny,icon)
importFrom(shiny,observeEvent)
importFrom(shiny,p)
importFrom(shiny,plotOutput)
importFrom(shiny,reactiveValues)
importFrom(shiny,renderPlot)
importFrom(shiny,runApp)
importFrom(shiny,shinyApp)
importFrom(shiny,stopApp)
importFrom(sp,point.in.polygon)
importFrom(stringr,str_remove)
importFrom(stringr,str_replace_all)
Expand Down
27 changes: 24 additions & 3 deletions R/internals.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
#' @title Check for installed package
#' @description Returns error if a required package is not installed. Mostly used for checking whether packages listed under the Suggests field in the DESCRIPTION file is installed.
#'
#' @param pkg The package to check for, a character of length 1.
#' @param msg Optionally additional text appended (with \code{paste0}) to the default error message.
#'
#' @return Returns error and message if not installed, otherwise \code{invisible(TRUE)}
#' @author Kasper Skytte Andersen \email{ksa@@bio.aau.dk}
checkReqPkg <- function(pkg, msg = "") {
stopifnot(is.character(pkg), length(pkg) == 1L, nchar(pkg) > 0)
if (!requireNamespace(pkg, quietly = TRUE)) {
stopifnot(is.character(msg))
stop(
paste0("Package '", pkg, "' is required but not installed. ", msg),
call. = FALSE
)
}
require(pkg, quietly = TRUE, character.only = TRUE)
}

#' @title Merge mm object with more data
#'
#' @description Internal function used in mmload. \code{y} can be a named vector, dataframe, or a list containing any of these types of data to be merged with \code{x}.
Expand Down Expand Up @@ -117,15 +137,16 @@ mmmerge <- function(x, y, type) {
#' @return A data frame with the x/y coordinates of the mousepositions clicked in the ggplot2 plot.
#'
#' @import ggplot2
#' @importFrom shiny actionButton div fillPage icon observeEvent p plotOutput reactiveValues renderPlot runApp shinyApp stopApp
#' @importFrom clipr write_clip
#' @importFrom rstudioapi viewer
#'
#' @author Kasper Skytte Andersen \email{ksa@@bio.aau.dk}
#' @author Rasmus Hansen Kirkegaard \email{rhk@@bio.aau.dk}
#' @author Soren M. Karst \email{smk@@bio.aau.dk}
#' @author Mads Albertsen \email{MadsAlbertsen85@@gmail.com}
mmlocator <- function(plot, x_scale = NULL, y_scale = NULL) {
checkReqPkg("shiny")
checkReqPkg("rstudioapi")
checkReqPkg("clipr")

app <- shinyApp(
ui = fillPage(
padding = c(5, 5, 50),
Expand Down
6 changes: 4 additions & 2 deletions R/mmload.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#' @importFrom dplyr mutate_all funs group_by left_join summarise_all
#' @importFrom stringr str_replace_all str_remove
#' @importFrom data.table fread
#' @importFrom tools file_path_sans_ext
#'
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -201,7 +202,8 @@ mmload <- function(assembly,

##### PCA of tetranucleotides #####
if (isTRUE(kmer_pca)) {
checkReqPkgs("vegan")
checkReqPkg("vegan")

if (isTRUE(verbose)) {
message(paste0(
"Calculating principal components of kmer (k=",
Expand All @@ -222,7 +224,7 @@ mmload <- function(assembly,

##### BH tSNE of tetranucleotides #####
if (isTRUE(kmer_BH_tSNE)) {
checkReqPkgs("Rtsne")
checkReqPkg("Rtsne", "To install with support for multithreading run:\n remotes::install_github('kasperskytte/Rtsne@openmp')\notherwise just install from CRAN.")
if (isTRUE(verbose)) {
message(paste0(
"Calculating Barnes-Hut t-Distributed Stochastic Neighbor Embedding representations of kmer (k=",
Expand Down
2 changes: 1 addition & 1 deletion R/mmplot_cov_profiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ mmplot_cov_profiles <- function(mm,

# add points to plot and generate plotly hover labels if interactive, return plot
if (isTRUE(interactive_plot)) {
checkReqPkgs(c("plotly", "purrr"))
checkReqPkg("plotly")
data_plotly <- gg %>%
purrr::imap(~ paste(.y, .x, sep = ": ")) %>%
as.data.frame() %>%
Expand Down
22 changes: 22 additions & 0 deletions man/checkReqPkg.Rd

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

0 comments on commit b84cbc0

Please sign in to comment.