@@ -120,16 +120,19 @@ InstalledData <- function() {
120120
121121# ' Modularly load a dataset
122122# '
123- # ' @inheritParams LoadH5Seurat
123+ # @inheritParams LoadH5Seurat
124124# ' @param ds Optional name of dataset to load
125- # ' @param type How to load the \code{Seurat} object; choose from
126- # ' \describe{
127- # ' \item{info}{Information about the object and what's stored in it}
128- # ' \item{raw}{The raw form of the dataset, no other options are evaluated}
129- # ' \item{processed}{The proccessed data, modular loading avaible by setting other parameters}
130- # ' }
131- # '
132- # ' @inherit LoadH5Seurat return
125+ # ' @param type How to load the \code{Seurat} object; choose from either
126+ # ' 'default' for the default dataset or any dataset listed in the
127+ # ' \code{other.datasets} section of the data manifest
128+ # \describe{
129+ # \item{info}{Information about the object and what's stored in it}
130+ # \item{raw}{The raw form of the dataset, no other options are evaluated}
131+ # \item{processed}{The proccessed data, modular loading avaible by setting other parameters}
132+ # }
133+ # '
134+ # @inherit LoadH5Seurat return
135+ # ' @return A \code{Seurat} object with the dataset asked for
133136# '
134137# ' @importFrom utils data
135138# '
@@ -139,39 +142,59 @@ InstalledData <- function() {
139142# '
140143LoadData <- function (
141144 ds ,
142- type = c( ' info ' , ' raw ' , ' processed ' ),
143- assays = NULL ,
144- reductions = NULL ,
145- graphs = NULL ,
146- verbose = TRUE
145+ type = ' default '
146+ # assays = NULL,
147+ # reductions = NULL,
148+ # graphs = NULL,
149+ # verbose = TRUE
147150) {
148- .NotYetImplemented()
149151 installed <- InstalledData()
150152 if (! NameToPackage(ds = ds ) %in% rownames(x = installed )) {
151153 stop(" Cannot find dataset " , ds , call. = FALSE )
152154 }
153155 ds <- NameToPackage(ds = ds )
154- type <- match.arg(arg = tolower(x = type ), choices = c(' info' , ' raw' , ' processed' ))
155- if (type == ' raw' ) {
156+ datasets <- c(
157+ installed [ds , ' default.dataset' , drop = TRUE ],
158+ trimws(x = unlist(x = strsplit(
159+ x = installed [ds , ' other.datasets' , drop = TRUE ], split = ' ,'
160+ )))
161+ )
162+ type <- match.arg(
163+ arg = tolower(x = type ),
164+ choices = c(' raw' , ' default' , datasets )
165+ )
166+ if (type %in% c(' raw' , ' default' )) {
167+ type <- gsub(pattern = pkg.key , replacement = ' ' , x = ds )
168+ } else if (type == ' final' ) {
169+ type <- paste0(gsub(pattern = pkg.key , replacement = ' ' , x = ds ), ' .final' )
170+ }
171+ if (type %in% data(package = ds )$ results [, ' Item' , drop = TRUE ]) {
156172 e <- new.env()
157- ds <- gsub(pattern = ' \\ .SeuratData' , replacement = ' ' , x = ds )
158- data(list = ds , envir = e )
159- return (e [[ds ]])
173+ data(list = type , package = ds , envir = e )
174+ # ds <- gsub(pattern = '\\.SeuratData', replacement = '', x = ds)
175+ # data(list = ds, envir = e)
176+ return (e [[type ]])
160177 }
178+ stop(
179+ " Could not find dataset '" ,
180+ type ,
181+ " ', please check manifest and try again" ,
182+ call. = FALSE
183+ )
161184 .NotYetImplemented()
162- type <- match.arg(arg = type , choices = c(' info' , ' processed' ))
163- return (LoadH5Seurat(
164- file = system.file(
165- file.path(' extdata' , ' processed.h5Seurat' ),
166- package = ds ,
167- mustWork = TRUE
168- ),
169- type = ifelse(test = type == ' processed' , yes = ' object' , no = type ),
170- assays = assays ,
171- reductions = reductions ,
172- graphs = graphs ,
173- verbose = verbose
174- ))
185+ # type <- match.arg(arg = type, choices = c('info', 'processed'))
186+ # return(LoadH5Seurat(
187+ # file = system.file(
188+ # file.path('extdata', 'processed.h5Seurat'),
189+ # package = ds,
190+ # mustWork = TRUE
191+ # ),
192+ # type = ifelse(test = type == 'processed', yes = 'object', no = type),
193+ # assays = assays,
194+ # reductions = reductions,
195+ # graphs = graphs,
196+ # verbose = verbose
197+ # ))
175198}
176199
177200# ' Remove a dataset
0 commit comments