Skip to content

Commit

Permalink
fix r check issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AliciaSchep committed Jul 4, 2020
1 parent 1124472 commit d677e34
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 14 deletions.
5 changes: 2 additions & 3 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: iheatmapr
Type: Package
Title: Interactive, Complex Heatmaps
Version: 1.0.0
Version: 1.0.0.9999
Authors@R: c(person("Alicia", "Schep",
email = "aschep@gmail.com",
role = c("aut", "cre"),
Expand Down Expand Up @@ -49,7 +49,6 @@ Depends:
R (>= 3.2.0)
Imports:
methods,
plyr,
utils,
magrittr,
stats,
Expand All @@ -71,7 +70,7 @@ Suggests:
roxygen2,
covr,
webshot
RoxygenNote: 7.0.2
RoxygenNote: 7.1.1
VignetteBuilder: knitr
URL: https://docs.ropensci.org/iheatmapr (website) https://github.com/ropensci/iheatmapr
BugReports: https://github.com/ropensci/iheatmapr/issues
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Expand Up @@ -76,6 +76,6 @@ importFrom(htmlwidgets,sizingPolicy)
importFrom(jsonlite,toJSON)
importFrom(knitr,knit_print)
importFrom(magrittr,"%>%")
importFrom(plyr,round_any)
importFrom(scales,zero_range)
importFrom(stats,setNames)
importFrom(utils,modifyList)
11 changes: 5 additions & 6 deletions R/colorbars.R
Expand Up @@ -79,7 +79,6 @@ setup_colorbar_grid <- function(nrows = 3,
}

#' @importFrom scales zero_range
#' @importFrom plyr round_any
tickvals_helper <- function(zmin, zmid, zmax) {

rng <- c(zmin, zmax)
Expand All @@ -92,12 +91,12 @@ tickvals_helper <- function(zmin, zmid, zmax) {
}

if (zmid > zmin && zmid < zmax){
out <- c(round_any(zmin,precision,ceiling),
round_any(zmid,precision),
round_any(zmax,precision,floor))
out <- c(round_multiple(zmin,precision,ceiling),
round_multiple(zmid,precision),
round_multiple(zmax,precision,floor))
} else{
out <- c(round_any(zmin,precision,ceiling),
round_any(zmax,precision,floor))
out <- c(round_multiple(zmin,precision,ceiling),
round_multiple(zmax,precision,floor))
}

out
Expand Down
40 changes: 37 additions & 3 deletions R/list_utils.R
@@ -1,49 +1,80 @@
#' S4 List Utils for Iheatmap classes
#'
#' These are utility methods for list-like classes in the package.
#' @name iheatmap_list_utils
#' @rdname iheatmap_list_utils
#' @param x input
#' @docType methods
#' @aliases length,IheatmapList-method
#' as.list,IheatmapList-method
#' names,IheatmapList-method
#' `names<-`,IheatmapList-method
#' `$`,IheatmapList-method
#' `$<-`,IheatmapList-method
#' `[`,IheatmapList-method
#' `[<-`,IheatmapList-method
#' `[[`,IheatmapList-method
#' `[[<-`,IheatmapList-method
#' lapply,IheatmapList-method
#' vapply,IheatmapList-method
#' @importFrom stats setNames
#' @keywords internal

setMethod("length", "IheatmapList", function(x) length(x@listData))

setAs("IheatmapList", "list", function(from) as.list(from))

#' @rdname iheatmap_list_utils
setMethod("as.list", "IheatmapList", function(x) {
x@listData
})

#' @rdname iheatmap_list_utils
setMethod("[", "IheatmapList", function(x, i) {
x_subset <- x
x_subset@listData <- x_subset@listData[i]
x_subset
})

#' @rdname iheatmap_list_utils
setReplaceMethod("[", "IheatmapList", function(x, i, value) {
x@listData[i] <- value
x
})

#' @rdname iheatmap_list_utils
setMethod("[[", "IheatmapList", function(x, i) {
x@listData[[i]]
})

#' @rdname iheatmap_list_utils
setReplaceMethod("[[", "IheatmapList", function(x, i, value) {
x@listData[[i]] <- value
x
})


#' @rdname iheatmap_list_utils
setMethod("$", "IheatmapList", function(x, name) x[[name, exact=FALSE]])

#' @rdname iheatmap_list_utils
setReplaceMethod("$", "IheatmapList",
function(x, name, value) {
x[[name]] <- value
x
})

#' @rdname iheatmap_list_utils
setMethod("names", "IheatmapList", function(x) names(x@listData))

#' @rdname iheatmap_list_utils
setReplaceMethod("names", "IheatmapList",
function(x, value) {
names(x@listData) <- value
x
})


#' @rdname iheatmap_list_utils
#' @param FUN function to apply to each element of x
setMethod("lapply", "IheatmapList",
function(X, FUN, ...)
{
Expand All @@ -53,11 +84,14 @@ setMethod("lapply", "IheatmapList",
}
)

#' @rdname iheatmap_list_utils
#' @param FUN.VALUE template for return value from FUN
#' @param USE.NAMES logical, use names?
#' @param ... additional arguments
setMethod("vapply", "IheatmapList",
function(X, FUN, FUN.VALUE, ..., USE.NAMES = TRUE)
{
FUN <- match.fun(FUN)
#browser()
ii <- setNames(seq_along(X), names(X))
vapply(ii, function(i) do.call(FUN, c(X[[i]], list(...))), FUN.VALUE, USE.NAMES = USE.NAMES)
}
Expand Down
5 changes: 5 additions & 0 deletions R/utils.R
Expand Up @@ -2,6 +2,11 @@
#' @export
magrittr::`%>%`

# Similar to round_any function in plyr
round_multiple <- function(x, precision, fun = round) {
fun(x / precision) * precision
}

# makes x based on colnames of mat if available
# if not available, just uses 1 to number of columns
default_x <- function(mat){
Expand Down
65 changes: 65 additions & 0 deletions man/iheatmap_list_utils.Rd

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

2 changes: 1 addition & 1 deletion man/reexports.Rd

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

0 comments on commit d677e34

Please sign in to comment.