Skip to content

Commit

Permalink
Merge pull request #14 from satijalab/develop
Browse files Browse the repository at this point in the history
SeuratData v0.2.1
  • Loading branch information
mojaveazure authored Dec 10, 2019
2 parents 6bb99eb + 00aa5be commit 12c77a8
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 54 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: SeuratData
Type: Package
Title: Install and Manage Seurat Datasets
Version: 0.2.0
Date: 2019-11-15
Version: 0.2.1
Date: 2019-12-09
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')),
Expand All @@ -17,7 +17,7 @@ BugReports: https://github.com/satijalab/seurat-data/issues
License: GPL-3 | file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
RoxygenNote: 7.0.2
Depends:
R (>= 3.5.0)
Imports:
Expand Down
89 changes: 56 additions & 33 deletions R/seurat_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,19 @@ InstalledData <- function() {

#' Modularly load a dataset
#'
#' @inheritParams LoadH5Seurat
# @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
#' @param type How to load the \code{Seurat} object; choose from either
#' 'default' for the default dataset or any dataset listed in the
#' \code{other.datasets} section of the data manifest
# \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
#' @return A \code{Seurat} object with the dataset asked for
#'
#' @importFrom utils data
#'
Expand All @@ -139,39 +142,59 @@ InstalledData <- function() {
#'
LoadData <- function(
ds,
type = c('info', 'raw', 'processed'),
assays = NULL,
reductions = NULL,
graphs = NULL,
verbose = TRUE
type = 'default'
# 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') {
datasets <- c(
installed[ds, 'default.dataset', drop = TRUE],
trimws(x = unlist(x = strsplit(
x = installed[ds, 'other.datasets', drop = TRUE], split = ','
)))
)
type <- match.arg(
arg = tolower(x = type),
choices = c('raw', 'default', datasets)
)
if (type %in% c('raw', 'default')) {
type <- gsub(pattern = pkg.key, replacement = '', x = ds)
} else if (type == 'final') {
type <- paste0(gsub(pattern = pkg.key, replacement = '', x = ds), '.final')
}
if (type %in% data(package = ds)$results[, 'Item', drop = TRUE]) {
e <- new.env()
ds <- gsub(pattern = '\\.SeuratData', replacement = '', x = ds)
data(list = ds, envir = e)
return(e[[ds]])
data(list = type, package = ds, envir = e)
# ds <- gsub(pattern = '\\.SeuratData', replacement = '', x = ds)
# data(list = ds, envir = e)
return(e[[type]])
}
stop(
"Could not find dataset '",
type,
"', please check manifest and try again",
call. = FALSE
)
.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
))
# 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
Expand Down
12 changes: 6 additions & 6 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -448,12 +448,12 @@ UpdateManifest <- function() {
x = avail.pkgs$InstalledVersion,
strict = FALSE
)
# TODO: remove these when we allow loading of processed datasets
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]
}
# # TODO: remove these when we allow loading of processed datasets
# 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)) {
Expand Down
15 changes: 7 additions & 8 deletions man/LoadData.Rd

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

6 changes: 3 additions & 3 deletions man/SeuratData-package.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/UpdateData.Rd

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

0 comments on commit 12c77a8

Please sign in to comment.