1616# '
1717# ' @export
1818# '
19- # ' @seealso \code{\link{InstallData}} \code{\link{InstalledData}} \code{\link{RemoveData}} \code{\link{UpdateData}}
19+ # ' @seealso \code{\link{InstallData}} \code{\link{InstalledData}}
20+ # ' \code{\link{RemoveData}} \code{\link{UpdateData}}
21+ # '
22+ # ' @examples
23+ # ' AvailableData()
2024# '
2125AvailableData <- function () {
2226 UpdateManifest()
@@ -35,18 +39,30 @@ AvailableData <- function() {
3539# '
3640# ' @export
3741# '
38- # ' @seealso \code{\link{AvailableData}} \code{\link{InstalledData}} \code{\link{RemoveData}} \code{\link{UpdateData}}
42+ # ' @seealso \code{\link{AvailableData}} \code{\link{InstalledData}}
43+ # ' \code{\link{RemoveData}} \code{\link{UpdateData}}
44+ # '
45+ # ' @examples
46+ # ' \dontrun{
47+ # ' InstallData('pbmc3k')
48+ # ' }
3949# '
4050InstallData <- function (ds , force.reinstall = FALSE , ... ) {
4151 UpdateManifest()
52+ if (pkg.env $ source != ' remote' ) {
53+ stop(
54+ " No access to remote SeuratData repository, unable to install new datasets" ,
55+ call. = FALSE
56+ )
57+ }
4258 pkgs <- NameToPackage(ds = ds )
4359 if (! force.reinstall ) {
4460 installed <- intersect(x = pkgs , y = rownames(x = InstalledData()))
4561 if (length(x = installed ) > 0 ) {
4662 warning(
4763 " The following packages are already installed and will not be reinstalled: " ,
4864 paste(
49- gsub(pattern = ' \\ .SeuratData ' , replacement = ' ' , x = installed ),
65+ gsub(pattern = pkg.key , replacement = ' ' , x = installed ),
5066 collapse = ' , '
5167 ),
5268 call. = FALSE ,
@@ -63,7 +79,12 @@ InstallData <- function(ds, force.reinstall = FALSE, ...) {
6379 for (p in pkgs2 [pkgs2 %in% search()]) {
6480 detach(name = p , unload = TRUE , character.only = TRUE )
6581 }
66- install.packages(pkgs = pkgs , repos = getOption(x = " SeuratData.repo.use" ), type = ' source' , ... )
82+ install.packages(
83+ pkgs = pkgs ,
84+ repos = getOption(x = " SeuratData.repo.use" ),
85+ type = ' source' ,
86+ ...
87+ )
6788 for (pkg in pkgs ) {
6889 attachNamespace(ns = pkg )
6990 pkg.env $ attached <- c(pkg.env $ attached , pkg )
@@ -86,13 +107,73 @@ InstallData <- function(ds, force.reinstall = FALSE, ...) {
86107# '
87108# ' @export
88109# '
89- # ' @seealso \code{\link{AvailableData}} \code{\link{InstallData}} \code{\link{RemoveData}} \code{\link{UpdateData}}
110+ # ' @seealso \code{\link{AvailableData}} \code{\link{InstallData}}
111+ # ' \code{\link{RemoveData}} \code{\link{UpdateData}}
112+ # '
113+ # ' @examples
114+ # ' InstalledData()
90115# '
91116InstalledData <- function () {
92117 dat <- AvailableData()
93118 return (dat [which(x = dat $ Installed , ), , drop = FALSE ])
94119}
95120
121+ # ' Modularly load a dataset
122+ # '
123+ # ' @inheritParams LoadH5Seurat
124+ # ' @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
133+ # '
134+ # ' @importFrom utils data
135+ # '
136+ # ' @export
137+ # '
138+ # ' @seealso \code{\link[utils]{data}}
139+ # '
140+ LoadData <- function (
141+ ds ,
142+ type = c(' info' , ' raw' , ' processed' ),
143+ assays = NULL ,
144+ reductions = NULL ,
145+ graphs = NULL ,
146+ verbose = TRUE
147+ ) {
148+ .NotYetImplemented()
149+ installed <- InstalledData()
150+ if (! NameToPackage(ds = ds ) %in% rownames(x = installed )) {
151+ stop(" Cannot find dataset " , ds , call. = FALSE )
152+ }
153+ ds <- NameToPackage(ds = ds )
154+ type <- match.arg(arg = tolower(x = type ), choices = c(' info' , ' raw' , ' processed' ))
155+ if (type == ' raw' ) {
156+ e <- new.env()
157+ ds <- gsub(pattern = ' \\ .SeuratData' , replacement = ' ' , x = ds )
158+ data(list = ds , envir = e )
159+ return (e [[ds ]])
160+ }
161+ .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+ ))
175+ }
176+
96177# ' Remove a dataset
97178# '
98179# ' @inheritParams utils::remove.packages
@@ -102,7 +183,13 @@ InstalledData <- function() {
102183# '
103184# ' @export
104185# '
105- # ' @seealso \code{\link{AvailableData}} \code{\link{InstallData}} \code{\link{InstalledData}} \code{\link{UpdateData}}
186+ # ' @seealso \code{\link{AvailableData}} \code{\link{InstallData}}
187+ # ' \code{\link{InstalledData}} \code{\link{UpdateData}}
188+ # '
189+ # ' @examples
190+ # ' \dontrun{
191+ # ' RemoveData('pbmc3k')
192+ # ' }
106193# '
107194RemoveData <- function (ds , lib ) {
108195 UpdateManifest()
@@ -125,9 +212,22 @@ RemoveData <- function(ds, lib) {
125212# '
126213# ' @export
127214# '
128- # ' @seealso \code{\link{AvailableData}} \code{\link{InstallData}} \code{\link{InstalledData}} \code{\link{RemoveData}}
215+ # ' @seealso \code{\link{AvailableData}} \code{\link{InstallData}}
216+ # ' \code{\link{InstalledData}} \code{\link{RemoveData}}
217+ # '
218+ # ' @examples
219+ # ' \dontrun{
220+ # ' UpdateData(ask = FALSE)
221+ # ' }
129222# '
130223UpdateData <- function (ask = TRUE , lib.loc = NULL ) {
224+ UpdateManifest()
225+ if (pkg.env $ source != ' remote' ) {
226+ stop(
227+ " No access to remote SeuratData repository, unable to update datasets" ,
228+ call. = FALSE
229+ )
230+ }
131231 update.packages(lib.loc = lib.loc , repos = getOption(x = " SeuratData.repo.use" ), ask = ask , type = ' source' )
132232 UpdateManifest()
133233 invisible (x = NULL )
0 commit comments