Package 'AnVIL'

Title: Bioconductor on the AnVIL compute environment
Description: The AnVIL is a cloud computing resource developed in part by the National Human Genome Research Institute. The AnVIL package provides programatic access to the Dockstore, Leonardo, Rawls, TDR, and Terra RESTful programming interfaces. For platform-specific user-level functionality, see either the AnVILGCP or AnVILAz package.
Authors: Marcel Ramos [aut, cre] (ORCID: <https://orcid.org/0000-0002-3242-0582>), Martin Morgan [aut] (ORCID: <https://orcid.org/0000-0002-5874-8148>), Kayla Interdonato [aut], Yubo Cheng [aut], Nitesh Turaga [aut], BJ Stubbs [ctb], Vincent Carey [ctb], Sehyun Oh [ctb], Sweta Gopaulakrishnan [ctb], Valerie Obenchain [ctb]
Maintainer: Marcel Ramos <[email protected]>
License: Artistic-2.0
Version: 1.25.1
Built: 2026-05-30 09:12:28 UTC
Source: https://github.com/Bioconductor/AnVIL

Help Index


Functions to implement AnVIL gadget interfaces

Description

Functions documented on this page are primarily intended for package developers wishing to implement gadgets (graphical interfaces) to navigating AnVIL-generated tables.

.gadget_run() presents the user with a tibble-navigating gadget, returning the value of DONE_FUN if a row of the tibble is selected, or NULL.

Usage

.gadget_run(title, tibble, DONE_FUN)

Arguments

title

character(1) (required) title to appear at the base of the gadget, e.g., "AnVIL Workspaces".

tibble

a tibble or data.frame to be displayed in the gadget.

DONE_FUN

a function of two arguments, tibble and row_selected. The tibble is the tibble provided as an argument to .gadget_run(). row_selected is the row selected in the gadget by the user. The function is only invoked when the user selects a valid row.

Value

.gadget_run() returns the result of DONE_FUN() if a row has been selected by the user, or NULL if no row is selected (the user presses Cancel, or Done prior to selecting any row).

Examples

tibble <- avworkspaces(platform = AnVILGCP::gcp())
DONE_FUN <- function(tibble, row_selected) {
    selected <- slice(tibble, row_selected)
    with(selected, paste0(namespace, "/", name))
}
.gadget_run("AnVIL Example", tibble, DONE_FUN)

Store and retrieve authentication credentials using a secure keyring

Description

anvil_set_auth_json() stores the content of an auth.json file in the system keyring. This is the recommended way to store credentials safely.

Usage

anvil_set_auth_json(service, path)

Arguments

service

character(1) The name of the service (e.g., "terra", "dockstore") for which the credentials are being set.

path

character(1) The path to the auth.json file.

Value

anvil_set_auth_json() returns NULL invisibly.

Examples

jsonlite::write_json(
   list(token = "example_token"),
   "terratcgadata-test-key.json",
)
anvil_set_auth_json(
    "terra",
    "terratcgadata-test-key.json"
)
AnVIL:::.authenticate_get_access("terra")
unlink("terratcgadata-test-key.json")

Graphical user interfaces for common AnVIL operations

Description

workspace() allows choice of workspace for subsequent use. It is the equivalent of displaying workspaces with avworkspaces(), and setting the selected workspace with avworkspace().

browse_workspace() uses browseURL() to open a browser window pointing to the Terra workspace.

table() allows choice of table in the current workspace (selected by avworkspace() or workspace()) to be returned as a tibble. It is equivalent to invoking avtables() to show available tables, and avtable() to retrieve the selected table.

workflow() allows choice of workflow for retrieval. It is the equivalent of avworkflows() for listing available workflows, and avworkflow_configuration_get() for retrieving the workflow.

Usage

avworkspace_gadget()

browse_workspace(use_avworkspace = TRUE)

avtable_gadget()

avworkflow_gadget()

Arguments

use_avworkspace

logical(1) when TRUE (default), use the selected workspace (via workspace() or avworkspace() if available. If FALSE or no workspace is currently selected, use workspace() to allow the user to select the workspace.

Value

workspace() returns the selected workspace as a character(1) using the format namespace/name, or character(0) if no workspace is selected.

browse_workspace() returns the status of a system() call to launch the browser, invisibly. The default app URL prefix (https://app.terra.bio) can be changed with the AnVIL.terra_app_url option.

table() returns a tibble representing the selected AnVIL table.

workflow() returns an avworkflow_configuration object representing the inputs and outputs of the selected workflow. This can be edited and updated as described in the "Running an AnVIL workflow within R" vigenette.

Examples

workspace()
browse_workspace(use_avworkspace = FALSE)
tbl <- table()
wkflw <- avworkflow_gadget()

RESTful service constructor

Description

RESTful service constructor

Usage

Service(
  service,
  host,
  config = httr::config(),
  authenticate = TRUE,
  api_url = character(),
  package = "AnVIL",
  schemes = "https",
  api_reference_url = api_url,
  api_reference_md5sum = character(),
  api_reference_version = character(),
  api_reference_headers = NULL,
  ...
)

Arguments

service

character(1) The Service class name, e.g., "terra".

host

character(1) host name that provides the API resource, e.g., "leonardo.dsde-prod.broadinstitute.org".

config

httr::config() curl options

authenticate

logical(1) use credentials from authentication service? See ?anvil_set_auth_json for the recommended way to securely store credentials.

api_url

optional character(1) url location of OpenAPI .json or .yaml service definition.

package

character(1) (default AnVIL) The package where 'api.json' yaml is located.

schemes

character(1) (default 'https') Specifies the transfer protocol supported by the API service.

api_reference_url

character(1) path to reference API. See Details.

api_reference_md5sum

character(1) the result of tools::md5sum() applied to the reference API.

api_reference_version

character(1) the version of the reference API. This is used to check that the version of the service matches the version of the reference API. It is usally set by the service generation function,. e.g., AnVIL::Rawls().

api_reference_headers

character() header(s) to be used (e.g., c(Authorization = paste("Bearer", token))) when retrieving the API reference for validation.

...

additional arguments passed to rapiclient::get_api()

Details

This function creates a RESTful interface to a service provided by a host, e.g., "leonardo.dsde-prod.broadinstitute.org". The function requires an OpenAPI .json or .yaml specification. The specification file is located in the source directory of a package, at ⁠<package>/inst/service/<service>/api.json⁠, or at api_url.

Authentication credentials can be stored securely in the system
keyring using `anvil_set_auth_json()`.

When provided, the api_reference_md5sum is used to check that the file described at api_reference_url has the same checksum as an author-validated version.

The service is usually a singleton, created at the package level during .onLoad().

Value

An object of class Service.

Examples

.MyService <- setClass("MyService", contains = "Service")

MyService <- function() {
    .MyService(Service("my_service", host="my.api.org"))
}

RESTful services useful for AnVIL developers

Description

RESTful services useful for AnVIL developers

Usage

empty_object

operations(x, ..., .deprecated = FALSE)

## S4 method for signature 'Service'
operations(x, ..., auto_unbox = FALSE, .deprecated = FALSE)

schemas(x)

tags(x, .tags, .deprecated = FALSE)

## S4 method for signature 'Service'
x$name

Leonardo()

Terra()

Rawls()

Dockstore()

TDR()

Arguments

x

A Service instance, usually a singleton provided by the package and documented on this page, e.g., leonardo or terra.

...

additional arguments passed to methods or, for ⁠operations,Service-method⁠, to the internal get_operation() function.

.deprecated

optional logical(1) include deprecated operations?

auto_unbox

logical(1) If FALSE (default) do not automatically 'unbox' R scalar values from JSON arrays to JSON scalers.

.tags

optional character() of tags to use to filter operations.

name

A symbol representing a defined operation, e.g., leonardo$listRuntimes().

Format

An object of class list of length 0.

Details

Note the services Terra(), Rawls(), and Leonardo() require the GCPtools package for authentication to the Google Cloud Platform. See ?GCPtools::gcloud_access_token() for details.

When using $ to select a service, some arguments appear in 'body' of the REST request. Specify these using the ⁠.__body__=⁠ argument, as illustrated for createBillingProjectFull(), below.

Value

empty_object returns a representation to be used as arguments in function calls expecting the empty json object {}.

Leonardo() creates the API of the Leonardo container deployment service at https://leonardo.dsde-prod.broadinstitute.org/api-docs.yaml. The default API url value can be changed with the AnVIL.leonardo_api_url option.

Terra() creates the API of the Terra cloud computational environment at https://api.firecloud.org/. The default API url value can be changed with the AnVIL.firecloud_api_url option.

Rawls() creates the API of the Rawls cloud computational environment at https://rawls.dsde-prod.broadinstitute.org. The default API url value can be changed with the AnVIL.rawls_api_url option.

Dockstore() represents the API of the Dockstore platform to share Docker-based tools in CWL or WDL or Nextflow at https://dockstore.org. The default API url value can be changed with the AnVIL.dockstore_api_url option.

TDR() creates the API of the Terra Data Repository to work with snapshot data in the Terra Data Repository at https://data.terra.bio. The default API url value can be changed with the AnVIL.tdr_api_url option.

Examples

empty_object


## Arguments to be used as the 'body' (`.__body__=`) of a REST query
Terra()$createBillingProjectFull       # 6 arguments...
## ... passed as `.__body__ = list(...)`
args(Terra()$createBillingProjectFull)

library(GCPtools)
if (gcloud_exists())
    Leonardo()

library(GCPtools)
if (gcloud_exists()) {
    tags(Terra())
    tags(Terra(), "Billing")
}

library(GCPtools)
if (gcloud_exists()) {
    tags(Rawls())
    tags(Rawls(), "billing")
}

Dockstore()

library(GCPtools)
if (gcloud_exists())
    TDR()

Utilities for managing library paths

Description

add_libpaths(): Add local library paths to .libPaths().

Usage

add_libpaths(paths)

Arguments

paths

character(): vector of directories to add to .libPaths(). Paths that do not exist will be created.

Value

add_libpaths(): updated .libPaths(), invisibly.

Examples

add_libpaths("/tmp/host-site-library")