Package 'metabolomicsWorkbenchR'

Title: Metabolomics Workbench in R
Description: This package provides functions for interfacing with the Metabolomics Workbench RESTful API. Study, compound, protein and gene information can be searched for using the API. Methods to obtain study data in common Bioconductor formats such as SummarizedExperiment and MultiAssayExperiment are also included.
Authors: Gavin Rhys Lloyd [aut, cre], Ralf Johannes Maria Weber [aut]
Maintainer: Gavin Rhys Lloyd <[email protected]>
License: GPL-3
Version: 1.17.0
Built: 2024-11-08 06:00:52 UTC
Source: https://github.com/bioc/metabolomicsWorkbenchR

Help Index


Get slot value from mw_base objects

Description

Gets the value of a slot from mw_base objects, provided they are not listed as 'private'.

Usage

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

Arguments

x

An object derived from mw_base.

name

The name of the slot to access.

Value

The assigned to the slot.

Examples

# an object derived from mw_base object
C = context$study
# access the name slot
C$name

Check input against acceptable input pattern

Description

Checks an input_value against a regex pattern to determine if the input_value is valid. This method is used internally and not for intended for general use.

Usage

check_pattern(I, input_value, match)

## S4 method for signature 'mw_input_item'
check_pattern(I, input_value, match)

Arguments

I

An mw_input_item.

input_value

The value for the input item (character).

match

The type of match. One of "exact" or "partial".

Value

TRUE if input matches the pattern, or throws an error.

Examples

check_pattern(input_item$study_id,'ST000001','exact')

Check inputs/outputs match

Description

Checks that the provided inputs and output are compatible. This method is used internally and not for intended for general use.

Usage

check_puts(input_item, output_item)

## S4 method for signature 'mw_input_item'
check_puts(input_item, output_item)

Arguments

input_item

An mw_input_item.

output_item

An mw_output_item.

Value

TRUE if the items are compatible or throws an error if not.

Examples

check_puts(input_item$study_id,output_item$summary)

Contexts

Description

A predefined list of mw_context objects. The context have been created to mirror the metabolomics workbench API documentation contexts as closely as possible.

Usage

context

Format

An object of class list of length 7.

Examples

# list available contexts
names(context)

# get the context 'study'
context$study

Valid inputs

Description

Get a list of valid input_items for a context.

Usage

context_inputs(context)

Arguments

context

The name of a valid context (character)

Value

A list of input item names for a context

Examples

# list of input items for the "study" context
context_inputs("study")

Valid outputs

Description

Get a list of valid output_items for a context.

Usage

context_outputs(context)

Arguments

context

The name of a valid context (character)

Value

A list of output item names for a context

Examples

# list of output items for the "study" context
context_outputs("study")

Query the Metabolomics Workbench database

Description

Sends a query to the metabolomics database and returns the result. Note that while objects derived from mw_base can be used the recommended approach is to use character inputs.

Usage

do_query(context, input_item, input_value, output_item)

## S4 method for signature 'character,character,character,character'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 'mw_moverz_context,list,character,mw_output_item'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 'mw_moverz_context,list,character,character'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 'mw_moverz_context,list,character,missing'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 'mw_moverz_context,character,character,missing'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 'character,character,character,missing'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 'mw_exactmass_context,list,character,mw_output_item'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 'mw_exactmass_context,list,character,character'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 'mw_exactmass_context,list,character,missing'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 'mw_exactmass_context,character,character,missing'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 'character,character,character,missing'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 'mw_context,mw_input_item,character,mw_output_item'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 'mw_context,mw_input_item,character,mw_SE_item'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 
## 'mw_context,mw_input_item,character,mw_untarg_SE_item'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 'mw_context,mw_input_item,character,mw_DE_item'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 
## 'mw_context,mw_input_item,character,mw_untarg_DE_item'
do_query(context, input_item, input_value, output_item)

## S4 method for signature 'mw_context,mw_input_item,character,mw_MAE_item'
do_query(context, input_item, input_value, output_item)

Arguments

context

A valid context name (character)

input_item

A valid input_item name (character)

input_value

The value for the input item (character).

output_item

A valid output_item (character).

Value

A data.frame, or other output appropriate to the output_item.

Examples

# Get a summary of all studies with "diabetes" in the title

df = do_query(
  context = 'study',
  input_item = 'study_title',
  input_value = 'diabetes',
  output_item = 'summary'  
)

Valid input_value for input_item

Description

Displays a valid input_value for an input_item and returns an example that matches the required input pattern.

Usage

input_example(input_item)

Arguments

input_item

The name of a valid input_item (character)

Value

An example input value matching the pattern required for the chosen input item.

Examples

# example input_value for input item "study_id" 
input_example('study_id')

Input items

Description

A predefined list of mw_input_item objects. The items have been created to mirror the Metabolomics Workbench API documentation input items as closely as possible.

Usage

input_item

Format

An object of class list of length 41.

Examples

# list available input_items
names(input_item)

# get the input item 'study_id'
input_item$study_id

Check validity of context and inputs/outputs

Description

Compares the input and output items to the expected values for a context and returns TRUE if the inputs/puts are valid for the provided context or an error if not. This method is used internally and not for intended for general use.

Usage

is_valid(context, input_item, input_value, output_item)

## S4 method for signature 'mw_context,character,character,character'
is_valid(context, input_item, input_value, output_item)

## S4 method for signature 'mw_moverz_context,character,character,missing'
is_valid(context, input_item, input_value)

## S4 method for signature 'mw_exactmass_context,character,character,missing'
is_valid(context, input_item, input_value)

Arguments

context

An mw_context object.

input_item

An mw_input_item object, or the name of one.

input_value

The value for the input item (character).

output_item

An mw_output_item, or the name of one.

Value

TRUE or an error.

Examples

is_valid(context$study,
  input_item$study_id$name,
  'ST000001',
  output_item$summary$name
)

Output items

Description

A predefined list of mw_output_item objects. The items have been created to mirror the Metabolomics Workbench API documentation output items as closely as possible.

Usage

output_item

Format

An object of class list of length 31.

Examples

# list available output_items
names(output_item)

# get the output item 'summary'
output_item$summary