Title: | iSEE extension for a landing page to a custom collection of data sets |
---|---|
Description: | This package provides an interface to any collection of data sets within a single iSEE web-application. The main functionality of this package is to define a custom landing page allowing app maintainers to list a custom collection of data sets that users can selected from and directly load objects into an iSEE web-application. |
Authors: | Kevin Rue-Albrecht [aut, cre] , Thomas Sandmann [ctb] , Federico Marini [aut] , Denali Therapeutics [fnd] |
Maintainer: | Kevin Rue-Albrecht <[email protected]> |
License: | Artistic-2.0 |
Version: | 1.5.0 |
Built: | 2024-11-29 08:14:36 UTC |
Source: | https://github.com/bioc/iSEEindex |
Generate an iSEE app that includes a landing page enabling users to choose from a custom set of data sets and initial configuration states prepared by the app maintainer.
iSEEindex( bfc, FUN.datasets, FUN.initial = NULL, default.add = TRUE, default.position = c("first", "last"), app.title = NULL, body.header = NULL, body.footer = NULL )
iSEEindex( bfc, FUN.datasets, FUN.initial = NULL, default.add = TRUE, default.position = c("first", "last"), app.title = NULL, body.header = NULL, body.footer = NULL )
bfc |
An |
FUN.datasets |
A function that returns a |
FUN.initial |
A function that returns a |
default.add |
Logical scalar indicating whether a default
initial configuration should be added as a choice in the Shiny |
default.position |
Character scalar indicating whether the default
initial configuration should be added as the |
app.title |
Character string to specify the desired title to be displayed
in the main window of the dashboard. Defaults to |
body.header |
UI element to display above the main landing page body. |
body.footer |
UI element to display below the main landing page body. |
An iSEE::iSEE()
app with a custom landing page using a
BiocFileCache()
to cache a selection of data sets.
The function passed to the argument FUN.datasets
must return a list
that
contains metadata about the available data sets.
For each data set, required metadata are:
A unique identifier for the data set.
A short human-readable title for the data set, displayed in the 'Info' panel when the data set is selected.
A Uniform Resource Identifier (URI) that indicates the location of the data file that contains the data set.
A more detailed description of the data set, displayed in the 'Info' panel when the data set is selected.
Example:
list( list( id = "dataset01", title = "Dataset 01", uri = "https://example.com/1.rds", description = "My first data set." ), list( id = "dataset02", title = "Dataset 02", uri = "https://example.com/1.rds", description = "My second data set." ) )
The individual sub-lists may also contain optional named metadata specific to
individual iSEEindexResource
classes (refer to the help page of
those classes for details).
Important: The id
value is used to identify the data set file in the
BiocFileCache.
Thus, we recommend using a dedicated BiocFileCache()
for the app, using the
BiocFileCache(cache)
argument to specify an on-disk location (directory
path) for the dedicated cache.
The function passed to the argument FUN.initial
must return a list
that
contains metadata about the available initial configurations, or NULL
in
the absence of any custom initial configuration (default settings will be
applied to all data sets.).
For each initial configuration, required metadata are:
A unique identifier for the initial configuration.
A short human-readable title for the initial configuration, representing the initial configuration in the 'Initial settings' dropdown menu.
A Uniform Resource Identifier (URI) that indicates the location of the R script that contains the initial configuration.
A more detailed description of the initial configuration, displayed in the 'Configure and launch' panel when the initial configuration is selected.
For each initial configuration, optional metadata are:
A series of data set identifiers for which the configuration should be made available. If missing, the configuration will be available for all data sets.
Example:
list( list( id = "config01", datasets = c("dataset01") title = "Configuration 01", uri = "https://example.com/1.R", description = "My first configuration." ), list( id = "config02", title = "Configuration 02", uri = "https://example.com/2.R", description = "My second configuration." ) )
The individual sub-lists may also contain additional optional named metadata
specific to individual iSEEindexResource
classes (refer to the help
page of those classes for details).
Kevin Rue-Albrecht
library("BiocFileCache") bfc <- BiocFileCache(cache = tempdir()) dataset_fun <- function() { x <- yaml::read_yaml(system.file(package = "iSEEindex", "example.yaml")) x$datasets } initial_fun <- function() { x <- yaml::read_yaml(system.file(package = "iSEEindex", "example.yaml")) x$initial } app <- iSEEindex(bfc, dataset_fun, initial_fun) if (interactive()) { shiny::runApp(app, port = 1234) } ## Alternatively, with the example based on using runr calls dataset_fun_tonsils <- function() { x <- yaml::read_yaml( system.file("tonsils_example", "tonsil_package.yml", package = "iSEEindex") ) x$datasets } initial_fun_tonsils <- function() { x <- yaml::read_yaml( system.file("tonsils_example", "tonsil_package.yml", package = "iSEEindex") ) x$initial } library("shiny") header_tonsils <- fluidRow( shinydashboard::box( width = 12, collapsible = TRUE, collapsed = TRUE, title = "How to explore the Tonsil Atlas datasets", includeMarkdown( system.file("tonsils_example", "header_tonsils.md", package = "iSEEindex") ) ) ) footer_tonsils <- fluidRow( shinydashboard::box( width = 12, includeMarkdown( system.file("tonsils_example", "footer_tonsils.md", package = "iSEEindex") ) ) ) app_tonsils <- iSEEindex(bfc, dataset_fun_tonsils, initial_fun_tonsils, default.add = TRUE, default.position = "last", app.title = "iSEE loves the Tonsil Data Atlas", body.header = header_tonsils, body.footer = footer_tonsils) if (interactive()) { shiny::runApp(app_tonsils, port = 5678) } ## This example shows that it is possible to mix different types of resources ## Some provide the path, some directly the object dataset_fun_mix <- function() { x <- yaml::read_yaml( system.file("mixed_resources.yml", package = "iSEEindex") ) x$datasets } initial_fun_mix <- function() { x <- yaml::read_yaml( system.file("mixed_resources.yml", package = "iSEEindex") ) x$initial } app_mixed <- iSEEindex(bfc, dataset_fun_mix, initial_fun_mix, default.add = TRUE, default.position = "last", app.title = "iSEE loves multiple resource types") if (interactive()) { shiny::runApp(app_mixed, port = 4242) }
library("BiocFileCache") bfc <- BiocFileCache(cache = tempdir()) dataset_fun <- function() { x <- yaml::read_yaml(system.file(package = "iSEEindex", "example.yaml")) x$datasets } initial_fun <- function() { x <- yaml::read_yaml(system.file(package = "iSEEindex", "example.yaml")) x$initial } app <- iSEEindex(bfc, dataset_fun, initial_fun) if (interactive()) { shiny::runApp(app, port = 1234) } ## Alternatively, with the example based on using runr calls dataset_fun_tonsils <- function() { x <- yaml::read_yaml( system.file("tonsils_example", "tonsil_package.yml", package = "iSEEindex") ) x$datasets } initial_fun_tonsils <- function() { x <- yaml::read_yaml( system.file("tonsils_example", "tonsil_package.yml", package = "iSEEindex") ) x$initial } library("shiny") header_tonsils <- fluidRow( shinydashboard::box( width = 12, collapsible = TRUE, collapsed = TRUE, title = "How to explore the Tonsil Atlas datasets", includeMarkdown( system.file("tonsils_example", "header_tonsils.md", package = "iSEEindex") ) ) ) footer_tonsils <- fluidRow( shinydashboard::box( width = 12, includeMarkdown( system.file("tonsils_example", "footer_tonsils.md", package = "iSEEindex") ) ) ) app_tonsils <- iSEEindex(bfc, dataset_fun_tonsils, initial_fun_tonsils, default.add = TRUE, default.position = "last", app.title = "iSEE loves the Tonsil Data Atlas", body.header = header_tonsils, body.footer = footer_tonsils) if (interactive()) { shiny::runApp(app_tonsils, port = 5678) } ## This example shows that it is possible to mix different types of resources ## Some provide the path, some directly the object dataset_fun_mix <- function() { x <- yaml::read_yaml( system.file("mixed_resources.yml", package = "iSEEindex") ) x$datasets } initial_fun_mix <- function() { x <- yaml::read_yaml( system.file("mixed_resources.yml", package = "iSEEindex") ) x$initial } app_mixed <- iSEEindex(bfc, dataset_fun_mix, initial_fun_mix, default.add = TRUE, default.position = "last", app.title = "iSEE loves multiple resource types") if (interactive()) { shiny::runApp(app_mixed, port = 4242) }
The iSEEindexHttpsResource class represents a resource accessible through an HTTPS link. A URI for this type of resource uses the prefix “https://”.
iSEEindexHttpsResource(x)
iSEEindexHttpsResource(x)
x |
List of metadata. See Details. |
Required metadata:
Character scalar. URI of the resource.
The constructor function iSEEindexHttpsResource()
returns an object
of class iSEEindexHttpsResource
.
This class inherits all slots from its parent class iSEEindexResource.
In the following code snippets, x
is an instance of a
iSEEindexHttpsResource class.
Refer to the documentation for each method for more details on the remaining
arguments.
precache(x, bfc, id, ...)
caches the resource located at
the given URI using BiocFileCache and returns the file path to the
cached file.
Kevin Rue-Albrecht
iSEEindexHttpsResource(list(uri = "https://example.com"))
iSEEindexHttpsResource(list(uri = "https://example.com"))
The iSEEindexLocalhostResource class represents a resource accessible through a local filepath. A URI for this type of resource uses the prefix “localhost://”.
iSEEindexLocalhostResource(x)
iSEEindexLocalhostResource(x)
x |
List of metadata. See Details. |
Required metadata:
Character scalar. URI of the resource.
The constructor function iSEEindexLocalhostResource()
returns an
object of object of class iSEEindexLocalhostResource
.
This class inherits all slots from its parent class iSEEindexResource.
In the following code snippets, x
is an instance of a
iSEEindexLocalhostResource class.
Refer to the documentation for each method for more details on the remaining
arguments.
precache(x, ...)
trims the localhost://
prefix, and
caches a copy of the resource located at the resulting file path using
BiocFileCache, before returning the file path to the cached file.
Absolute and relative paths are both supported.
Absolute paths require an additional /
(forward slash)
following the double forward slash //
separating the scheme component of
the URI.
For instance:
localhost://path/to/file
refers to the relative path path/to/file
(relative to the working directory when the Shiny application is launched).
localhost:///path/to/file
refers to the absolute path /path/to/file
.
Kevin Rue-Albrecht
iSEEindexLocalhostResource(list(uri = "localhost:///example/absolute/path")) iSEEindexLocalhostResource(list(uri = "localhost://example/relative/path"))
iSEEindexLocalhostResource(list(uri = "localhost:///example/absolute/path")) iSEEindexLocalhostResource(list(uri = "localhost://example/relative/path"))
The iSEEindexRcallResource class represents a resource accessible through the result of an R call. A URI for this type of resource uses the prefix “rcall://”.
iSEEindexRcallResource(x)
iSEEindexRcallResource(x)
x |
List of metadata. See Details. |
Required metadata:
Character scalar. R call which, once evaluated, produces a character scalar that is the URI of the resource.
The constructor function iSEEindexRcallResource()
returns an object
of object of class iSEEindexRcallResource
.
The URI must contain valid R code, once the prefix rcall://
is removed.
The code must return the path to an existing file on the local filesystem.
For instance:
rcall://system.file(package='iSEEindex','ReprocessedAllenData_config_01.R')
This class inherits all slots from its parent class iSEEindexResource.
In the following code snippets, x
is an instance of a
iSEEindexRcallResource class.
Refer to the documentation for each method for more details on the remaining
arguments.
precache(x, ...)
trims the rcall://
prefix,
evaluates the remainder of the URI as R code, and caches a copy of the
resource located at the resulting file path using BiocFileCache,
before returning the file path to the cached file.
Kevin Rue-Albrecht
iSEEindexRcallResource(list( uri = "rcall://system.file(package='iSEEindex','ReprocessedAllenData_config_01.R')" ))
iSEEindexRcallResource(list( uri = "rcall://system.file(package='iSEEindex','ReprocessedAllenData_config_01.R')" ))
The iSEEindexResource class is a virtual class from which classes of supported resource must be derived.
## S4 method for signature 'iSEEindexResource' show(object) ## S4 method for signature 'iSEEindexResource' precache(x, bfc, id, ...)
## S4 method for signature 'iSEEindexResource' show(object) ## S4 method for signature 'iSEEindexResource' precache(x, bfc, id, ...)
object |
An |
x |
An |
bfc |
A |
id |
A data set identifier as a character scalar. |
... |
additional arguments passed to and from other methods. |
show()
returns NULL
after displaying a summary of the object.
precache()
throws an error if no method is found for the derived class.
uri
, a character scalar specifying the URI of a resource.
In the following code snippets, x
is an instance of a
iSEEindexResource
class.
Refer to the documentation for each method for more details on the remaining
arguments.
precache(x, bfc, id, ...)
throws an error, encouraging
users to develop a method for derived classes that are not supported yet.
Kevin Rue-Albrecht
showClass("iSEEindexResource")
showClass("iSEEindexResource")
An overview of the generics for iSEEindexResources
objects.
precache(x, bfc, id, ...)
precache(x, bfc, id, ...)
x |
An |
bfc |
A |
id |
A data set identifier as a character scalar. |
... |
additional arguments passed to and from other methods. |
precache()
returns the file path to the cached copy of a resource
fetched from a given URI.
precache(x, bfc, id, ...)
retrieves and caches a resource from an URI,
caches it, and returns the path to the cached file.
Kevin Rue-Albrecht
library(BiocFileCache) bfc <- BiocFileCache(cache = tempdir()) x <- iSEEindexRcallResource(list( uri = "rcall://system.file(package='iSEEindex','ReprocessedAllenData_config_01.R')" )) precache(x, bfc, "ID0")
library(BiocFileCache) bfc <- BiocFileCache(cache = tempdir()) x <- iSEEindexRcallResource(list( uri = "rcall://system.file(package='iSEEindex','ReprocessedAllenData_config_01.R')" )) precache(x, bfc, "ID0")
The iSEEindexRunrResource class represents an SE object, obtained directly through an R call.
iSEEindexRunrResource(x)
iSEEindexRunrResource(x)
x |
List of metadata. See Details. |
A URI for this type of resource uses the prefix “runr://”.
Required metadata:
Character scalar. URI of the resource.
The constructor function iSEEindexRunrResource()
returns an object
of object of class iSEEindexRunrResource
.
In the following code snippets, x
is an instance of a
iSEEindexRunrResource class.
Refer to the documentation for each method for more details on the remaining
arguments.
precache(x, bfc, id, ...)
caches the resource located at
the given URI using BiocFileCache and returns the file path to the
cached file.
iSEEindexRunrResource(list( uri = "runr://HCATonsilData::HCATonsilData(assayType = 'RNA', cellType = 'epithelial')" ))
iSEEindexRunrResource(list( uri = "runr://HCATonsilData::HCATonsilData(assayType = 'RNA', cellType = 'epithelial')" ))
The iSEEindexS3Resource class represents a cloud storage resource accessible via the paws.storage R package. A URI for this type of resource uses the prefix “s3://”.
iSEEindexS3Resource(x)
iSEEindexS3Resource(x)
x |
List of metadata. See Details. |
Required metadata:
Character scalar. URI of the resource.
The constructor function iSEEindexS3Resource()
returns an object of
object of class iSEEindexS3Resource
.
This class inherits all slots from its parent class iSEEindexResource.
Furthermore, this class defines the additional slot(s) below:
AWS region.
In the following code snippets, x
is an instance of a
iSEEindexS3Resource class.
Refer to the documentation for each method for more details on the remaining
arguments.
precache(x, ..., temp_dir = tempdir())
trims the s3://
prefix, parses information encoded in the remainder of the URI,
downloads the resource from AWS S3 using that information,
and caches a copy of the resource located at the resulting file path using
BiocFileCache, before returning the file path to the cached file.
The URI must correspond to an existing file in an AWS S3 compatible cloud storage system.
For instance:
s3://bucket/prefix/index.rds
For details about authentication, see section “AWS Credentials” below.
Additional arguments to the precache(x, ..., temp_dir = tempdir())
:
temp_dir
Scalar character, the directory to store the downloaded file in before it is handed over to BiocFileCache. This directory will be created recursively if it doesn't already exist.
For detailed information, please consult the paws R package documentation.
Currently, you must have the AWS Command Line Interface installed to use AWS SSO with paws.storage.
A default AWS region can be set in the file ~/.aws/config
.
For instance:
[default] region=eu-west-2
Optionally, a field named region
can be added in the list of resource
metadata to set the AWS S3 region for each individual resource, e.g.
- id: ID1 title: ReprocessedAllenData uri: s3://example/ReprocessedAllenData.rds description: | Reprocessed Allen Data. region: eu-west-2
Regions set in individual resource metadata override the default AWS region
set in ~/.aws/config
(if any).
The region metadata does not need to be set for resources that should use the
default region, and resource classes that do not require region information.
If a default region is NOT set in ~/.aws/config
, then the region MUST be
set in the metadata.
Credentials for all services can be set in the AWS shared credentials file
~/.aws/credentials
.
For instance:
[default] aws_access_key_id=your AWS access key aws_secret_access_key=your AWS secret key
Thomas Sandmann, Kevin Rue-Albrecht
# Without region metadata metadata <- list(uri = "s3://example/path/to/bucket") x <- iSEEindexS3Resource(metadata) str(x) # With region metadata # NOTE: The @region slot is set to NA pending bugfix (see above). metadata <- list(uri = "s3://example/path/to/bucket", region = "eu-west-2") x <- iSEEindexS3Resource(metadata) str(x)
# Without region metadata metadata <- list(uri = "s3://example/path/to/bucket") x <- iSEEindexS3Resource(metadata) str(x) # With region metadata # NOTE: The @region slot is set to NA pending bugfix (see above). metadata <- list(uri = "s3://example/path/to/bucket", region = "eu-west-2") x <- iSEEindexS3Resource(metadata) str(x)