avtables {AnVIL}R Documentation

Functions for convenient user interaction with AnVIL resources

Description

'avtables()' describes tables available in a workspace.

'avtable()' returns an AnVIL table.

'avtable_import()' imports a data.frame to an AnVIL table.

'avtable_delete_values()' removes rows from an AnVIL table.

‘avdata()' returns the key-value table of ’REFERENCE DATA' and 'OTHER DATA' workspace attributes.

'avbucket()' retrieves the google bucket associated with a workspace.

'avworkspace_namespace()' and 'avworkspace_name()' are utiliity functions to retrieve workspace namespace and name from environment variables or interfaces available in AnVIL. Providing arguments to these functions over-rides AnVIL-determined settings with the provided value. Revert to system settings with arguments 'NA'.

Usage

avtables(namespace = avworkspace_namespace(), name = avworkspace_name())

avtable(table, namespace = avworkspace_namespace(), name = avworkspace_name())

avtable_import(
  .data,
  entity = names(.data)[[1]],
  namespace = avworkspace_namespace(),
  name = avworkspace_name()
)

avtable_delete_values(
  table,
  values,
  namespace = avworkspace_namespace(),
  name = avworkspace_name()
)

avdata(namespace = avworkspace_namespace(), name = avworkspace_name())

avbucket(
  namespace = avworkspace_namespace(),
  name = avworkspace_name(),
  as_path = TRUE
)

avworkspace_namespace(namespace = NULL)

avworkspace_name(name = NULL)

Arguments

namespace

character(1) AnVIL workspace namespace as returned by, e.g., 'avworkspace_namespace()'

name

character(1) AnVIL workspace name as returned by, eg., 'avworkspace_name()'.

table

character(1) table name as returned by, e.g., 'avtables()'.

.data

A tibble or data.frame for import as an AnVIL table.

entity

'character(1)' column name of '.data' to be used as imported table name. When the table comes from R, this is usually a column name such as 'sample'. The data will be imported into AnVIL as a table 'sample', with the 'sample' column included with suffix '_id', e.g., 'sample_id'. A column in '.data' with suffix '_id' can also be used, e.g., 'entity = "sample_id"', creating the table 'sample' with column 'sample_id' in AnVIL. Finally, a value of 'entity' that is not a column in '.data', e.g., 'entity = "unknown"', will cause a new table with name 'entity' and entity values 'seq_len(nrow(.data))'.

values

vector of values in the entity (key) column of 'table' to be deleted. A table 'sample' has an associated entity column with suffix '_id', e.g., 'sample_id'. Rows with entity column entries matching 'values' are deleted.

as_path

logical(1) when TRUE (default) return bucket with prefix 'gs://'.

Value

'avtables()': A tibble with columns identifying the table, the number of records, and the column names.

'avtable()': a tibble of data corresponding to the AnVIL table 'table' in the specified workspace.

'avtable_import()' returns a 'character(1)' name of the imported AnVIL tibble.

'avtable_delete_values()' returns a 'tibble' representing deleted entities, invisibly.

'avdata()' returns a tibble with five columns: '"type"' represents the origin of the data from the 'REFERENCE' or 'OTHER' data menus. '"table"' is the table name in the ‘REFERENCE' menu, or ’workspace' for the table in the 'OTHER' menu, the key used to access the data element, the value label associated with the data element and the value (e.g., google bucket) of the element.

'avbucket()' returns a 'character(1)' bucket identifier, prefixed with 'gs://' if 'as_path = TRUE'.

'avworkspace_namespace()', and 'avworkspace_name()' return 'character(1)' identifiers.

Examples

if (gcloud_exists() && nzchar(avworkspace_namespace()))
    ## from within AnVIL
    avdata()

if (gcloud_exists() && nzchar(avworkspace_namespace()))
    ## From within AnVIL...
    bucket <- avbucket()                        # discover bucket

## Not run: 
path <- file.path(bucket, "mtcars.tab")
gsutil_ls(dirname(path))                    # no 'mtcars.tab'...
write.table(mtcars, gsutil_pipe(path, "w")) # write to bucket
gsutil_stat(path)                           # yep, there!
read.table(gsutil_pipe(path, "r"))          # read from bucket

## End(Not run)
avworkspace_namespace()

avworkspace_name()


[Package AnVIL version 1.0.3 Index]