diff --git a/DESCRIPTION b/DESCRIPTION index 5a1f2bf..ffe4fb1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: SeuratData Type: Package Title: Install and Manage Seurat Datasets -Version: 0.1.0 -Date: 2019-07-17 +Version: 0.2.0 +Date: 2019-11-15 Authors@R: c( person(given = 'Rahul', family = 'Satija', email = 'rsatija@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0001-9448-8833')), person(given = 'Paul', family = 'Hoffman', email = 'phoffman@nygenome.org', role = c('aut', 'cre'), comment = c(ORCID = '0000-0002-7693-8957')), @@ -18,11 +18,14 @@ License: GPL-3 | file LICENSE Encoding: UTF-8 LazyData: true RoxygenNote: 6.1.1 +Depends: + R (>= 3.5.0) Imports: cli, crayon, + rappdirs, stats, utils -Collate: +Collate: 'zzz.R' 'seurat_data.R' diff --git a/NAMESPACE b/NAMESPACE index bd01537..4b41238 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,6 +3,7 @@ export(AvailableData) export(InstallData) export(InstalledData) +export(LoadData) export(RemoveData) export(UpdateData) importFrom(cli,rule) @@ -14,8 +15,10 @@ importFrom(crayon,col_nchar) importFrom(crayon,green) importFrom(crayon,red) importFrom(crayon,yellow) +importFrom(rappdirs,user_data_dir) importFrom(stats,na.omit) importFrom(utils,available.packages) +importFrom(utils,data) importFrom(utils,install.packages) importFrom(utils,packageVersion) importFrom(utils,remove.packages) diff --git a/R/seurat_data.R b/R/seurat_data.R index ff1743d..c0bfe09 100644 --- a/R/seurat_data.R +++ b/R/seurat_data.R @@ -16,7 +16,11 @@ NULL #' #' @export #' -#' @seealso \code{\link{InstallData}} \code{\link{InstalledData}} \code{\link{RemoveData}} \code{\link{UpdateData}} +#' @seealso \code{\link{InstallData}} \code{\link{InstalledData}} +#' \code{\link{RemoveData}} \code{\link{UpdateData}} +#' +#' @examples +#' AvailableData() #' AvailableData <- function() { UpdateManifest() @@ -35,10 +39,22 @@ AvailableData <- function() { #' #' @export #' -#' @seealso \code{\link{AvailableData}} \code{\link{InstalledData}} \code{\link{RemoveData}} \code{\link{UpdateData}} +#' @seealso \code{\link{AvailableData}} \code{\link{InstalledData}} +#' \code{\link{RemoveData}} \code{\link{UpdateData}} +#' +#' @examples +#' \dontrun{ +#' InstallData('pbmc3k') +#' } #' InstallData <- function(ds, force.reinstall = FALSE, ...) { UpdateManifest() + if (pkg.env$source != 'remote') { + stop( + "No access to remote SeuratData repository, unable to install new datasets", + call. = FALSE + ) + } pkgs <- NameToPackage(ds = ds) if (!force.reinstall) { installed <- intersect(x = pkgs, y = rownames(x = InstalledData())) @@ -46,7 +62,7 @@ InstallData <- function(ds, force.reinstall = FALSE, ...) { warning( "The following packages are already installed and will not be reinstalled: ", paste( - gsub(pattern = '\\.SeuratData', replacement = '', x = installed), + gsub(pattern = pkg.key, replacement = '', x = installed), collapse = ', ' ), call. = FALSE, @@ -63,7 +79,12 @@ InstallData <- function(ds, force.reinstall = FALSE, ...) { for (p in pkgs2[pkgs2 %in% search()]) { detach(name = p, unload = TRUE, character.only = TRUE) } - install.packages(pkgs = pkgs, repos = getOption(x = "SeuratData.repo.use"), type = 'source', ...) + install.packages( + pkgs = pkgs, + repos = getOption(x = "SeuratData.repo.use"), + type = 'source', + ... + ) for (pkg in pkgs) { attachNamespace(ns = pkg) pkg.env$attached <- c(pkg.env$attached, pkg) @@ -86,13 +107,73 @@ InstallData <- function(ds, force.reinstall = FALSE, ...) { #' #' @export #' -#' @seealso \code{\link{AvailableData}} \code{\link{InstallData}} \code{\link{RemoveData}} \code{\link{UpdateData}} +#' @seealso \code{\link{AvailableData}} \code{\link{InstallData}} +#' \code{\link{RemoveData}} \code{\link{UpdateData}} +#' +#' @examples +#' InstalledData() #' InstalledData <- function() { dat <- AvailableData() return(dat[which(x = dat$Installed, ), , drop = FALSE]) } +#' Modularly load a dataset +#' +#' @inheritParams LoadH5Seurat +#' @param ds Optional name of dataset to load +#' @param type How to load the \code{Seurat} object; choose from +#' \describe{ +#' \item{info}{Information about the object and what's stored in it} +#' \item{raw}{The raw form of the dataset, no other options are evaluated} +#' \item{processed}{The proccessed data, modular loading avaible by setting other parameters} +#' } +#' +#' @inherit LoadH5Seurat return +#' +#' @importFrom utils data +#' +#' @export +#' +#' @seealso \code{\link[utils]{data}} +#' +LoadData <- function( + ds, + type = c('info', 'raw', 'processed'), + assays = NULL, + reductions = NULL, + graphs = NULL, + verbose = TRUE +) { + .NotYetImplemented() + installed <- InstalledData() + if (!NameToPackage(ds = ds) %in% rownames(x = installed)) { + stop("Cannot find dataset ", ds, call. = FALSE) + } + ds <- NameToPackage(ds = ds) + type <- match.arg(arg = tolower(x = type), choices = c('info', 'raw', 'processed')) + if (type == 'raw') { + e <- new.env() + ds <- gsub(pattern = '\\.SeuratData', replacement = '', x = ds) + data(list = ds, envir = e) + return(e[[ds]]) + } + .NotYetImplemented() + type <- match.arg(arg = type, choices = c('info', 'processed')) + return(LoadH5Seurat( + file = system.file( + file.path('extdata', 'processed.h5Seurat'), + package = ds, + mustWork = TRUE + ), + type = ifelse(test = type == 'processed', yes = 'object', no = type), + assays = assays, + reductions = reductions, + graphs = graphs, + verbose = verbose + )) +} + #' Remove a dataset #' #' @inheritParams utils::remove.packages @@ -102,7 +183,13 @@ InstalledData <- function() { #' #' @export #' -#' @seealso \code{\link{AvailableData}} \code{\link{InstallData}} \code{\link{InstalledData}} \code{\link{UpdateData}} +#' @seealso \code{\link{AvailableData}} \code{\link{InstallData}} +#' \code{\link{InstalledData}} \code{\link{UpdateData}} +#' +#' @examples +#' \dontrun{ +#' RemoveData('pbmc3k') +#' } #' RemoveData <- function(ds, lib) { UpdateManifest() @@ -125,9 +212,22 @@ RemoveData <- function(ds, lib) { #' #' @export #' -#' @seealso \code{\link{AvailableData}} \code{\link{InstallData}} \code{\link{InstalledData}} \code{\link{RemoveData}} +#' @seealso \code{\link{AvailableData}} \code{\link{InstallData}} +#' \code{\link{InstalledData}} \code{\link{RemoveData}} +#' +#' @examples +#' \dontrun{ +#' UpdateData(ask = FALSE) +#' } #' UpdateData <- function(ask = TRUE, lib.loc = NULL) { + UpdateManifest() + if (pkg.env$source != 'remote') { + stop( + "No access to remote SeuratData repository, unable to update datasets", + call. = FALSE + ) + } update.packages(lib.loc = lib.loc, repos = getOption(x = "SeuratData.repo.use"), ask = ask, type = 'source') UpdateManifest() invisible(x = NULL) diff --git a/R/zzz.R b/R/zzz.R index 156cf16..51681a0 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -2,11 +2,19 @@ #' #' @section Package options: #' -#' SeuratData uses the following [options()] to configure behaviour: +#' SeuratData uses the following options to control behaviour, users can configure +#' these with \code{\link[base]{options}}: #' #' \itemize{ #' \item `SeuratData.repo.use`: Set the location where the SeuratData datasets #' are stored. Users generally should not modify. +#' \item `SeuratData.manifest.cache`: Cache the data manifest whenever we talk +#' to the data repository; note, setting to \code{FALSE} will simply prevent +#' SeuratData from caching the manifest, not from reading a previously cached +#' manifest +#' \item `SeuratData.roaming`: For Windows users, use a roaming profile directory +#' for domain users. See \url{https://en.wikipedia.org/wiki/Roaming_user_profile} +#' for a brief overview and Microsoft's documentation for greater detail #' } #' #' @docType package @@ -17,16 +25,23 @@ "_PACKAGE" #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -# Global variables and environment +# Global variables, default options, and package environment #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% default.options <- list( - SeuratData.repo.use = 'https://seurat.nygenome.org' + SeuratData.repo.use = 'http://seurat.nygenome.org/', + SeuratData.manifest.cache = TRUE, + SeuratData.roaming = FALSE ) +pkg.key <- '\\.SeuratData$' + pkg.env <- new.env() -pkg.env$manifest <- vector(mode = 'character') +pkg.env$manifest <- vector(mode = 'list') +pkg.env$source <- vector(mode = 'character') +pkg.env$update.call <- vector(mode = 'character') pkg.env$attached <- vector(mode = 'character') +pkg.env$extdata.warn <- FALSE #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # Internal functions @@ -44,6 +59,12 @@ pkg.env$attached <- vector(mode = 'character') #' @author Hadley Wickham #' @references \url{https://adv-r.hadley.nz/functions.html#missing-arguments} #' +#' @examples +#' \dontrun{ +#' 4 %||% 5 +#' NULL %|| 5 +#' } +#' #' @keywords internal #' `%||%` <- function(lhs, rhs) { @@ -54,6 +75,28 @@ pkg.env$attached <- vector(mode = 'character') } } +#' Get an application data directory +#' +#' @inheritParams AttachData +#' @param author Author name for application +#' +#' @return A character vector with path to the application data dir +#' +#' @importFrom rappdirs user_data_dir +#' +#' @seealso \code{\link[rappdirs]{user_data_dir}} +#' +#' @keywords internal +#' +AppData <- function(pkgname = 'SeuratData', author = pkgname) { + return(user_data_dir( + appname = pkgname, + appauthor = author, + version = file.path('%p-platform', '%v'), + roaming = getOption(x = 'SeuratData.roaming', default = FALSE) + )) +} + #' Attach datasets #' #' @param pkgname Name of package @@ -133,12 +176,99 @@ AttachData <- function(pkgname = 'SeuratData') { invisible(x = NULL) } +#' Enumerate a list or vector +#' +#' @param x A list or a vector +#' +#' @return A list of length \code{x} with the following named values: +#' \describe{ +#' \item{\code{name}}{The name of \code{x} at a given index} +#' \item{\code{value}}{The value of \code{x} at the corresponding index} +#' } +#' +#' @note For any given index \code{i} in \code{x}, all attempts to use the name +#' of the value of \code{x} at \code{i} will be made. If there is no name +#' (eg. \code{nchar(x = names(x = x)[i]) == 0}), the index \code{i} will be used +#' in its stead +#' +#' @keywords internal +#' +Enumerate <- function(x) { + indices <- seq_along(along.with = x) + keys <- names(x = x) %||% as.character(x = indices) + keys[nchar(x = keys) == 0] <- indices[nchar(x = keys) == 0] + vals <- lapply( + X = indices, + FUN = function(i) { + return(c('name' = keys[i], 'value' = unname(obj = x[i]))) + } + ) + return(vals) +} + +#' Check to see if a matrix is empty +#' +#' Deterime if a matrix is empty or not +#' +#' @param x A matrix +#' +#' @return \code{TRUE} if the matrix is empty otherwise \code{FALSE} +#' +#' @details A matrix is considered empty if it satisfies one of the following +#' conditions: +#' \itemize{ +#' \item The dimensions of the matrix are 0-by-0 (\code{all(dim(x) == 0)}) +#' \item The dimensions of the matrix are 1-by-1 (\code{all(dim(x) == 1)}) and +#' the sole value is a \code{NA} +#' } +#' These two situations correspond to matrices generated with either +#' \code{new('matrix')} or \code{matrix()} +#' +#' @examples +#' \dontrun{ +#' IsMatrixEmpty(new('matrix')) +#' IsMatrixEmpty(matrix()) +#' IsMatrixEmpty(matrix(1:9, nrow = 3)) +#' } +#' +#' @keywords internal +#' +IsMatrixEmpty <- function(x) { + matrix.dims <- dim(x = x) + matrix.na <- all(matrix.dims == 1) && all(is.na(x = x)) + return(all(matrix.dims == 0) || matrix.na) +} + +#' Make a space +#' +#' @param n Length space should be +#' +#' @return A space (' ') of length \code{n} +#' +#' @examples +#' \dontrun{ +#' MakeSpace(10) +#' } +#' +#' @keywords internal +#' +MakeSpace <- function(n) { + return(paste(rep_len(x = ' ', length.out = n), collapse = '')) +} + #' Find dataset packages based on name #' #' @param ds Names of datasets #' #' @return A vector of package names based on dataset names #' +#' @examples +#' \dontrun{ +#' NameToPackage('cbmc') +#' NameToPackage('pbmc3k.SeuratData') +#' NameToPackage('notadataset') +#' } +#' #' @keywords internal #' NameToPackage <- function(ds) { @@ -171,77 +301,134 @@ NameToPackage <- function(ds) { #' @keywords internal #' UpdateManifest <- function() { - avail.pkgs <- available.packages( - repos = getOption(x = "SeuratData.repo.use"), - type = 'source', - fields = c('Description', 'Title'), - ignore_repo_cache = TRUE + # Set some defaults + pkg.env$source <- 'remote' + cache.manifest <- file.path( + AppData(pkgname = 'SeuratData', author = 'Satija Lab'), + 'manifest.Rds' ) - avail.pkgs <- as.data.frame(x = avail.pkgs, stringsAsFactors = FALSE) - avail.pkgs <- avail.pkgs[grepl(pattern = '\\.SeuratData$', x = avail.pkgs$Package), , drop = FALSE] - avail.pkgs <- apply( - X = avail.pkgs, - MARGIN = 1, - FUN = function(pkg) { - dataset <- gsub( - pattern = '\\.SeuratData$', - replacement = '', - x = pkg[['Package']] - ) - desc <- unlist(x = strsplit(x = pkg[['Description']], split = '\n')) - desc <- sapply( - X = strsplit(x = desc, split = ':'), - FUN = function(x) { - name <- trimws(x = x[[1]]) - val <- trimws(x = unlist(x = strsplit(x = x[[2]], split = ','))) - val <- paste(val, collapse = ', ') - names(x = val) <- name - return(val) - } - ) - desc <- sapply( - X = desc, - FUN = function(x) { - x <- tryCatch( - expr = as.numeric(x = x), - warning = function(...) { - return(x) - } - ) - if (!is.numeric(x = x) && !is.na(x = as.logical(x = x))) { - x <- as.logical(x = x) - } - return(x) - }, - simplify = FALSE, - USE.NAMES = TRUE - ) - desc <- c( - 'Dataset' = dataset, - 'Version' = pkg[['Version']], - 'Summary' = pkg[['Title']], - desc + # Attempt to get the manifest from the remote server + avail.pkgs <- tryCatch( + expr = available.packages( + repos = getOption(x = "SeuratData.repo.use"), + type = 'source', + fields = c('Description', 'Title'), + ignore_repo_cache = TRUE + ), + warning = function(...) { + pkg.env$source <- ifelse( + test = file.exists(cache.manifest), + yes = 'appdir', + no = 'extdata' ) - return(desc) } ) - manifest.names <- unique(x = unlist( - x = lapply(X = avail.pkgs, FUN = names), - use.names = FALSE - )) - for (pkg in names(x = avail.pkgs)) { - for (col in manifest.names) { - avail.pkgs[[pkg]][[col]] <- avail.pkgs[[pkg]][[col]] %||% NA + # Process the manifest + if (pkg.env$source == 'remote') { + # Lots of stuff to get the manifest modified from the available.packages format + # into something usable by SeuratData + pkg.env$extdata.warn <- FALSE + avail.pkgs <- as.data.frame(x = avail.pkgs, stringsAsFactors = FALSE) + # Ensure we only use datasets tagged with .SeuratData + avail.pkgs <- avail.pkgs[grepl(pattern = pkg.key, x = avail.pkgs$Package), , drop = FALSE] + # Filter down to dataset name, short summary from package title, and + # metadata contained in package description + avail.pkgs <- apply( + X = avail.pkgs, + MARGIN = 1, + FUN = function(pkg) { + # Get dataset name + dataset <- gsub( + pattern = pkg.key, + replacement = '', + x = pkg[['Package']] + ) + # Process the description metadata + desc <- unlist(x = strsplit(x = pkg[['Description']], split = '\n')) + desc <- sapply( + X = strsplit(x = desc, split = ':'), + FUN = function(x) { + name <- trimws(x = x[[1]]) + val <- trimws(x = unlist(x = strsplit(x = x[[2]], split = ','))) + val <- paste(val, collapse = ', ') + names(x = val) <- name + return(val) + } + ) + desc <- sapply( + X = desc, + FUN = function(x) { + x <- tryCatch( + expr = as.numeric(x = x), + warning = function(...) { + return(x) + } + ) + if (!is.numeric(x = x) && !is.na(x = as.logical(x = x))) { + x <- as.logical(x = x) + } + return(x) + }, + simplify = FALSE, + USE.NAMES = TRUE + ) + # Assemble the information + desc <- c( + 'Dataset' = dataset, + 'Version' = pkg[['Version']], + 'Summary' = pkg[['Title']], + desc + ) + return(desc) + } + ) + # Pad missing metadata with NAs + manifest.names <- unique(x = unlist( + x = lapply(X = avail.pkgs, FUN = names), + use.names = FALSE + )) + for (pkg in names(x = avail.pkgs)) { + for (col in manifest.names) { + avail.pkgs[[pkg]][[col]] <- avail.pkgs[[pkg]][[col]] %||% NA + } } + # Convert each entry to a dataframe and bind everything together + avail.pkgs <- lapply(X = avail.pkgs, FUN = as.data.frame, stringsAsFactors = FALSE) + avail.pkgs <- do.call(what = 'rbind', args = avail.pkgs) + # Coerce version information to package_version + avail.pkgs$Version <- package_version(x = avail.pkgs$Version) + } else if (pkg.env$source == 'appdir') { + # Read cached manifest + pkg.env$extdata.warn <- FALSE + packageStartupMessage( + "Using cached data manifest, last updated at ", + file.info(cache.manifest)$ctime + ) + avail.pkgs <- readRDS(file = cache.manifest) + } else if (pkg.env$source == 'extdata') { + # Read SeuratData-bundled manifest + if (!pkg.env$extdata.warn) { + warning( + "Using SeuratData-bundled data manifest. ", + "This may be out-of-date and not contain the latest datasets. ", + "This warning will be shown once per session or until we can read from a remote or cached data manifest", + call. = FALSE, + immediate. = TRUE + ) + } + pkg.env$extdata.warn <- TRUE + avail.pkgs <- readRDS(file = system.file( + 'extdata/manifest.Rds', + package = 'SeuratData', + mustWork = TRUE + )) } - avail.pkgs <- lapply(X = avail.pkgs, FUN = as.data.frame, stringsAsFactors = FALSE) - avail.pkgs <- do.call(what = 'rbind', args = avail.pkgs) - avail.pkgs$Version <- package_version(x = avail.pkgs$Version) + # Get dataset installation status avail.pkgs$Installed <- vapply( X = rownames(x = avail.pkgs), FUN = requireNamespace, FUN.VALUE = logical(length = 1L), - quietly = TRUE, + quietly = TRUE ) avail.pkgs$InstalledVersion <- sapply( X = rownames(x = avail.pkgs), @@ -255,14 +442,33 @@ UpdateManifest <- function() { return(as.character(x = pkg.version)) } ) + # Coerce version information to package_version + # Allow NAs to become effectively NA_pacakge_version_ avail.pkgs$InstalledVersion <- package_version( x = avail.pkgs$InstalledVersion, strict = FALSE ) # TODO: remove these when we allow loading of processed datasets - ds.index <- which(x = colnames(x = avail.pkgs) %in% c('default.dataset', 'other.datasets')) - avail.pkgs <- avail.pkgs[, -ds.index] + cols.remove <- c('default.dataset', 'other.datasets') + if (any(cols.remove %in% colnames(x = avail.pkgs))) { + ds.index <- which(x = colnames(x = avail.pkgs) %in% cols.remove) + avail.pkgs <- avail.pkgs[, -ds.index] + } pkg.env$manifest <- avail.pkgs + # Cache the manifest + if (getOption(x = 'SeuratData.manifest.cache', default = FALSE)) { + if (!dir.exists(paths = dirname(path = cache.manifest))) { + dir.create(path = dirname(path = cache.manifest), recursive = TRUE) + } + cached <- if (file.exists(cache.manifest)) { + readRDS(file = cache.manifest) + } else { + NULL + } + if (!isTRUE(x = all.equal(target = pkg.env$manifest, current = cached))) { + saveRDS(object = pkg.env$manifest, file = cache.manifest) + } + } invisible(x = NULL) } diff --git a/exec/update_packages.R b/exec/update_packages.R new file mode 100644 index 0000000..aa1d362 --- /dev/null +++ b/exec/update_packages.R @@ -0,0 +1,58 @@ +#!/usr/bin/env Rscript + +# Check required packages +if (!requireNamespace('tools', quietly = TRUE)) { + stop("Cannot find the tools package, exiting", call. = FALSE) +} + +# Get the script name +ProgramName <- function() { + prefix <- '--file=' + name <- sub( + pattern = prefix, + replacement = '', + x = grep( + pattern = paste0(prefix, "(.+)"), + x = commandArgs(), + value = TRUE + ) + ) + return(name) +} + +# Usage message +usage <- paste("Usage:", ProgramName(), "/path/to/repo") + +# Parse and check arguments +args <- commandArgs(trailingOnly = TRUE) +if (length(x = args) != 1 || tolower(x = args) %in% c('-h', '--help')) { + cat(usage, '\n', file = stderr()) + quit(status = 1) +} +if (!dir.exists(paths = args)) { + stop("Cannot find repo directory ", args, call. = FALSE) +} + +# Get the contrib directories +dirs <- list.dirs(path = args) +dirs <- grep(pattern = 'contrib', x = dirs, value = TRUE) +if (length(x = dirs) < 1) { + stop("Invalid repository structure in ", args, call. = FALSE) +} + +# Write the PACKAGES manifests +for (d in dirs) { + type <- if (grepl(pattern = 'macosx', x = d)) { + 'mac.binary' + } else if (grepl(pattern = 'windows', x = d)) { + 'win.binary' + } else { + 'source' + } + tools::write_PACKAGES( + dir = d, + fields = c('Description', 'Title', 'Date'), + type = type, + verbose = TRUE + ) +} diff --git a/inst/extdata/manifest.Rds b/inst/extdata/manifest.Rds new file mode 100644 index 0000000..5dda2b0 Binary files /dev/null and b/inst/extdata/manifest.Rds differ diff --git a/man/AppData.Rd b/man/AppData.Rd new file mode 100644 index 0000000..eefc803 --- /dev/null +++ b/man/AppData.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/zzz.R +\name{AppData} +\alias{AppData} +\title{Get an application data directory} +\usage{ +AppData(pkgname = "SeuratData", author = pkgname) +} +\arguments{ +\item{pkgname}{Name of package} + +\item{author}{Author name for application} +} +\value{ +A character vector with path to the application data dir +} +\description{ +Get an application data directory +} +\seealso{ +\code{\link[rappdirs]{user_data_dir}} +} +\keyword{internal} diff --git a/man/AvailableData.Rd b/man/AvailableData.Rd index 2526a4d..ac06af4 100644 --- a/man/AvailableData.Rd +++ b/man/AvailableData.Rd @@ -19,7 +19,12 @@ Other columns are extra metadata, and may change as new datasets are made availa } \description{ Get list of available datasets +} +\examples{ +AvailableData() + } \seealso{ -\code{\link{InstallData}} \code{\link{InstalledData}} \code{\link{RemoveData}} \code{\link{UpdateData}} +\code{\link{InstallData}} \code{\link{InstalledData}} +\code{\link{RemoveData}} \code{\link{UpdateData}} } diff --git a/man/Enumerate.Rd b/man/Enumerate.Rd new file mode 100644 index 0000000..2e95974 --- /dev/null +++ b/man/Enumerate.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/zzz.R +\name{Enumerate} +\alias{Enumerate} +\title{Enumerate a list or vector} +\usage{ +Enumerate(x) +} +\arguments{ +\item{x}{A list or a vector} +} +\value{ +A list of length \code{x} with the following named values: +\describe{ + \item{\code{name}}{The name of \code{x} at a given index} + \item{\code{value}}{The value of \code{x} at the corresponding index} +} +} +\description{ +Enumerate a list or vector +} +\note{ +For any given index \code{i} in \code{x}, all attempts to use the name +of the value of \code{x} at \code{i} will be made. If there is no name +(eg. \code{nchar(x = names(x = x)[i]) == 0}), the index \code{i} will be used +in its stead +} +\keyword{internal} diff --git a/man/InstallData.Rd b/man/InstallData.Rd index 5018550..cf79746 100644 --- a/man/InstallData.Rd +++ b/man/InstallData.Rd @@ -18,7 +18,14 @@ Invisible \code{NULL} } \description{ Install a dataset +} +\examples{ +\dontrun{ +InstallData('pbmc3k') +} + } \seealso{ -\code{\link{AvailableData}} \code{\link{InstalledData}} \code{\link{RemoveData}} \code{\link{UpdateData}} +\code{\link{AvailableData}} \code{\link{InstalledData}} +\code{\link{RemoveData}} \code{\link{UpdateData}} } diff --git a/man/InstalledData.Rd b/man/InstalledData.Rd index 74852ce..24d6f89 100644 --- a/man/InstalledData.Rd +++ b/man/InstalledData.Rd @@ -19,7 +19,12 @@ Other columns are extra metadata, and may change as new datasets are made availa } \description{ Get a list of installed datasets +} +\examples{ +InstalledData() + } \seealso{ -\code{\link{AvailableData}} \code{\link{InstallData}} \code{\link{RemoveData}} \code{\link{UpdateData}} +\code{\link{AvailableData}} \code{\link{InstallData}} +\code{\link{RemoveData}} \code{\link{UpdateData}} } diff --git a/man/IsMatrixEmpty.Rd b/man/IsMatrixEmpty.Rd new file mode 100644 index 0000000..acd15c3 --- /dev/null +++ b/man/IsMatrixEmpty.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/zzz.R +\name{IsMatrixEmpty} +\alias{IsMatrixEmpty} +\title{Check to see if a matrix is empty} +\usage{ +IsMatrixEmpty(x) +} +\arguments{ +\item{x}{A matrix} +} +\value{ +\code{TRUE} if the matrix is empty otherwise \code{FALSE} +} +\description{ +Deterime if a matrix is empty or not +} +\details{ +A matrix is considered empty if it satisfies one of the following +conditions: +\itemize{ + \item The dimensions of the matrix are 0-by-0 (\code{all(dim(x) == 0)}) + \item The dimensions of the matrix are 1-by-1 (\code{all(dim(x) == 1)}) and + the sole value is a \code{NA} +} +These two situations correspond to matrices generated with either +\code{new('matrix')} or \code{matrix()} +} +\examples{ +\dontrun{ +IsMatrixEmpty(new('matrix')) +IsMatrixEmpty(matrix()) +IsMatrixEmpty(matrix(1:9, nrow = 3)) +} + +} +\keyword{internal} diff --git a/man/LoadData.Rd b/man/LoadData.Rd new file mode 100644 index 0000000..e3ca9a5 --- /dev/null +++ b/man/LoadData.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/seurat_data.R +\name{LoadData} +\alias{LoadData} +\title{Modularly load a dataset} +\usage{ +LoadData(ds, type = c("info", "raw", "processed"), assays = NULL, + reductions = NULL, graphs = NULL, verbose = TRUE) +} +\arguments{ +\item{ds}{Optional name of dataset to load} + +\item{type}{How to load the \code{Seurat} object; choose from +\describe{ + \item{info}{Information about the object and what's stored in it} + \item{raw}{The raw form of the dataset, no other options are evaluated} + \item{processed}{The proccessed data, modular loading avaible by setting other parameters} +}} +} +\description{ +Modularly load a dataset +} +\seealso{ +\code{\link[utils]{data}} +} diff --git a/man/MakeSpace.Rd b/man/MakeSpace.Rd new file mode 100644 index 0000000..0f3a6eb --- /dev/null +++ b/man/MakeSpace.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/zzz.R +\name{MakeSpace} +\alias{MakeSpace} +\title{Make a space} +\usage{ +MakeSpace(n) +} +\arguments{ +\item{n}{Length space should be} +} +\value{ +A space (' ') of length \code{n} +} +\description{ +Make a space +} +\examples{ +\dontrun{ +MakeSpace(10) +} + +} +\keyword{internal} diff --git a/man/NameToPackage.Rd b/man/NameToPackage.Rd index 92a3d14..af9d743 100644 --- a/man/NameToPackage.Rd +++ b/man/NameToPackage.Rd @@ -14,5 +14,13 @@ A vector of package names based on dataset names } \description{ Find dataset packages based on name +} +\examples{ +\dontrun{ +NameToPackage('cbmc') +NameToPackage('pbmc3k.SeuratData') +NameToPackage('notadataset') +} + } \keyword{internal} diff --git a/man/RemoveData.Rd b/man/RemoveData.Rd index 2f5e21e..57433e5 100644 --- a/man/RemoveData.Rd +++ b/man/RemoveData.Rd @@ -15,7 +15,14 @@ RemoveData(ds, lib) } \description{ Remove a dataset +} +\examples{ +\dontrun{ +RemoveData('pbmc3k') +} + } \seealso{ -\code{\link{AvailableData}} \code{\link{InstallData}} \code{\link{InstalledData}} \code{\link{UpdateData}} +\code{\link{AvailableData}} \code{\link{InstallData}} +\code{\link{InstalledData}} \code{\link{UpdateData}} } diff --git a/man/SeuratData-package.Rd b/man/SeuratData-package.Rd index 9036e29..18498c2 100644 --- a/man/SeuratData-package.Rd +++ b/man/SeuratData-package.Rd @@ -14,11 +14,19 @@ Single cell RNA sequencing datasets can be large, consisting of matrices \section{Package options}{ -SeuratData uses the following [options()] to configure behaviour: +SeuratData uses the following options to control behaviour, users can configure +these with \code{\link[base]{options}}: \itemize{ \item `SeuratData.repo.use`: Set the location where the SeuratData datasets are stored. Users generally should not modify. + \item `SeuratData.manifest.cache`: Cache the data manifest whenever we talk + to the data repository; note, setting to \code{FALSE} will simply prevent + SeuratData from caching the manifest, not from reading a previously cached + manifest + \item `SeuratData.roaming`: For Windows users, use a roaming profile directory + for domain users. See \url{https://en.wikipedia.org/wiki/Roaming_user_profile} + for a brief overview and Microsoft's documentation for greater detail } } diff --git a/man/UpdateData.Rd b/man/UpdateData.Rd index ccdf2d2..f389c41 100644 --- a/man/UpdateData.Rd +++ b/man/UpdateData.Rd @@ -25,7 +25,14 @@ Invisible \code{NULL} } \description{ Update datasets +} +\examples{ +\dontrun{ +UpdateData(ask = FALSE) +} + } \seealso{ -\code{\link{AvailableData}} \code{\link{InstallData}} \code{\link{InstalledData}} \code{\link{RemoveData}} +\code{\link{AvailableData}} \code{\link{InstallData}} +\code{\link{InstalledData}} \code{\link{RemoveData}} } diff --git a/man/set-if-null.Rd b/man/set-if-null.Rd index 4db00db..0de9104 100644 --- a/man/set-if-null.Rd +++ b/man/set-if-null.Rd @@ -17,6 +17,13 @@ rhs if lhs is null, else lhs } \description{ Set a default value if an object is null +} +\examples{ +\dontrun{ +4 \%||\% 5 +NULL \%|| 5 +} + } \references{ \url{https://adv-r.hadley.nz/functions.html#missing-arguments}