| Title: | Fast, Simple API Tools for Retrieving Data from 'DeltaBreed' |
|---|---|
| Description: | Simplified data retrieval from the 'DeltaBreed' breeding data management platform (<https://sandbox.breedinginsight.net/>) via the 'BrAPI' open-source breeding data API (<https://brapi.org/specification>). Each of the four main data types stored in 'DeltaBreed' (germplasm, trait variables, experiments/environments, and observations) are handled by a get_datatype() function that constructs and executes the request, handles paginated responses, and parses the retrieved data. Responses are reformatted into a consistent, R-friendly data frame format that resembles how the data appears on the 'DeltaBreed' web interface as closely as possible. |
| Authors: | Tyr Wiesner-Hanks [aut, cre] (ORCID: <https://orcid.org/0000-0002-3280-5749>) |
| Maintainer: | Tyr Wiesner-Hanks <[email protected]> |
| License: | Apache License 2.0 |
| Version: | 1.0.4 |
| Built: | 2026-09-29 16:44:29 UTC |
| Source: | https://github.com/breeding-insight/deltabreedquery |
Checks if the user has credentials currently stored and validates them by performing a test call to the BrAPI endpoint. Also prints the remaining time until the access token expires, if applicable.
check_auth()check_auth()
No return value, called for side effects (printing status)
check_auth() login_deltabreed("example", verbose = FALSE) check_auth()check_auth() login_deltabreed("example", verbose = FALSE) check_auth()
This function retrieves a foo filtered list of observation data
using one or more filter values provided by the user, packaging the
response into a data frame of the same format as get_observations().
This function is best used by calling get_experiments() first, in order
to see what experiments are actually present in the target DeltaBreed
instance.
filter_observations( year = NA, location = NA, exp_name = NA, env_name = NA, exp_type = NA, page_size = 10000, drop_empty_columns = FALSE, include_dbids = FALSE, case_correct = TRUE, verbose = TRUE )filter_observations( year = NA, location = NA, exp_name = NA, env_name = NA, exp_type = NA, page_size = 10000, drop_empty_columns = FALSE, include_dbids = FALSE, case_correct = TRUE, verbose = TRUE )
year |
A year or vector of years. |
location |
A location name or vector of locations. |
exp_name |
An experiment name or vector of names. |
env_name |
An environment name or vector of names. |
exp_type |
An experiment type or vector of types. |
page_size |
Page size to use for the response. Larger page sizes may decrease total retrieval time. |
drop_empty_columns |
If |
include_dbids |
If |
case_correct |
If |
verbose |
If |
A data frame of observations using the supplied filters.
login_deltabreed("example", verbose = FALSE) # the available filters (and values to filter on) correspond to columns of get_experiments() get_experiments() all_obs <- get_observations(verbose = FALSE) manitoba <- filter_observations(location = "Manitoba") table(all_obs$Location) table(manitoba$Location) # all filters can take vectors as arguments almtis <- filter_observations(location = c("Alma", "Tisdale")) table(almtis$Year, almtis$Location) # filters can be combined as needed ayt_mb <- filter_observations(exp_type = "AYT", location = "Manitoba") table(ayt_mb$ExpName, ayt_mb$EnvName)login_deltabreed("example", verbose = FALSE) # the available filters (and values to filter on) correspond to columns of get_experiments() get_experiments() all_obs <- get_observations(verbose = FALSE) manitoba <- filter_observations(location = "Manitoba") table(all_obs$Location) table(manitoba$Location) # all filters can take vectors as arguments almtis <- filter_observations(location = c("Alma", "Tisdale")) table(almtis$Year, almtis$Location) # filters can be combined as needed ayt_mb <- filter_observations(exp_type = "AYT", location = "Manitoba") table(ayt_mb$ExpName, ayt_mb$EnvName)
Retrieves a summary of all experiments and environments in a given DeltaBreed program. This may include experiments for which no observations have been recorded yet.
get_experiments(verbose = TRUE, include_dbids = FALSE)get_experiments(verbose = TRUE, include_dbids = FALSE)
verbose |
If |
include_dbids |
If |
Data frame of experiment/environment metadata.
login_deltabreed("example", verbose = FALSE) expt <- get_experiments() exptlogin_deltabreed("example", verbose = FALSE) expt <- get_experiments() expt
Retrieves all germplasm data from the current DeltaBreed instance, reformatting it to match DeltaBreed layout.
get_germplasm(page_size = 10000)get_germplasm(page_size = 10000)
page_size |
Page size to use for the response. Larger page sizes may decrease total retrieval time. |
Data frame of germplasm/accession/entry information.
login_deltabreed("example", verbose = FALSE) germplasm <- get_germplasm() head(germplasm)login_deltabreed("example", verbose = FALSE) germplasm <- get_germplasm() head(germplasm)
Retrieves all observation data from a DeltaBreed instance via BrAPI call. This includes observation units with no observations. converting it into a data frame that mimics the appearance of the data tables on the Experiments & Observations tab of DeltaBreed.
get_observations( page_size = 10000, drop_empty_columns = FALSE, include_dbids = FALSE, case_correct = TRUE, verbose = TRUE )get_observations( page_size = 10000, drop_empty_columns = FALSE, include_dbids = FALSE, case_correct = TRUE, verbose = TRUE )
page_size |
Page size to use for the response. Larger page sizes may decrease total retrieval time. |
drop_empty_columns |
If |
include_dbids |
If |
case_correct |
If |
verbose |
If |
A data frame of all observation units and any observations (phenotypes).
login_deltabreed("example", verbose = FALSE) obs <- get_observations() # phenotype columns will be typed according to the observation variables (trait definitions) str(obs[,16:20]) get_variables()login_deltabreed("example", verbose = FALSE) obs <- get_observations() # phenotype columns will be typed according to the observation variables (trait definitions) str(obs[,16:20]) get_variables()
Retrieves trait data from a DeltaBreed program via BrAPI, converting it into a data frame that mimics the appearance of the Ontology table in DeltaBreed itself.
get_variables(verbose = TRUE, include_archived = FALSE)get_variables(verbose = TRUE, include_archived = FALSE)
verbose |
If |
include_archived |
If |
Data frame of trait definitions drawn from BrAPI /variables endpoint.
login_deltabreed("example", verbose = FALSE) vars <- get_variables() varslogin_deltabreed("example", verbose = FALSE) vars <- get_variables() vars
This function stores your authentication credentials for a target DeltaBreed instance. To log in, you will require the BrAPI Base URL and a valid authentication token, both of which can be found on the 'BrAPI' tab of DeltaBreed.
The URL and token can be given as arguments or supplied to function prompts. The function performs some basic checks, including verifying that the user has internet access and making some test calls to the BrAPI server.
login_deltabreed(base_url = NULL, access_token = NULL, verbose = TRUE)login_deltabreed(base_url = NULL, access_token = NULL, verbose = TRUE)
base_url |
The BrAPI Base URL, found on the BrAPI tab of DeltaBreed in the BrAPI Information pane. |
access_token |
A valid Access Token, retrieved from the DeltaBreed user interface. |
verbose |
If |
Access tokens are valid for 24 hours after generation. To check your
authorization credentials at any time, use the check_auth() function.
No return value, called for side effects (storing credentials)
## Not run: # function can be run with no arguments to bring up a prompt to enter the URL/token login_deltabreed() # since your program's URL will remain static, you can supply it as an argument, e.g.: login_deltabreed("https://app.breedinginsight.net/v1/programs/f152169d-049f-4a7c-b5d8-c725b14e66f0") ## End(Not run)## Not run: # function can be run with no arguments to bring up a prompt to enter the URL/token login_deltabreed() # since your program's URL will remain static, you can supply it as an argument, e.g.: login_deltabreed("https://app.breedinginsight.net/v1/programs/f152169d-049f-4a7c-b5d8-c725b14e66f0") ## End(Not run)
Removes stored credentials (URL and access token) from the
package environment. The access token will remain valid for as long as the
DeltaBreed instance specifies, but in order to retrieve data the URL/token
will need to be-entered with login_deltabreed().
logout_deltabreed()logout_deltabreed()
No return value, called for side effects (clearing credentials)