Commit a16a4d5c authored by domingue's avatar domingue
Browse files

Updated paradigm - not everything was committed last time around

parent 545dfef1
Pipeline #1814 canceled with stage
......@@ -40,6 +40,7 @@ export(install_package)
export(interaction_plot)
export(intersect_all)
export(load_pack)
export(load_renv)
export(makePcaPlot)
export(map_ens_archive_to_build)
export(match_df)
......
......@@ -8,7 +8,7 @@
#' @return A message listing files that were not found and might require manual installation
#'
#' @export
#'
#'
#' @importFrom BiocManager available install
#'
#' @examples
......@@ -76,10 +76,33 @@ load_pack <- function(pkg, warn_conflicts = TRUE) {
#' @param min_version The minimal version desired
#'
#' @importFrom utils packageVersion
#'
#'
#' @return An error message when the installed packaged version is older.
#' @export
check_version <- function(pkg, min_version) {
cur_version <- packageVersion(pkg)
if (cur_version < min_version) stop(sprintf("Package %s needs a newer version, found %s, need at least %s", pkg, cur_version, min_version))
}
#' Check version
#'
#' Compares a package version with current version
#'
#' @param pkg The package to be compared
#' @param min_version The minimal version desired
#'
#' @importFrom renv load
#'
#' @return An error message when the installed packaged version is older.
#' @export
load_renv <- function() {
scripts_dir <- Sys.getenv("PRJ_SCRIPTS")
lock_file <- file.path(scripts_dir, "renv.lock")
if (scripts_dir != "" & file.exists(lock_file)) {
message("Project variables were detected. Loading renv")
renv::load(project = Sys.getenv("PRJ_SCRIPTS"))
} else {
error("renv not loaded: Bash variable PRJ_SCRIPTS was not found.")
}
}
......@@ -7,15 +7,9 @@
gsubfn.engine = "R"
)
load_renv <- function() {
scripts_dir <- Sys.getenv("PRJ_SCRIPTS")
lock_file <- file.path(scripts_dir, "renv.lock")
if (scripts_dir != "" & file.exists(lock_file)) {
packageStartupMessage("Project variables were detected. Loading renv")
renv::load(project = Sys.getenv("PRJ_SCRIPTS"))
}
if (!require("renv", character.only = TRUE)) {
install.packages("renv")
}
load_renv()
## load core packages
load_pack("purrr")
......@@ -33,7 +27,7 @@ load_renv()
## common plotting requirements since they are omnipresent
load_pack("ggplot2")
load_pack("scales", warn_conflicts = F) # note this has a known conflit with purrr::discard
load_pack("scales", warn_conflicts = F) # note this has a known conflict with purrr::discard
load_pack("grid")
load_pack("RColorBrewer")
......
......@@ -19,7 +19,7 @@ Replace empty "cells" with NA
Holger's notes:
for na instead use mutate_each with:
empty_as_na <- function(x) safe_ifelse(x=="", NA, x)
empty_as_na <- function(x) ifelse(class(x) %in% c("factor", "character") & x=="", NA, x)
empty_as_na <- function(x) ifelse(class(x) \%in\% c("factor", "character") & x=="", NA, x)
}
\examples{
\dontrun{
......
......@@ -4,8 +4,15 @@
\alias{ggsave2}
\title{Save plot}
\usage{
ggsave2(gplot = last_plot(), width = 8, height = 6, prefix = "",
saveData = FALSE, outputFormat = gg2Format, ...)
ggsave2(
gplot = last_plot(),
width = 8,
height = 6,
prefix = "",
saveData = FALSE,
outputFormat = gg2Format,
...
)
}
\arguments{
\item{gplot}{= last_plot() <what param does>}
......
......@@ -4,8 +4,15 @@
\alias{makePcaPlot}
\title{Plot PCA}
\usage{
makePcaPlot(matrixData, color_by = NA, items = rownames(matrixData),
title = NA, center = TRUE, repel = TRUE, scale = FALSE)
makePcaPlot(
matrixData,
color_by = NA,
items = rownames(matrixData),
title = NA,
center = TRUE,
repel = TRUE,
scale = FALSE
)
}
\arguments{
\item{matrixData}{A transposed matrix of gene counts. Samples should be rows.}
......
......@@ -19,6 +19,6 @@ Moves any number of columns to the last position in the data frame
}
\details{
TBD how to make this possible without quoting column names?
An alternative would be: df %>% select(-b, pushColNames())
An alternative would be: df \%>\% select(-b, pushColNames())
I am not updating the function because is being used in production.
}
......@@ -17,7 +17,7 @@ a vector of the same type as x
\description{
replace NAs with any value within pipe.
Holger's example that did not work for me:
just use ... %>% do(replaceNA(0)) %>% ...
just use ... \%>\% do(replaceNA(0)) \%>\% ...
See example
}
\examples{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment