| Title: | A Tidyverse-Native Client for the 'BrAPI' v2 (Breeding API) Specification |
|---|---|
| Description: | Provides pipe-friendly, stateless read access to the Breeding API ('BrAPI') v2.1 specification, an open community standard for plant breeding data interchange maintained by the BrAPI project <https://brapi.org>. Wraps 32 of the 37 'BrAPI' v2.1 entities across all four modules, Core, Germplasm, Phenotyping, and Genotyping, covering 49 of the specification's 138 retrieval ('GET' and search) endpoints and returning tidy tibbles ready for analysis. Write and update endpoints are out of scope by design. Features include automatic pagination, async search handling, response caching, parallel batch fetching, and convenience functions for genomic selection workflows (e.g. dosage matrix extraction). Designed for plant breeders and bioinformaticians who need programmatic access to plant breeding databases that implement the 'BrAPI' v2 specification. |
| Authors: | Joash Joshua Ayo [aut, cre, cph] (ORCID: <https://orcid.org/0009-0007-1642-0172>), David Waring [rev] (David reviewed the package (v. 0.1.0) for rOpenSci, see <https://github.com/ropensci/software-review/issues/792>), Jenna Hershberger [rev] (Jenna reviewed the package (v. 0.1.0) for rOpenSci, see <https://github.com/ropensci/software-review/issues/792>) |
| Maintainer: | Joash Joshua Ayo <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-09-24 15:22:12 UTC |
| Source: | https://github.com/ropensci/brapiR2 |
Retrieves genotype calls from the /allelematrix endpoint and returns a
tidy tibble with one row per (variant, callSet) combination. The
/allelematrix response has a unique structure (2-D pagination, no
result$data envelope) so it cannot use the generic brapi_get().
brapi_allele_matrix(con, variantSetDbId = NULL, ...)brapi_allele_matrix(con, variantSetDbId = NULL, ...)
con |
A |
variantSetDbId |
Character or NULL. Filter by variant set. |
... |
Additional query parameters
(e.g. |
A tibble with columns variantDbId, callSetDbId, genotype.
GET /allelematrix - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
dimensionVariantPage, dimensionVariantPageSize,
dimensionCallSetPage, dimensionCallSetPageSize.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_allele_matrix(con, variantSetDbId = "variantset1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_allele_matrix(con, variantSetDbId = "variantset1") }
Removes all cached responses from the cache directory.
brapi_cache_clear(con)brapi_cache_clear(con)
con |
A |
Invisibly returns con.
con <- brapi_connection("https://test-server.brapi.org") con <- brapi_cache_enable(con, dir = tempdir()) brapi_cache_clear(con)con <- brapi_connection("https://test-server.brapi.org") con <- brapi_cache_enable(con, dir = tempdir()) brapi_cache_clear(con)
Returns a new connection object with caching enabled. Cached responses are stored as JSON files in the specified directory, keyed by URL and query parameters.
brapi_cache_enable(con, dir = NULL, ttl = 3600)brapi_cache_enable(con, dir = NULL, ttl = 3600)
con |
A |
dir |
Character. Directory to store cached responses.
Defaults to a user cache directory via |
ttl |
Numeric. Time-to-live for cached entries in seconds. Default 3600 (1 hour). |
A new brapi_con object with caching configured.
con <- brapi_connection("https://test-server.brapi.org") con <- brapi_cache_enable(con, dir = tempdir(), ttl = 7200) concon <- brapi_connection("https://test-server.brapi.org") con <- brapi_cache_enable(con, dir = tempdir(), ttl = 7200) con
List Call Sets (Samples with Genotype Data)
brapi_call_sets(con, ...)brapi_call_sets(con, ...)
con |
A |
... |
Additional query parameters. |
A tibble with one row per call set.
GET /callsets - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
callSetDbId, callSetName, variantSetDbId, sampleDbId.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_call_sets(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_call_sets(con) }
List Genotype Calls
brapi_calls(con, variantSetDbId = NULL, ...)brapi_calls(con, variantSetDbId = NULL, ...)
con |
A |
variantSetDbId |
Character or NULL. Filter by variant set. |
... |
Additional query parameters. |
A tibble with one row per genotype call.
GET /calls - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
callSetDbId, variantDbId, variantSetDbId, expandHomozygotes,
unknownString, sepPhased, sepUnphased.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_calls(con, variantSetDbId = "variantset1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_calls(con, variantSetDbId = "variantset1") }
Creates a connection object that holds server URL, authentication token,
and configuration. This object is passed as the first argument to all
brapiR2 functions. No global state is used.
brapi_connection( url, token = NULL, version = "v2", path = "brapi", user_agent = NULL, page_size = 1000L, timeout = 120 )brapi_connection( url, token = NULL, version = "v2", path = "brapi", user_agent = NULL, page_size = 1000L, timeout = 120 )
url |
Character. Base URL of the BrAPI server
(e.g. |
token |
Character or NULL. An existing Bearer token for authentication.
If NULL, you can authenticate later with |
version |
Character. BrAPI version path segment. Default |
path |
Character. URL path segment before the version, for servers
that do not serve BrAPI at |
user_agent |
Character or NULL. Overrides the user agent brapiR2 sends with each request. The default identifies the package, its version, and the httr2 and R versions in use. |
page_size |
Integer. Number of records per page for paginated requests. Default 1000. |
timeout |
Numeric. Request timeout in seconds. Default 120. |
An S3 object of class "brapi_con" (a named list).
# Connect to the public BrAPI test server (no auth needed) con <- brapi_connection("https://test-server.brapi.org") con # Connect with an existing token con <- brapi_connection("https://my-breedbase.org", token = "my_token_here") # Connect to a server that serves BrAPI under a different path con <- brapi_connection("https://npgsweb.ars-grin.gov", path = "gringlobal/brapi")# Connect to the public BrAPI test server (no auth needed) con <- brapi_connection("https://test-server.brapi.org") con # Connect with an existing token con <- brapi_connection("https://my-breedbase.org", token = "my_token_here") # Connect to a server that serves BrAPI under a different path con <- brapi_connection("https://npgsweb.ars-grin.gov", path = "gringlobal/brapi")
List Crosses
brapi_crosses(con, ...)brapi_crosses(con, ...)
con |
A |
... |
Additional query parameters. |
A tibble with one row per cross.
GET /crosses - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
crossingProjectDbId, crossingProjectName, crossDbId, crossName.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_crosses(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_crosses(con) }
List Crossing Projects
brapi_crossing_projects(con, ...)brapi_crossing_projects(con, ...)
con |
A |
... |
Additional query parameters. |
A tibble with one row per crossing project.
GET /crossingprojects - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
crossingProjectDbId, crossingProjectName,
includePotentialParents.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_crossing_projects(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_crossing_projects(con) }
Queries the /serverinfo endpoint to list which BrAPI calls the
server supports, along with their HTTP methods and versions.
brapi_endpoints(con)brapi_endpoints(con)
con |
A |
A tibble with columns for endpoint service, method(s), and version(s).
GET /serverinfo - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
contentType, dataType.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_endpoints(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_endpoints(con) }
List Events
brapi_events(con, studyDbId = NULL, ...)brapi_events(con, studyDbId = NULL, ...)
con |
A |
studyDbId |
Character or NULL. Filter by study. |
... |
Additional query parameters. |
A tibble with one row per event.
GET /events - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
observationUnitDbId, eventDbId, eventType, dateRangeStart,
dateRangeEnd.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_events(con, studyDbId = "study1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_events(con, studyDbId = "study1") }
Fetches data from multiple BrAPI endpoints or IDs in parallel using
the furrr package. Useful for retrieving data across many studies,
trials, or germplasm records simultaneously.
brapi_fetch_parallel(con, .fn, ids, .workers = NULL, ...)brapi_fetch_parallel(con, .fn, ids, .workers = NULL, ...)
con |
A |
.fn |
A brapiR2 function to call for each item
(e.g. |
ids |
Character vector. A set of IDs to iterate over. |
.workers |
Deprecated. No longer used - the parallel backend is now
the caller's choice, set via |
... |
Additional arguments passed to |
This function uses whatever future plan is already active when it is
called, and does not set or restore one itself. If you have not called
future::plan(), furrr::future_map_dfr() falls back to
future::sequential, so nothing runs in parallel until you set a plan
yourself - call future::plan(future::multisession, workers = N) before
this function to fetch in parallel, and future::plan(future::sequential)
afterwards to shut the workers back down. Per the future package's
best-practices vignette, choosing the parallel backend is the caller's
decision: a package that sets and restores a plan on every call still
mutates session-wide state the caller did not ask it to touch, and can
silently replace a backend they configured deliberately.
A tibble with results from all IDs combined.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { study_ids <- c("study1", "study2", "study3") # Set the parallel backend yourself before calling; brapi_fetch_parallel() # uses whatever plan is active rather than setting one for you. future::plan(future::multisession, workers = 2) all_data <- brapi_fetch_parallel(con, brapi_study_data, study_ids) future::plan(future::sequential) # shut the workers back down when done }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { study_ids <- c("study1", "study2", "study3") # Set the parallel backend yourself before calling; brapi_fetch_parallel() # uses whatever plan is active rather than setting one for you. future::plan(future::multisession, workers = 2) all_data <- brapi_fetch_parallel(con, brapi_study_data, study_ids) future::plan(future::sequential) # shut the workers back down when done }
List Germplasm
brapi_germplasm(con, ...)brapi_germplasm(con, ...)
con |
A |
... |
Additional query parameters
(e.g. |
A tibble with one row per germplasm accession.
GET /germplasm - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
accessionNumber, collection, binomialName, genus, species,
synonym, parentDbId, progenyDbId.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_germplasm(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_germplasm(con) }
List Germplasm Attributes
brapi_germplasm_attributes(con, ...)brapi_germplasm_attributes(con, ...)
con |
A |
... |
Additional query parameters. |
A tibble with one row per attribute definition.
GET /attributes - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
attributeCategory, attributeDbId, attributeName, attributePUI.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_germplasm_attributes(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_germplasm_attributes(con) }
Get a Single Germplasm by ID
brapi_germplasm_detail(con, germplasmDbId)brapi_germplasm_detail(con, germplasmDbId)
con |
A |
germplasmDbId |
Character. The unique germplasm identifier. |
A single-row tibble with germplasm details.
GET /germplasm/{germplasmDbId} - see the
v2.1 specification.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_germplasm_detail(con, "germplasm1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_germplasm_detail(con, "germplasm1") }
The /germplasm/{germplasmDbId}/pedigree endpoint this function
originally called was deprecated in BrAPI v2.1. It now queries
/pedigree?germplasmDbId= instead, which returns a richer record.
brapi_germplasm_pedigree(con, germplasmDbId)brapi_germplasm_pedigree(con, germplasmDbId)
con |
A |
germplasmDbId |
Character. The unique germplasm identifier. |
A single-row tibble of the germplasm's pedigree node, with
parents, siblings and progeny as list-columns of tidy tibbles.
See brapi_pedigree(), which this function calls.
GET /pedigree - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
accessionNumber, collection, familyCode, binomialName, genus,
species, synonym, includeParents, includeSiblings,
includeProgeny, includeFullTree, pedigreeDepth, progenyDepth.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_germplasm_pedigree(con, "germplasm1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_germplasm_pedigree(con, "germplasm1") }
Get Germplasm Progeny
brapi_germplasm_progeny(con, germplasmDbId)brapi_germplasm_progeny(con, germplasmDbId)
con |
A |
germplasmDbId |
Character. The unique germplasm identifier. |
A single-row tibble of the germplasm's pedigree node, with
progeny as a list-column of a tidy tibble of descendants. See
brapi_pedigree(), which this function calls.
GET /pedigree - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
accessionNumber, collection, familyCode, binomialName, genus,
species, synonym, includeParents, includeSiblings,
includeProgeny, includeFullTree, pedigreeDepth, progenyDepth.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_germplasm_progeny(con, "germplasm1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_germplasm_progeny(con, "germplasm1") }
The named functions in brapiR2 cover 32 of the 36 BrAPI v2.1 entities. This is the layer beneath them, for endpoints brapiR2 does not wrap, for servers with non-standard extensions, and for query parameters a named function does not expose. Pagination, caching, authentication and error reporting work exactly as they do for the named functions.
brapi_get(con, endpoint, query = list(), max_pages = Inf)brapi_get(con, endpoint, query = list(), max_pages = Inf)
con |
A |
endpoint |
Character. The endpoint path, with or without a leading
slash (for example |
query |
Named list. Query parameters to append to the URL.
|
max_pages |
Numeric. Stop after this many pages instead of
fetching all of them. |
A tibble of results, or an empty tibble if the endpoint returned no data.
The response passes through the same parser the named functions use, so a well-formed BrAPI collection returns one row per record. An endpoint returning something the parser does not recognise may come back with list-columns or a shape you need to reshape yourself. The named functions are the better choice wherever one exists.
brapi_post_search() for the POST search endpoints.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { # An endpoint brapiR2 does not wrap brapi_get(con, "/commoncropnames") # A query parameter no named function exposes brapi_get(con, "/studies", query = list(active = "true")) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { # An endpoint brapiR2 does not wrap brapi_get(con, "/commoncropnames") # A query parameter no named function exposes brapi_get(con, "/studies", query = list(active = "true")) }
Fetches genotype data from a BrAPI server and converts it into a numeric
dosage matrix (samples × markers) compatible with genomic selection
packages like rrBLUP, BGLR, and sommer.
brapi_get_dosage_matrix(con, variantSetDbId, sep = "/", unknown_string = ".")brapi_get_dosage_matrix(con, variantSetDbId, sep = "/", unknown_string = ".")
con |
A |
variantSetDbId |
Character. The variant set to retrieve. |
sep |
Character. Unphased allele separator. Default |
unknown_string |
Character. String representing missing data.
Default |
Allele dosage is computed by splitting each genotype string on sep (or
"|" for phased calls) and counting how many alleles are non-reference
(i.e. not "0"). Missing calls (unknown_string, ".", or "") become
NA.
A numeric matrix: rows = samples (callSetDbIds), columns = markers
(variantDbIds). Values are integer dosages (0, 1, 2 for diploids; 0–N
for polyploids). Missing calls are NA.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { dosage <- brapi_get_dosage_matrix(con, "variantset1") dim(dosage) # Use with rrBLUP: # library(rrBLUP) # result <- mixed.solve(y = pheno$yield, Z = dosage) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { dosage <- brapi_get_dosage_matrix(con, "variantset1") dim(dosage) # Use with rrBLUP: # library(rrBLUP) # result <- mixed.solve(y = pheno$yield, Z = dosage) }
Convenience function that retrieves marker positions on a genome map as
a tidy tibble. Positions come from the Genome Maps entity
(brapi_marker_positions() / /markerpositions), which places a
marker on a named brapi_map() - genetic (cM) or physical (bp), per
the map's type and unit - not from brapi_variants()'s
start/referenceName, which places a variant on a reference assembly
instead. A server may populate either, both, or neither; the two are
independent coordinate systems, not duplicates of each other.
brapi_get_marker_map(con, variantSetDbId = NULL, mapDbId = NULL)brapi_get_marker_map(con, variantSetDbId = NULL, mapDbId = NULL)
con |
A |
variantSetDbId |
Character or NULL. A variant set to retrieve
marker positions for. Mutually exclusive with |
mapDbId |
Character or NULL. A single genome map to retrieve all
marker positions from. Mutually exclusive with |
Supply exactly one of mapDbId (every marker placed on that one map)
or variantSetDbId (positions for every variant in that set, wherever
they have been placed). The variantSetDbId path looks variant IDs up
first via brapi_variants(), then retrieves their positions in one
call via brapi_search_marker_positions() rather than the GET
/markerpositions filter, which only accepts a single variantDbId.
If a marker is placed on more than one map, it contributes one row per placement - the result is never collapsed to one row per marker.
A tibble with columns variantDbId, variantName, mapDbId,
mapName, type, unit, linkageGroupName, and position - one
row per marker-map placement, so a marker on several maps appears
more than once. type and unit are joined in from brapi_maps()
so a caller can tell a genetic (cM) map from a physical (bp) one.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_get_marker_map(con, mapDbId = "genome_map1") brapi_get_marker_map(con, variantSetDbId = "variantset1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_get_marker_map(con, mapDbId = "genome_map1") brapi_get_marker_map(con, variantSetDbId = "variantset1") }
List Images
brapi_images(con, ...)brapi_images(con, ...)
con |
A |
... |
Additional query parameters. |
A tibble with one row per image record.
GET /images - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
imageDbId, imageName, observationUnitDbId, observationDbId,
descriptiveOntologyTerm.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_images(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_images(con) }
Unlike brapi_lists(), which returns only list metadata, this returns
a single list together with its members in the data list-column.
listType says what the members are (for example "germplasm").
brapi_list(con, listDbId)brapi_list(con, listDbId)
con |
A |
listDbId |
Character. The unique list identifier. |
A single-row tibble of list metadata, with the list's members
as a character vector in the data list-column.
GET /lists/{listDbId} - see the
v2.1 specification.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { lst <- brapi_list(con, "list1") lst$data[[1]] }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { lst <- brapi_list(con, "list1") lst$data[[1]] }
List Generic Lists
brapi_lists(con, ...)brapi_lists(con, ...)
con |
A |
... |
Additional query parameters (e.g. |
A tibble with one row per list.
GET /lists - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
listType, listName, listDbId, listSource.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_lists(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_lists(con) }
Get a Single Location by ID
brapi_location(con, locationDbId)brapi_location(con, locationDbId)
con |
A |
locationDbId |
Character. The unique location identifier. |
A single-row tibble with location metadata, including coordinates where the server provides them.
GET /locations/{locationDbId} - see the
v2.1 specification.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_location(con, "location_01") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_location(con, "location_01") }
List Locations
brapi_locations(con, ...)brapi_locations(con, ...)
con |
A |
... |
Additional query parameters (e.g. |
A tibble with one row per location.
GET /locations - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
locationType, locationDbId, locationName, parentLocationDbId,
parentLocationName.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_locations(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_locations(con) }
Authenticates using the BrAPI /token endpoint and returns an updated
connection object with the Bearer token set.
brapi_login(con, username, password)brapi_login(con, username, password)
con |
A |
username |
Character. Your username. |
password |
Character. Your password. |
A new brapi_con object with the token populated.
The "Handling Credentials Safely" section of
vignette("brapiR2") for how to keep username/password out of
your script, using .Renviron or the keyring package.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { con <- brapi_login(con, "brapi_reader", "brapi_reader") con }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { con <- brapi_login(con, "brapi_reader", "brapi_reader") con }
Performs an OAuth 2.0 authorization code flow or client credentials flow. Returns an updated connection object with the Bearer token set.
brapi_login_oauth2(con, client_id, client_secret, authorize_url, access_url)brapi_login_oauth2(con, client_id, client_secret, authorize_url, access_url)
con |
A |
client_id |
Character. OAuth client ID. |
client_secret |
Character. OAuth client secret. |
authorize_url |
Character. The authorization endpoint URL. |
access_url |
Character. The token endpoint URL. |
A new brapi_con object with the token populated.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { con <- brapi_login_oauth2( con, client_id = "brapi_client", client_secret = "brapi_secret", authorize_url = "https://test-server.brapi.org/brapi/v2/authorize", access_url = "https://test-server.brapi.org/brapi/v2/token" ) con }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { con <- brapi_login_oauth2( con, client_id = "brapi_client", client_secret = "brapi_secret", authorize_url = "https://test-server.brapi.org/brapi/v2/authorize", access_url = "https://test-server.brapi.org/brapi/v2/token" ) con }
Get a Single Genome Map by ID
brapi_map(con, mapDbId)brapi_map(con, mapDbId)
con |
A |
mapDbId |
Character. The unique genome map identifier. |
A single-row tibble with genome map details, including type
(e.g. "Genetic" or "Physical") and unit (e.g. "cM" or "bp").
GET /maps/{mapDbId} - see the
v2.1 specification.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_map(con, "genome_map1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_map(con, "genome_map1") }
A linkage group is BrAPI's generic term for a named section of a map - it may represent a chromosome, a scaffold, or a generic linkage group.
brapi_map_linkage_groups(con, mapDbId)brapi_map_linkage_groups(con, mapDbId)
con |
A |
mapDbId |
Character. The unique genome map identifier. |
A tibble with one row per linkage group on the map.
GET /maps/{mapDbId}/linkagegroups - see the
v2.1 specification.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_map_linkage_groups(con, "genome_map1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_map_linkage_groups(con, "genome_map1") }
List Genome Maps
brapi_maps(con, ...)brapi_maps(con, ...)
con |
A |
... |
Additional query parameters. |
A tibble with one row per genome map.
GET /maps - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
mapDbId, mapPUI, scientificName, type.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_maps(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_maps(con) }
Retrieves marker placements on genome maps from /markerpositions. A
position here is relative to a named brapi_map() (genetic, in cM, or
physical, in bp) - a different coordinate system from
brapi_variants()'s start/referenceName, which places a variant on
a reference assembly instead. A server may populate either, both, or
neither; one being empty does not imply the other is.
brapi_marker_positions( con, mapDbId = NULL, variantDbId = NULL, linkageGroupName = NULL, minPosition = NULL, maxPosition = NULL, ... )brapi_marker_positions( con, mapDbId = NULL, variantDbId = NULL, linkageGroupName = NULL, minPosition = NULL, maxPosition = NULL, ... )
con |
A |
mapDbId |
Character or NULL. Filter by genome map. |
variantDbId |
Character or NULL. Filter by a single marker/variant
ID. For multiple IDs at once, use
|
linkageGroupName |
Character or NULL. Filter by linkage group (e.g. chromosome) name. |
minPosition |
Integer or NULL. Minimum position, inclusive. |
maxPosition |
Integer or NULL. Maximum position, inclusive. |
... |
Additional query parameters. |
A tibble with one row per marker placement.
GET /markerpositions - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
mapDbId, linkageGroupName, variantDbId, minPosition,
maxPosition.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_marker_positions(con, mapDbId = "genome_map1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_marker_positions(con, mapDbId = "genome_map1") }
List Methods
brapi_methods(con, ...)brapi_methods(con, ...)
con |
A |
... |
Additional query parameters. |
A tibble with one row per measurement method.
GET /methods - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
methodDbId, observationVariableDbId.
brapi_ontologies() and brapi_ontology() to resolve the
ontology a method's ontologyDbId/ontologyReference points to.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_methods(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_methods(con) }
List Observation Units
brapi_observation_units(con, studyDbId = NULL, ...)brapi_observation_units(con, studyDbId = NULL, ...)
con |
A |
studyDbId |
Character or NULL. Filter by study. |
... |
Additional query parameters. |
A tibble with one row per observation unit (plot/plant/sample).
GET /observationunits - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
observationUnitDbId, observationUnitName, locationDbId,
seasonDbId, includeObservations.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_observation_units(con, studyDbId = "study1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_observation_units(con, studyDbId = "study1") }
Returns the ontology of observation variables (trait + method + scale).
brapi_observation_variables(con, ...)brapi_observation_variables(con, ...)
con |
A |
... |
Additional query parameters. |
A tibble with one row per variable definition.
GET /variables - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
observationVariableDbId, observationVariableName,
observationVariablePUI, traitClass.
brapi_ontologies() and brapi_ontology() to resolve the
ontology a variable's ontologyDbId/ontologyReference points to.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_observation_variables(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_observation_variables(con) }
List Observations
brapi_observations(con, studyDbId = NULL, ...)brapi_observations(con, studyDbId = NULL, ...)
con |
A |
studyDbId |
Character or NULL. Filter by study. |
... |
Additional query parameters. |
A tibble with one row per observation (trait measurement).
GET /observations - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
observationDbId, observationUnitDbId, observationVariableDbId,
locationDbId, seasonDbId, observationTimeStampRangeStart,
observationTimeStampRangeEnd.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_observations(con, studyDbId = "study1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_observations(con, studyDbId = "study1") }
Retrieves the ontologies registered on the server: metadata about each
ontology (name, version, authors, description, ...), not the trait
terms that belong to it. brapi_traits(), brapi_scales(),
brapi_methods(), and brapi_observation_variables() each carry an
ontology reference back to one of these records.
brapi_ontologies(con, ...)brapi_ontologies(con, ...)
con |
A |
... |
Additional query parameters. |
A tibble with one row per ontology.
GET /ontologies - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
ontologyName.
brapi_ontology() for a single ontology by ID;
brapi_traits(), brapi_scales(), brapi_methods(), and
brapi_observation_variables() for the records that reference these
ontologies.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_ontologies(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_ontologies(con) }
Get a Single Ontology by ID
brapi_ontology(con, ontologyDbId)brapi_ontology(con, ontologyDbId)
con |
A |
ontologyDbId |
Character. The unique ontology identifier. |
A single-row tibble with ontology details.
GET /ontologies/{ontologyDbId} - see the
v2.1 specification.
brapi_ontologies(); brapi_traits(), brapi_scales(),
brapi_methods(), and brapi_observation_variables() for the
records that reference ontologies.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_ontology(con, "O_001") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_ontology(con, "O_001") }
Retrieves a filtered subset of a pedigree tree via /pedigree - a batch
endpoint for pulling pedigree records across many germplasm in one call.
This is different from brapi_germplasm_pedigree(), which retrieves one
germplasm's immediate pedigree via the germplasm sub-resource
(/germplasm/{germplasmDbId}/pedigree) and must be called once per
germplasm. Use brapi_pedigree() (or brapi_search_pedigree()) to pull
pedigree records for many germplasm at once - e.g. everything in a crop,
program, or family - in one or a few requests; use
brapi_germplasm_pedigree() when you already have a single germplasm ID
in hand.
brapi_pedigree( con, germplasmDbId = NULL, includeParents = NULL, includeSiblings = NULL, includeProgeny = NULL, includeFullTree = NULL, pedigreeDepth = NULL, progenyDepth = NULL, ... )brapi_pedigree( con, germplasmDbId = NULL, includeParents = NULL, includeSiblings = NULL, includeProgeny = NULL, includeFullTree = NULL, pedigreeDepth = NULL, progenyDepth = NULL, ... )
con |
A |
germplasmDbId |
Character or NULL. Filter by germplasm. |
includeParents |
Logical or NULL. Include each node's parents. |
includeSiblings |
Logical or NULL. Include each node's siblings. |
includeProgeny |
Logical or NULL. Include each node's progeny. |
includeFullTree |
Logical or NULL. Recursively include every node reachable in the pedigree tree. |
pedigreeDepth |
Integer or NULL. Number of levels to include up the tree (parents, grandparents, ...). |
progenyDepth |
Integer or NULL. Number of levels to include down the tree (children, grandchildren, ...). |
... |
Additional query parameters. |
Each row is one pedigree node (one germplasm). The server only includes
a node's relatives if asked: set includeParents, includeSiblings,
and/or includeProgeny to TRUE to populate the parents, siblings,
and progeny list-columns, each holding a small tibble of related
germplasm (germplasmDbId, germplasmName, and parentType - NA for
siblings, which have none) that you can tidyr::unnest() when you need
one row per relationship rather than one row per node. Nodes are never
collapsed or flattened by default: a pedigree is graph-shaped (each node
has its own parents, siblings, and progeny edges), and the three
relation types don't share a common row shape, so there is no lossless
single flat table to fall back to.
A tibble with one row per pedigree node. parents, siblings,
and progeny, when requested, are list-columns of small tibbles (one
row per relative) rather than raw nested lists or a flattened table.
GET /pedigree - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
accessionNumber, collection, familyCode, binomialName, genus,
species, synonym, includeParents, includeSiblings,
includeProgeny, includeFullTree, pedigreeDepth, progenyDepth.
brapi_germplasm_pedigree() for one germplasm's pedigree via
the germplasm sub-resource; brapi_search_pedigree() for the same
batch retrieval via POST, with a fuller set of filters.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_pedigree(con, includeParents = TRUE, includeProgeny = TRUE) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_pedigree(con, includeParents = TRUE, includeProgeny = TRUE) }
List People
brapi_people(con, ...)brapi_people(con, ...)
con |
A |
... |
Additional query parameters. |
A tibble with one row per person.
GET /people - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
firstName, lastName, personDbId, userID.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_people(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_people(con) }
Tests whether the BrAPI server is reachable and responding.
brapi_ping(con)brapi_ping(con)
con |
A |
Logical. TRUE if the server responds, FALSE otherwise.
GET /serverinfo - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
contentType, dataType.
con <- brapi_connection("https://test-server.brapi.org") brapi_ping(con)con <- brapi_connection("https://test-server.brapi.org") brapi_ping(con)
The companion to brapi_get() for the POST /search/{entity}
endpoints, which take a filter body rather than query parameters and
may run asynchronously. Use it for search endpoints brapiR2 does not
wrap, or for filter fields a named search function does not expose.
brapi_post_search( con, endpoint, body = list(), poll_interval = 2, max_polls = 30L )brapi_post_search( con, endpoint, body = list(), poll_interval = 2, max_polls = 30L )
con |
A |
endpoint |
Character. The search endpoint, with or without a
leading slash (for example |
body |
Named list. The search request body. Filter fields are sent as JSON arrays, as BrAPI expects, even when you supply a single value. |
poll_interval |
Numeric. Seconds between polling attempts for an asynchronous search. Default 2. |
max_polls |
Integer. Maximum polling attempts before giving up. Default 30. |
A tibble of search results.
A server may answer immediately with the results, or with HTTP 202 and
a searchResultsDbId to be polled until the results are ready. Both
are handled here; the polling happens inside the call and you get the
finished results either way.
As with brapi_get(), the response passes through the same parser the
named functions use. A well-formed BrAPI result returns one row per
record; an unusual one may need reshaping yourself.
brapi_get() for the GET endpoints.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_post_search(con, "/search/germplasm", body = list(germplasmNames = "Tomatillo Fantastico")) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_post_search(con, "/search/germplasm", body = list(germplasmNames = "Tomatillo Fantastico")) }
Get a Single Program by ID
brapi_program(con, programDbId)brapi_program(con, programDbId)
con |
A |
programDbId |
Character. The unique program identifier. |
A single-row tibble with program details.
GET /programs/{programDbId} - see the
v2.1 specification.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_program(con, "program1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_program(con, "program1") }
Retrieves a list of breeding programs from the BrAPI server.
brapi_programs(con, ...)brapi_programs(con, ...)
con |
A |
... |
Additional query parameters passed to the API
(e.g. |
A tibble with one row per program.
GET /programs - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
abbreviation, programType.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_programs(con) brapi_programs(con, commonCropName = "rice") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_programs(con) brapi_programs(con, commonCropName = "rice") }
List Reference Sets (Genome Assemblies)
brapi_reference_sets(con, ...)brapi_reference_sets(con, ...)
con |
A |
... |
Additional query parameters. |
A tibble with one row per reference set.
GET /referencesets - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
referenceSetDbId, accession, assemblyPUI, md5checksum.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_reference_sets(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_reference_sets(con) }
List References (Chromosomes/Contigs)
brapi_references(con, ...)brapi_references(con, ...)
con |
A |
... |
Additional query parameters. |
A tibble with one row per reference sequence.
GET /references - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
referenceDbId, referenceSetDbId, accession, md5checksum,
isDerived, minLength, maxLength.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_references(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_references(con) }
List Samples
brapi_samples(con, ...)brapi_samples(con, ...)
con |
A |
... |
Additional query parameters
(e.g. |
A tibble with one row per sample.
GET /samples - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
sampleDbId, sampleName, sampleGroupDbId, observationUnitDbId,
plateDbId, plateName.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_samples(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_samples(con) }
List Scales
brapi_scales(con, ...)brapi_scales(con, ...)
con |
A |
... |
Additional query parameters. |
A tibble with one row per scale definition.
GET /scales - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
scaleDbId, observationVariableDbId.
brapi_ontologies() and brapi_ontology() to resolve the
ontology a scale's ontologyDbId/ontologyReference points to.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_scales(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_scales(con) }
Search Genotype Calls
brapi_search_calls(con, variantSetDbIds = NULL, callSetDbIds = NULL, ...)brapi_search_calls(con, variantSetDbIds = NULL, callSetDbIds = NULL, ...)
con |
A |
variantSetDbIds |
Character vector. Filter by variant set IDs. |
callSetDbIds |
Character vector. Filter by call set IDs. |
... |
Additional search body parameters. |
A tibble of matching genotype calls.
POST /search/calls - see the
v2.1 specification.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_search_calls(con, variantSetDbIds = "variantset1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_search_calls(con, variantSetDbIds = "variantset1") }
Performs a BrAPI search for germplasm records matching the given criteria.
brapi_search_germplasm( con, germplasmNames = NULL, germplasmDbIds = NULL, commonCropNames = NULL, ... )brapi_search_germplasm( con, germplasmNames = NULL, germplasmDbIds = NULL, commonCropNames = NULL, ... )
con |
A |
germplasmNames |
Character vector. Filter by germplasm names. |
germplasmDbIds |
Character vector. Filter by database IDs. |
commonCropNames |
Character vector. Filter by crop name. |
... |
Additional body parameters for the search request. |
A tibble of matching germplasm records.
POST /search/germplasm - see the
v2.1 specification.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_search_germplasm(con, commonCropNames = "Tomatillo") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_search_germplasm(con, commonCropNames = "Tomatillo") }
The /markerpositions GET filter (see brapi_marker_positions())
takes a single variantDbId; this search endpoint accepts many IDs at
once, which is what brapi_get_marker_map() uses internally when
looking up positions for an entire variant set.
brapi_search_marker_positions( con, mapDbIds = NULL, variantDbIds = NULL, linkageGroupNames = NULL, minPosition = NULL, maxPosition = NULL, ... )brapi_search_marker_positions( con, mapDbIds = NULL, variantDbIds = NULL, linkageGroupNames = NULL, minPosition = NULL, maxPosition = NULL, ... )
con |
A |
mapDbIds |
Character vector. Filter by genome map IDs. |
variantDbIds |
Character vector. Filter by marker/variant IDs. |
linkageGroupNames |
Character vector. Filter by linkage group names. |
minPosition |
Integer. Minimum position, inclusive. |
maxPosition |
Integer. Maximum position, inclusive. |
... |
Additional search body parameters. |
A tibble of matching marker positions.
POST /search/markerpositions - see the
v2.1 specification.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_search_marker_positions(con, variantDbIds = c("variant01", "variant02")) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_search_marker_positions(con, variantDbIds = c("variant01", "variant02")) }
Search Observations
brapi_search_observations( con, studyDbIds = NULL, observationVariableDbIds = NULL, ... )brapi_search_observations( con, studyDbIds = NULL, observationVariableDbIds = NULL, ... )
con |
A |
studyDbIds |
Character vector. Filter by study IDs. |
observationVariableDbIds |
Character vector. Filter by variable IDs. |
... |
Additional search body parameters. |
A tibble of matching observations.
POST /search/observations - see the
v2.1 specification.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_search_observations(con, studyDbIds = "study1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_search_observations(con, studyDbIds = "study1") }
The POST equivalent of brapi_pedigree(), taking the same
tree-shaping parameters plus the fuller set of filters
/search/pedigree accepts (crop, program, trial, study, accession
number, collection, family code, genus/species, and more - pass any of
these through ...). See brapi_pedigree() for the shape of the
returned tibble and its relationship to brapi_germplasm_pedigree().
brapi_search_pedigree( con, germplasmDbIds = NULL, includeParents = NULL, includeSiblings = NULL, includeProgeny = NULL, includeFullTree = NULL, pedigreeDepth = NULL, progenyDepth = NULL, ... )brapi_search_pedigree( con, germplasmDbIds = NULL, includeParents = NULL, includeSiblings = NULL, includeProgeny = NULL, includeFullTree = NULL, pedigreeDepth = NULL, progenyDepth = NULL, ... )
con |
A |
germplasmDbIds |
Character vector. Filter by germplasm IDs. |
includeParents |
Logical. Include each node's parents. |
includeSiblings |
Logical. Include each node's siblings. |
includeProgeny |
Logical. Include each node's progeny. |
includeFullTree |
Logical. Recursively include every node reachable in the pedigree tree. |
pedigreeDepth |
Integer. Number of levels to include up the tree. |
progenyDepth |
Integer. Number of levels to include down the tree. |
... |
Additional search body parameters. |
A tibble with one row per pedigree node; see brapi_pedigree()
for column details.
POST /search/pedigree - see the
v2.1 specification.
brapi_pedigree(), brapi_germplasm_pedigree()
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_search_pedigree(con, includeParents = TRUE) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_search_pedigree(con, includeParents = TRUE) }
Search Observation Variables
brapi_search_variables(con, traitClasses = NULL, ...)brapi_search_variables(con, traitClasses = NULL, ...)
con |
A |
traitClasses |
Character vector. Filter by trait class. |
... |
Additional search body parameters. |
A tibble of matching observation variables.
POST /search/variables - see the
v2.1 specification.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_search_variables(con, traitClasses = "agronomic") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_search_variables(con, traitClasses = "agronomic") }
Search Variants
brapi_search_variants(con, variantSetDbIds = NULL, ...)brapi_search_variants(con, variantSetDbIds = NULL, ...)
con |
A |
variantSetDbIds |
Character vector. Filter by variant set IDs. |
... |
Additional search body parameters. |
A tibble of matching variants.
POST /search/variants - see the
v2.1 specification.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_search_variants(con, variantSetDbIds = "variantset1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_search_variants(con, variantSetDbIds = "variantset1") }
List Seasons
brapi_seasons(con, ...)brapi_seasons(con, ...)
con |
A |
... |
Additional query parameters (e.g. |
A tibble with one row per season.
GET /seasons - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
seasonDbId, season, seasonName, year.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_seasons(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_seasons(con) }
List Seed Lots
brapi_seed_lots(con, ...)brapi_seed_lots(con, ...)
con |
A |
... |
Additional query parameters. |
A tibble with one row per seed lot.
GET /seedlots - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
seedLotDbId, crossDbId, crossName.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_seed_lots(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_seed_lots(con) }
Returns a tibble of BrAPI calls supported by the server. Each row is one supported endpoint with columns for service name, HTTP methods, BrAPI versions, and content/data types.
brapi_server_info(con)brapi_server_info(con)
con |
A |
A tibble of supported endpoints and their methods.
GET /serverinfo - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
contentType, dataType.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_server_info(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_server_info(con) }
If you already have a token (e.g. from a web browser session), you can set it directly without going through a login flow.
brapi_set_token(con, token)brapi_set_token(con, token)
con |
A |
token |
Character. The Bearer token string. |
A new brapi_con object with the token populated.
The "Handling Credentials Safely" section of
vignette("brapiR2") for how to keep token out of your script,
using .Renviron or the keyring package.
con <- brapi_connection("https://test-server.brapi.org") con <- brapi_set_token(con, "my_existing_token")con <- brapi_connection("https://test-server.brapi.org") con <- brapi_set_token(con, "my_existing_token")
Retrieves studies (occurrences/environments), optionally filtered by trial.
brapi_studies(con, trialDbId = NULL, ...)brapi_studies(con, trialDbId = NULL, ...)
con |
A |
trialDbId |
Character or NULL. Filter by trial. |
... |
Additional query parameters. |
A tibble with one row per study.
GET /studies - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
studyType, locationDbId, seasonDbId, studyCode, studyPUI,
observationVariableDbId, active, sortBy, sortOrder.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_studies(con) brapi_studies(con, trialDbId = "trial1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_studies(con) brapi_studies(con, trialDbId = "trial1") }
Get a Single Study by ID
brapi_study(con, studyDbId)brapi_study(con, studyDbId)
con |
A |
studyDbId |
Character. The unique study identifier. |
A single-row tibble with study metadata.
GET /studies/{studyDbId} - see the
v2.1 specification.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_study(con, "study1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_study(con, "study1") }
A convenience function that fetches observation units and observations for a given study and pivots them into a wide-format tibble with one row per observation unit and one column per trait — ready for analysis.
brapi_study_data(con, studyDbId)brapi_study_data(con, studyDbId)
con |
A |
studyDbId |
Character. The unique study identifier. |
A wide-format tibble with columns for plot metadata and one column per observed trait containing the measurement values.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { data <- brapi_study_data(con, "study1") head(data) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { data <- brapi_study_data(con, "study1") head(data) }
List Traits
brapi_traits(con, ...)brapi_traits(con, ...)
con |
A |
... |
Additional query parameters. |
A tibble with one row per trait.
GET /traits - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
traitDbId, observationVariableDbId.
brapi_ontologies() and brapi_ontology() to resolve the
ontology a trait's ontologyDbId/ontologyReference points to.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_traits(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_traits(con) }
Get a Single Trial by ID
brapi_trial(con, trialDbId)brapi_trial(con, trialDbId)
con |
A |
trialDbId |
Character. The unique trial identifier. |
A single-row tibble with trial details.
GET /trials/{trialDbId} - see the
v2.1 specification.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_trial(con, "trial1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_trial(con, "trial1") }
Retrieves trials, optionally filtered by program.
brapi_trials(con, programDbId = NULL, ...)brapi_trials(con, programDbId = NULL, ...)
con |
A |
programDbId |
Character or NULL. Filter by program. |
... |
Additional query parameters. |
A tibble with one row per trial.
GET /trials - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
active, contactDbId, locationDbId, searchDateRangeStart,
searchDateRangeEnd, trialPUI, sortBy, sortOrder.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_trials(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_trials(con) }
List Variant Sets (Datasets)
brapi_variant_sets(con, studyDbId = NULL, ...)brapi_variant_sets(con, studyDbId = NULL, ...)
con |
A |
studyDbId |
Character or NULL. Filter by study. |
... |
Additional query parameters. |
A tibble with one row per variant set.
GET /variantsets - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
variantSetDbId, variantDbId, callSetDbId, referenceSetDbId.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_variant_sets(con) }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_variant_sets(con) }
List Variants (Markers/SNPs)
brapi_variants(con, variantSetDbId = NULL, ...)brapi_variants(con, variantSetDbId = NULL, ...)
con |
A |
variantSetDbId |
Character or NULL. Filter by variant set. |
... |
Additional query parameters. |
A tibble with one row per variant.
GET /variants - see the
v2.1 specification.
Query parameters the specification defines, which may be passed
through ...:
variantDbId, variantSetDbId, referenceDbId, referenceSetDbId.
con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_variants(con, variantSetDbId = "variantset1") }con <- brapi_connection("https://test-server.brapi.org") if (brapi_ping(con)) { brapi_variants(con, variantSetDbId = "variantset1") }
Print a BrAPI Connection Object
## S3 method for class 'brapi_con' print(x, ...)## S3 method for class 'brapi_con' print(x, ...)
x |
A |
... |
Additional arguments (ignored). |
Invisibly returns x.
con <- brapi_connection("https://test-server.brapi.org") print(con)con <- brapi_connection("https://test-server.brapi.org") print(con)