Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Hoffman committed May 23, 2019
0 parents commit 919f7a1
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
^.*\.Rproj$
^\.Rproj\.user$
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
15 changes: 15 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Package: SeuratData
Type: Package
Title: What the Package Does (Title Case)
Version: 0.1.0
Author: Who wrote it
Maintainer: The package maintainer <[email protected]>
Description: More about what it does (maybe more than one line)
Use four spaces when indenting paragraphs within the Description.
License: What license is it under?
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
Collate:
'zzz.R'
'seurat_data.R'
8 changes: 8 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Generated by roxygen2: do not edit by hand

export(AvailableData)
export(InstallData)
export(InstalledData)
importFrom(utils,available.packages)
importFrom(utils,install.packages)
importFrom(utils,remove.packages)
87 changes: 87 additions & 0 deletions R/seurat_data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#' @include zzz.R
#'
NULL

#' Get list of available datasets
#'
#' @return A vector of dataset names
#'
#' @export
#'
AvailableData <- function() {
UpdateManifest()
return(manifest)
}

#' Install a dataset
#'
#' @param pkgs List of datasets to install
#' @param ... Extra parameters passed to \code{\link[utils]{install.packages}}
#'
#' @importFrom utils install.packages
#'
#' @export
#'
InstallData <- function(pkgs, ...) {
UpdateManifest()
pkgs <- pkgs[pkgs %in% manifest]
if (length(x = pkgs) < 1) {
stop("No datasets provided", call. = FALSE)
}
install.packages(
pkgs = pkgs,
repos = 'http://satijalab04.nygenome.org',
type = 'source',
...
)
for (pkg in pkgs) {
attachNamespace(ns = pkg)
attached <<- c(attached, pkg)
}
}

#' Get a list of installed datasets
#'
#' @return A vector of installed datasets
#'
#' @export
#'
InstalledData <- function() {
installed <- vector(mode = 'character')
for (pkg in manifest) {
if (requireNamespace(pkg, quietly = TRUE)) {
installed <- c(installed, pkg)
}
}
return(installed)
}

#' Remove a dataset
#'
#' @inheritDotParams utils::remove.packages
#' @param pkgs List of dataset to remove
#'
#' @importFrom utils remove.packages
#'
RemoveData <- function(pkgs, lib) {
UpdateManifest()
pkgs <- pkgs[pkgs %in% manifest]
if (length(x = pkgs) < 1) {
stop("No datasets provided", call. = FALSE)
}
remove.packages(pkgs = pkgs, lib = lib)
}

#' Update the available package manifest
#'
#' @importFrom utils available.packages
#'
UpdateManifest <- function() {
repo.use <- 'http://satijalab04.nygenome.org'
avail.pkgs <- available.packages(
contriburl = paste(repo.use, 'src/contrib', sep = '/'),
type = 'source'
)
manifest <<- rownames(x = avail.pkgs)
invisible(x = NULL)
}
21 changes: 21 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
manifest <- vector(mode = 'character')

attached <- vector(mode = 'character')

.onLoad <- function(libname, pkgname) {
UpdateManifest()
for (pkg in manifest) {
if (requireNamespace(pkg, quietly = TRUE)) {
message("Attaching ", pkg)
try(expr = attachNamespace(ns = pkg), silent = TRUE)
attached <<- c(attached, pkg)
}
}
}

.onUnload <- function(libpath) {
for (pkg in attached) {
message("Detaching ", pkg)
unloadNamespace(ns = pkg)
}
}
14 changes: 14 additions & 0 deletions man/AvailableData.Rd

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

16 changes: 16 additions & 0 deletions man/InstallData.Rd

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

14 changes: 14 additions & 0 deletions man/InstalledData.Rd

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

22 changes: 22 additions & 0 deletions man/RemoveData.Rd

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

11 changes: 11 additions & 0 deletions man/UpdateManifest.Rd

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

19 changes: 19 additions & 0 deletions seurat-data.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

StripTrailingWhitespace: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source

0 comments on commit 919f7a1

Please sign in to comment.