Title: | Query the Breeding Management System(s) |
---|---|
Description: | This R package assists breeders in linking data systems with their analytic pipelines, a crucial step in digitizing breeding processes. It supports querying and retrieving phenotypic and genotypic data from systems like 'EBS' <https://ebs.excellenceinbreeding.org/>, 'BMS' <https://bmspro.io>, 'BreedBase' <https://breedbase.org>, and 'GIGWA' <https://github.com/SouthGreenPlatform/Gigwa2> (using 'BrAPI' <https://brapi.org> calls). Extra helper functions support environmental data sources, including 'TerraClimate' <https://www.climatologylab.org/terraclimate.html> and 'FAO' 'HWSDv2' <https://gaez.fao.org/pages/hwsd> soil database. |
Authors: | Khaled Al-Shamaa [aut, cre], Mariano Omar Crimi [ctb], Zakaria Kehel [ctb], Johan Aparicio [ctb], ICARDA [cph] |
Maintainer: | Khaled Al-Shamaa <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.5.0 |
Built: | 2024-11-22 05:38:01 UTC |
Source: | https://github.com/icarda-git/qbms |
Fetches data from an API endpoint, handles pagination by retrieving all pages, and consolidates the results into a single data frame.
brapi_get_call(call_url, nested = TRUE)
brapi_get_call(call_url, nested = TRUE)
call_url |
Character string specifying the base URL of the API endpoint to request. |
nested |
Logical value indicating whether to flatten nested lists in the JSON responses. Defaults to |
This function performs the following steps:
Fetches the first page synchronously to determine the total number of pages.
If multiple pages exist, it asynchronously fetches the remaining pages using get_async_pages()
.
Consolidates the data from all pages into a single data frame.
Updates global state variables with pagination information.
It relies on global variables from qbms_globals
to manage state and configuration.
A list containing the consolidated data and associated metadata from the API response.
Khaled Al-Shamaa, [email protected]
This function constructs a list of standard HTTP headers required for making API requests, ensuring proper authentication and encoding. These headers are typically included with each API call to provide necessary information such as authorization tokens and content acceptance types. The function is designed to work with authenticated APIs, including BrAPI.
brapi_headers()
brapi_headers()
A named list of common HTTP headers, including the authorization token (Bearer), content encoding, and accepted content types.
A named list containing key HTTP headers, including:
Authorization: Bearer token used for authenticated API access.
Accept-Encoding: Specifies supported compression types such as gzip and deflate.
Accept: Specifies that the client accepts responses in JSON format.
Ensure that the global state contains a valid authorization token before making API requests. This function retrieves the token from 'qbms_globals$state$token', which should be set after a successful login or authentication process.
Khaled Al-Shamaa, [email protected]
This internal table maps QBMS function names to corresponding BrAPI calls for different versions of the BrAPI standard. It is used internally by the QBMS system to translate function calls into BrAPI-compliant API requests.
brapi_map
brapi_map
An object of class data.frame
with 31 rows and 3 columns.
This table supports both BrAPI v1 and v2 endpoints. It is regularly updated to reflect changes in the BrAPI standard and the inclusion of new API calls.
This function is used internally to execute POST calls for retrieving the allele matrix via BrAPI. It handles the post request, waits for the results asynchronously if required, and processes the results.
brapi_post_search_allelematrix(call_url, call_body, nested = TRUE)
brapi_post_search_allelematrix(call_url, call_body, nested = TRUE)
call_url |
BrAPI URL for the POST request. |
call_body |
The request body to send with the POST request. |
nested |
Logical indicating whether to flatten the nested structure. Default is TRUE. |
A list of results obtained from the BrAPI POST call.
Khaled Al-Shamaa, [email protected]
This function is used internally to execute POST calls to BrAPI endpoints and retrieve the results while handling pagination and long-running tasks.
brapi_post_search_call(call_url, call_body, nested = TRUE)
brapi_post_search_call(call_url, call_body, nested = TRUE)
call_url |
BrAPI URL for the POST request. |
call_body |
The request body to send with the POST request. |
nested |
Logical indicating whether to flatten the nested structure. Default is TRUE. |
A list of results obtained from the BrAPI POST call.
Khaled Al-Shamaa, [email protected]
Recursively builds a pedigree table by extracting and tracking parents for each genotype/germplasm in the provided list. The function handles backcross cases and updates the pedigree data frame with parent information for multiple generations.
build_pedigree_table( geno_list = NULL, pedigree_list = NULL, pedigree_df = NULL )
build_pedigree_table( geno_list = NULL, pedigree_list = NULL, pedigree_df = NULL )
geno_list |
A character vector of genotype/germplasm names. |
pedigree_list |
A character vector of associated pedigree strings, corresponding to the genotypes in |
pedigree_df |
A data frame of pedigrees from a previous iteration, used to accumulate pedigree data. If NULL, a new data frame is created. |
A data frame with three columns: - 'Variety': The identifier for the individual genotype. - 'Female': The identifier for the female parent. - 'Male': The identifier for the male parent. The pedigree is built recursively, with individuals listed before any appearance as a parent.
Khaled Al-Shamaa, [email protected]
This function calculates the 19 standard bioclimatic variables derived from monthly temperature and precipitation data. Bioclimatic variables are often used in ecological modeling and species distribution modeling to capture biologically meaningful patterns in climate data, including annual trends, seasonality, and extreme environmental factors.
The bioclimatic variables represent metrics such as the annual mean temperature, temperature seasonality, and precipitation patterns (e.g., wettest or driest quarter). These metrics help to model species distributions and analyze ecological dynamics.
The bioclimatic variables are coded as follows:
BIO1 = Annual Mean Temperature
BIO2 = Mean Diurnal Range (Mean of monthly (max temp - min temp))
BIO3 = Isothermality (BIO2/BIO7) (* 100)
BIO4 = Temperature Seasonality (standard deviation * 100)
BIO5 = Max Temperature of Warmest Month
BIO6 = Min Temperature of Coldest Month
BIO7 = Temperature Annual Range (BIO5 - BIO6)
BIO8 = Mean Temperature of Wettest Quarter
BIO9 = Mean Temperature of Driest Quarter
BIO10 = Mean Temperature of Warmest Quarter
BIO11 = Mean Temperature of Coldest Quarter
BIO12 = Annual Precipitation
BIO13 = Precipitation of Wettest Month
BIO14 = Precipitation of Driest Month
BIO15 = Precipitation Seasonality (Coefficient of Variation)
BIO16 = Precipitation of Wettest Quarter
BIO17 = Precipitation of Driest Quarter
BIO18 = Precipitation of Warmest Quarter
BIO19 = Precipitation of Coldest Quarter
These variables are computed using temperature and precipitation data in a standard format, and are critical for understanding species habitats and the effects of climate on ecosystems.
This work is derived from the dismo R package.
calc_biovars(data)
calc_biovars(data)
data |
A data frame containing monthly climate data. The data frame must include:
The data should contain 12 rows (one for each month from January to December) per year, with the columns sorted in the order of year, ppt, tmin, and tmax. |
A data frame with 19 columns representing the bioclimatic variables (BIO1 to BIO19) and an additional column for the year. The output data frame provides one row per year, with each column corresponding to one of the bioclimatic variables described above.
Khaled Al-Shamaa, [email protected]
Robert Hijmans, Museum of Vertebrate Zoology, UC Berkeley
Nix, 1986. A biogeographic analysis of Australian elapid snakes. In: R. Longmore (ed.). Atlas of elapid snakes of Australia. Australian Flora and Fauna Series 7. Australian Government Publishing Service, Canberra.
Retrieves the internal QBMS status object for debugging purposes. This object contains the current configuration and state of the QBMS session, including connection settings and active tokens.
debug_qbms()
debug_qbms()
An environment object that holds the current QBMS configuration and state.
Khaled Al-Shamaa, [email protected]
if (interactive()) { obj <- debug_qbms() obj$config obj$state }
if (interactive()) { obj <- debug_qbms() obj$config obj$state }
Sends an asynchronous HTTP GET request to fetch data from a single API page.
get_async_page(full_url, nested)
get_async_page(full_url, nested)
full_url |
Character string specifying the full URL of the API endpoint to request. |
nested |
Logical value indicating whether to flatten nested lists in the JSON response. |
This function uses future::future()
to perform the HTTP GET request asynchronously.
It retrieves the content from the specified URL, checks for HTTP errors, and parses the JSON response.
A future representing the asynchronous operation, which will resolve to a list containing the parsed JSON response.
Khaled Al-Shamaa, [email protected]
Sends asynchronous HTTP GET requests to fetch data from multiple API pages concurrently.
get_async_pages(pages, nested)
get_async_pages(pages, nested)
pages |
Character vector of full URLs specifying the API endpoints to request. |
nested |
Logical value indicating whether to flatten nested lists in the JSON responses. |
This function uses future.apply::future_lapply()
to perform concurrent HTTP GET requests for multiple pages.
It retrieves and parses the JSON responses from each URL provided.
A list of parsed JSON responses from each page.
Khaled Al-Shamaa, [email protected]
Constructs the BrAPI endpoint URL for a given QBMS function based on the configured server, crop, and BrAPI version. The function name is mapped to the corresponding BrAPI call using internal mapping.
get_brapi_url(func_name)
get_brapi_url(func_name)
func_name |
(string) The name of the QBMS function for which the BrAPI endpoint URL is required. |
A string representing the BrAPI endpoint URL.
Khaled Al-Shamaa, [email protected]
Retrieves a detailed list of attributes for a given germplasm, such as its origin, donors, and taxonomic information.
get_germplasm_attributes(germplasm_name = "")
get_germplasm_attributes(germplasm_name = "")
germplasm_name |
The name of the germplasm. |
A data frame containing the attributes associated with the specified germplasm.
Johan Steven Aparicio, [email protected]
login_bms
, set_crop
, get_germplasm_data
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") germplasm_attributes <- get_germplasm_attributes("Jabal") }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") germplasm_attributes <- get_germplasm_attributes("Jabal") }
Retrieves all available observations data for the given germplasm in the current active crop. This data is aggregated across all trials in the crop database.
get_germplasm_data(germplasm_name = "")
get_germplasm_data(germplasm_name = "")
germplasm_name |
The name of the germplasm. |
A data frame containing all available observations data for the specified germplasm.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
, get_germplasm_attributes
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") germplasm_observations <- get_germplasm_data("Jabal") head(germplasm_observations) }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") germplasm_observations <- get_germplasm_data("Jabal") head(germplasm_observations) }
Retrieves the unique germplasm ID associated with the specified germplasm name for the current active crop.
get_germplasm_id(germplasm_name = "")
get_germplasm_id(germplasm_name = "")
germplasm_name |
The name of the germplasm. |
A string representing the germplasm's unique ID (germplasmDbId).
Khaled Al-Shamaa, [email protected]
set_crop
, get_germplasm_data
, get_germplasm_attributes
Retrieves the list of germplasm (genetic material) used in the currently active study,
which must be set using the set_study
function.
get_germplasm_list()
get_germplasm_list()
A data frame containing the germplasm list for the active study.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
, set_program
,
set_trial
, set_study
for related operations on crops and studies.
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") set_trial("IDYT39") set_study("IDYT39 Environment Number 9") germplasm <- get_germplasm_list() head(germplasm) }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") set_trial("IDYT39") set_study("IDYT39 Environment Number 9") germplasm <- get_germplasm_list() head(germplasm) }
Queries the HWSD v2 database to retrieve soil information for specific locations based on their coordinates. For each location, the function extracts the Soil Mapping Unit (SMU) code and retrieves soil attributes based on the specified sequence (soil dominance) and depth layer. The function returns the input data frame augmented with soil data from the HWSDv2 dataset.
The HWSD2_SMU table contains general information for each of the soil units occurring in any given SMU code (dominant soil unit and up to 11 associated soils).
The SEQUENCE column refers to the sequence in which soil units within the SMU are presented (in order of percentage share). The dominant soil has sequence 1. The sequence can range between 1 and 12.
The SHARE column refers to the share of the soil unit within the mapping unit in percentage. Shares of soil units within a mapping unit always sum up to 100 percent.
The HWSD2_LAYERS table provides soil attributes per depth layer for each of the seven depth layers (D1 to D7) separately (represented in the LAYER column in the HWSD2_LAYERS table). The depth of the top and bottom of each layer is defined in the TOPDEP and BOTDEP columns, respectively.
get_hwsd2(df, con, x = "longitude", y = "latitude", sequence = 1, layer = "D1")
get_hwsd2(df, con, x = "longitude", y = "latitude", sequence = 1, layer = "D1")
df |
A data frame containing location information, including longitude and latitude in decimal degrees. |
con |
The HWSDv2 object returned by the |
x |
The column name in the data frame representing longitude (default is 'Longitude'). |
y |
The column name in the data frame representing latitude (default is 'Latitude'). |
sequence |
Integer indicating the soil unit's dominance order within the SMU (default is 1 for the dominant soil). Valid values range from 1 to 12. |
layer |
String indicating the depth layer for which soil attributes should be retrieved (default is 'D1', with layers ranging from 'D1' to 'D7'). |
A data frame with the original location data augmented by soil attributes for the specified sequence and layer. The data frame includes additional columns such as 'smu_id', 'SEQUENCE', 'LAYER', and other soil attributes.
Khaled Al-Shamaa, [email protected]
if (interactive()) { Location <- c('Tel-Hadya', 'Terbol', 'Marchouch') Latitude <- c(36.016, 33.808, 33.616) Longitude <- c(36.943, 35.991, -6.716) sites <- data.frame(Location, Latitude, Longitude) hwsd2 <- ini_hwsd2(data_path = 'C:/Users/Kel-shamaa/Downloads/HWSD v2/') sites <- get_hwsd2(df = sites, con = hwsd2, x = 'Longitude', y = 'Latitude', sequence = 1, layer = 'D1') }
if (interactive()) { Location <- c('Tel-Hadya', 'Terbol', 'Marchouch') Latitude <- c(36.016, 33.808, 33.616) Longitude <- c(36.943, 35.991, -6.716) sites <- data.frame(Location, Latitude, Longitude) hwsd2 <- ini_hwsd2(data_path = 'C:/Users/Kel-shamaa/Downloads/HWSD v2/') sites <- get_hwsd2(df = sites, con = hwsd2, x = 'Longitude', y = 'Latitude', sequence = 1, layer = 'D1') }
Opens a GUI pop-up window using Tcl/Tk to prompt the user for their username and password. The window title and prompt message adapt based on the type of server being used (e.g., BMS, GIGWA).
get_login_details()
get_login_details()
A vector containing the inserted username and password, with names 'usr' and 'pwd' respectively.
Khaled Al-Shamaa, [email protected]
Utility function to split a given pedigree string and retrieve the pedigrees of the direct parents (female and male). The function handles different formats of cross representations, such as single slashes (/), double slashes (//), or numbered crosses (e.g., /3/). It extracts the highest cross order when available and returns the sub-pedigree for the immediate parents.
get_parents(pedigree)
get_parents(pedigree)
pedigree |
A string providing the parentage through which a cultivar was obtained. |
A vector of two items representing the direct female and male parents. If parent information is unavailable or unknown, 'NA' is returned for the respective parent.
Khaled Al-Shamaa, [email protected]
Retrieves a comprehensive pedigree table for the given dataset, which contains genotype names and pedigree strings. The function recursively traces parentage across generations and builds a pedigree table where each row corresponds to an individual, with columns for the female and male parents. It also handles cases of similar genotype names by standardizing them.
get_pedigree_table( data, geno_column = "germplasmName", pedigree_column = "pedigree" )
get_pedigree_table( data, geno_column = "germplasmName", pedigree_column = "pedigree" )
data |
A data frame containing genotype/germplasm data, including names and pedigree strings. |
geno_column |
The name of the column that identifies the genotype/germplasm names. |
pedigree_column |
The name of the column that contains the pedigree strings. |
A data frame with three columns: - 'Variety': The identifier for the individual genotype. - 'Female': The identifier for the female parent. - 'Male': The identifier for the male parent. The pedigree table is sorted such that individuals appear before any row where they are listed as a parent. For founders (i.e., individuals with no parent information), 'NA' is used for the parental columns.
Khaled Al-Shamaa, [email protected]
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") set_trial("IDYT39") set_study("IDYT39 Environment Number 9") germplasm <- get_germplasm_list() pedigree_table <- get_pedigree_table(germplasm, "germplasmName", "pedigree") ############################# # nadiv package way # library(nadiv) # Get additive relationship matrix in sparse matrix format # A <- nadiv::makeA(pedigree_table) # Get A inverse matrix using base R function # AINV <- solve(as.matrix(A)) ############################# # ASReml-R package way # library(asreml) # Represent A inverse matrix in an efficient way using i, j index and Ainverse value # Actual genotype names of any given index are in the attr(ainv, "rowNames") # ainv <- asreml::ainverse(pedigree_table) ############################# # Dummy data set for testing test <- data.frame(genotype = c("X", "Y"), pedigree = c("A//B/D/2/C", "B/C/3/A//B/C/2/D")) pedigree_table <- get_pedigree_table(test, "genotype", "pedigree") }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") set_trial("IDYT39") set_study("IDYT39 Environment Number 9") germplasm <- get_germplasm_list() pedigree_table <- get_pedigree_table(germplasm, "germplasmName", "pedigree") ############################# # nadiv package way # library(nadiv) # Get additive relationship matrix in sparse matrix format # A <- nadiv::makeA(pedigree_table) # Get A inverse matrix using base R function # AINV <- solve(as.matrix(A)) ############################# # ASReml-R package way # library(asreml) # Represent A inverse matrix in an efficient way using i, j index and Ainverse value # Actual genotype names of any given index are in the attr(ainv, "rowNames") # ainv <- asreml::ainverse(pedigree_table) ############################# # Dummy data set for testing test <- data.frame(genotype = c("X", "Y"), pedigree = c("A//B/D/2/C", "B/C/3/A//B/C/2/D")) pedigree_table <- get_pedigree_table(test, "genotype", "pedigree") }
Retrieves comprehensive information about the trials, studies, and environments/locations
within the current active breeding program, as configured in the internal state object using
the set_program
function. This includes test and check entry counts for each study.
get_program_studies()
get_program_studies()
A data frame containing detailed information for each study within the program's trials, including trial names, study names, location information, and entry counts.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
, set_program
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") program_studies <- get_program_studies() head(program_studies) }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") program_studies <- get_program_studies() head(program_studies) }
This internal function retrieves the list of trials for the currently active breeding program
and crop combination. The crop and program must be set using set_crop
and
set_program
prior to calling this function.
get_program_trials()
get_program_trials()
A data frame containing information on trials for the active breeding program.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
, set_program
, list_trials
Retrieves the current QBMS connection object, which contains the server's configuration and state, including any active sessions and tokens. This can be used to save and restore connections between sessions.
get_qbms_connection()
get_qbms_connection()
A list containing the current QBMS configuration and state.
Khaled Al-Shamaa, [email protected]
if(interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") df1 <- get_germplasm_data("Jabal") con1 <- get_qbms_connection() set_qbms_config("https://gigwa.southgreen.fr/gigwa/", engine = "gigwa", no_auth = TRUE) gigwa_set_db("DIVRICE_NB") gigwa_set_project("refNB") gigwa_set_run("03052022") df2 <- gigwa_get_metadata() con2 <- get_qbms_connection() set_qbms_connection(con1) df3 <- get_germplasm_attributes("Jabal") }
if(interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") df1 <- get_germplasm_data("Jabal") con1 <- get_qbms_connection() set_qbms_config("https://gigwa.southgreen.fr/gigwa/", engine = "gigwa", no_auth = TRUE) gigwa_set_db("DIVRICE_NB") gigwa_set_project("refNB") gigwa_set_run("03052022") df2 <- gigwa_get_metadata() con2 <- get_qbms_connection() set_qbms_connection(con1) df3 <- get_germplasm_attributes("Jabal") }
Retrieves the observations data (e.g., measurements, variables) for the active study,
which must be set using the set_study
function.
get_study_data()
get_study_data()
A data frame containing the observation data for the active study, or NULL
if no data is available.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
, set_program
,
set_trial
, set_study
for related study operations.
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") set_trial("IDYT39") set_study("IDYT39 Environment Number 9") data <- get_study_data() head(data) }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") set_trial("IDYT39") set_study("IDYT39 Environment Number 9") data <- get_study_data() head(data) }
Retrieves detailed metadata for the currently active study. The study must be
set using the set_study
function, and its details will be fetched
from the BrAPI server.
get_study_info()
get_study_info()
A data frame containing the metadata of the active study. Returns NULL
if no study metadata is available.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
, set_program
,
set_trial
, set_study
for related crop and study management.
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") set_trial("IDYT39") set_study("IDYT39 Environment Number 9") info <- get_study_info() }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") set_trial("IDYT39") set_study("IDYT39 Environment Number 9") info <- get_study_info() }
This function allows you to extract climate variables from the
TerraClimate dataset for specific geographic coordinates.
TerraClimate is a global dataset of monthly climate data covering the years 1958-present. The function retrieves
climate variables directly from the hosting server provided by the
University of Idaho, avoiding the need to download large raster files in netCDF format.
Additionally, the function calculates bioclimatic variables
using the calc_biovars
function, derived from the dismo R package.
The TerraClimate dataset is compared with WorldClim in several aspects:
TerraClimate: 1958-present vs. WorldClim: 1970-2000
14 climate variables vs. 7 climate variables in WorldClim
Spatial resolution: ~4 km (TerraClimate) vs. ~1 km (WorldClim)
Need to calculate bioclimatic variables (TerraClimate) vs. pre-calculated (WorldClim)
get_terraclimate( lat, lon, from = "1958-01-01", to = "2022-12-31", clim_vars = NULL, month_mask = NULL, offline = FALSE, data_path = "./data/" )
get_terraclimate( lat, lon, from = "1958-01-01", to = "2022-12-31", clim_vars = NULL, month_mask = NULL, offline = FALSE, data_path = "./data/" )
lat |
Vector of Latitude(s) in decimal degree format. Each entry corresponds to a location of interest. |
lon |
Vector of Longitude(s) in decimal degree format. Each entry corresponds to a location of interest. |
from |
Start date as a string in 'YYYY-MM-DD' format. Defines the beginning of the time range for data extraction. |
to |
End date as a string in 'YYYY-MM-DD' format. Defines the end of the time range for data extraction. |
clim_vars |
List of climate variables to extract. Valid options include: aet, def, pet, ppt, q, soil,
srad, swe, tmax, tmin, vap, ws, vpd, and PDSI. Default is |
month_mask |
A vector specifying the months of interest, e.g., for specific seasons (e.g., planting season:
|
offline |
Logical value indicating whether to extract TerraClimate data from pre-downloaded netCDF files.
Default is |
data_path |
String specifying the directory path where downloaded netCDF files are stored when working offline. Default is './data/'. |
A list of two data frames for each coordinate pair (latitude and longitude):
climate: A data frame containing the requested climate variables for each month and location.
biovars: A data frame with calculated bioclimatic variables, based on the extracted climate data.
Each data frame is in a format ready for further analysis in R.
Khaled Al-Shamaa, [email protected]
Abatzoglou, J., Dobrowski, S., Parks, S. et al. TerraClimate, a high-resolution global dataset of monthly climate and climatic water balance from 1958-2015. Sci Data 5, 170191 (2018). doi:10.1038/sdata.2017.191
ini_terraclimate
, calc_biovars
if (interactive()) { # data <- get_terraclimate(36.016, 36.943, '1979-09-01', '2012-06-30', # c('ppt', 'tmin', 'tmax'), c(10:12,1:5)) data <- get_terraclimate(36.016, 36.943, '1979-09-01', '2012-06-30') View(data$climate[[1]]) # View the climate data View(data$biovars[[1]]) # View the bioclimatic variables }
if (interactive()) { # data <- get_terraclimate(36.016, 36.943, '1979-09-01', '2012-06-30', # c('ppt', 'tmin', 'tmax'), c(10:12,1:5)) data <- get_terraclimate(36.016, 36.943, '1979-09-01', '2012-06-30') View(data$climate[[1]]) # View the climate data View(data$biovars[[1]]) # View the bioclimatic variables }
Retrieves the combined observations data (including all studies) for the current
active trial, as configured in the internal state object using the set_trial
function.
This function iterates over all studies within the active trial and aggregates
their observation data.
get_trial_data()
get_trial_data()
A data frame containing the combined observations data from all studies in the active trial.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
, set_program
, set_trial
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") set_trial("IDYT39") MET <- get_trial_data() head(MET) }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") set_trial("IDYT39") MET <- get_trial_data() head(MET) }
Retrieves the traits ontology or metadata for the current active trial, which includes detailed information about the observation variables used in the trial.
get_trial_obs_ontology()
get_trial_obs_ontology()
A data frame containing the traits ontology or metadata, filtered by the observation variables used in the current trial.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
, set_program
, set_trial
,
get_study_data
for retrieving study observations.
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") set_trial("IDYT39") ontology <- get_trial_obs_ontology() }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") set_trial("IDYT39") ontology <- get_trial_obs_ontology() }
Retrieve a two-dimensional matrix of genotype data from the selected GIGWA run. This matrix is returned based on filters for regions, samples, or variants. The data can be simplified to use numeric coding for genotypes, or returned in its raw VCF-like format.
gigwa_get_allelematrix( samples = NULL, start = 0, end = "", chrom = NULL, snps = NULL, snps_pageSize = 10000, samples_pageSize = 100, simplify = TRUE )
gigwa_get_allelematrix( samples = NULL, start = 0, end = "", chrom = NULL, snps = NULL, snps_pageSize = 10000, samples_pageSize = 100, simplify = TRUE )
samples |
A list of sample names to include (optional). If NULL, all samples will be included. |
start |
Start position of the query region (zero-based, inclusive). |
end |
End position of the query region (zero-based, exclusive). |
chrom |
Reference sequence name (e.g., chromosome or contig). |
snps |
A list of variant names to filter (optional). |
snps_pageSize |
Number of variants to fetch per page (default is 10,000). |
samples_pageSize |
Number of samples to fetch per page (default is 100). |
simplify |
Whether to simplify the returned data using numeric coding (default is TRUE). |
A data frame with rows representing SNP markers and columns representing samples. Values are numeric codings (0: reference allele, 1: heterozygous, 2: alternative allele).
Khaled Al-Shamaa, [email protected]
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") gigwa_set_run("run1") samples <- gigwa_get_samples() chroms <- gigwa_get_sequences() geno_data <- gigwa_get_allelematrix(samples = samples[1:5], start = 0, end = 1234567, chrom = chroms[1:3]) }
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") gigwa_set_run("run1") samples <- gigwa_get_samples() chroms <- gigwa_get_sequences() geno_data <- gigwa_get_allelematrix(samples = samples[1:5], start = 0, end = 1234567, chrom = chroms[1:3]) }
Retrieve a filtered list of SNP variants from the selected run. This function allows users to query variants based on chromosomal regions and return results in simplified format.
gigwa_get_markers(start = NULL, end = NULL, chrom = NULL, simplify = TRUE)
gigwa_get_markers(start = NULL, end = NULL, chrom = NULL, simplify = TRUE)
start |
Start position of the query region (zero-based, inclusive). |
end |
End position of the query region (zero-based, exclusive). |
chrom |
Reference sequence name (e.g., chromosome). |
simplify |
Logical, if TRUE (default) returns data in a simplified HapMap-like format with columns for rs#, alleles, chromosome, and position. |
A data frame of SNP markers, optionally simplified to include rs#, alleles, chromosome, and position.
Khaled Al-Shamaa, [email protected]
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") gigwa_set_run("run1") chroms <- gigwa_get_sequences() geno_map <- gigwa_get_markers(start = 0, end = 12345678, chrom = chroms[7]) }
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") gigwa_set_run("run1") chroms <- gigwa_get_sequences() geno_map <- gigwa_get_markers(start = 0, end = 12345678, chrom = chroms[7]) }
Retrieve metadata associated with the samples in the current active run, set using the 'gigwa_set_run()' function. The metadata provides additional information about the samples in the selected run.
gigwa_get_metadata()
gigwa_get_metadata()
A data frame containing metadata attributes for each sample in the active run.
Khaled Al-Shamaa, [email protected]
set_qbms_config
, gigwa_set_run
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("3kG_10M") gigwa_set_project("3003_ind") gigwa_set_run("1") metadata <- gigwa_get_metadata() }
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("3kG_10M") gigwa_set_project("3003_ind") gigwa_set_run("1") metadata <- gigwa_get_metadata() }
Retrieve the list of samples associated with the currently active GIGWA project, set using 'gigwa_set_project()'.
gigwa_get_samples()
gigwa_get_samples()
A vector of sample names in the selected project.
Khaled Al-Shamaa, [email protected]
set_qbms_config
, gigwa_set_project
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") samples <- gigwa_get_samples() }
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") samples <- gigwa_get_samples() }
Retrieve the list of sequences (e.g., chromosomes) associated with the currently active project in GIGWA, which has been set using the 'gigwa_set_project()' function.
gigwa_get_sequences()
gigwa_get_sequences()
A vector of sequence names (e.g., chromosome names) for the selected project.
Khaled Al-Shamaa, [email protected]
set_qbms_config
, gigwa_set_project
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") chroms <- gigwa_get_sequences() }
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") chroms <- gigwa_get_sequences() }
Retrieve variant data (e.g., SNP markers) for the selected GIGWA run based on filtering criteria, including minor allele frequency, missing data threshold, and sample subset.
gigwa_get_variants( max_missing = 1, min_maf = 0.5, samples = NULL, start = NULL, end = NULL, referenceName = NULL )
gigwa_get_variants( max_missing = 1, min_maf = 0.5, samples = NULL, start = NULL, end = NULL, referenceName = NULL )
max_missing |
The maximum allowable missing data ratio, between 0 and 1 (default is 1, meaning up to 100% missing data). |
min_maf |
Minimum Minor Allele Frequency (MAF) between 0 and 0.5 (default is 0). |
samples |
A list of sample names to include in the query (optional). If NULL, all samples will be included. |
start |
Start position of the query region (zero-based, inclusive). |
end |
End position of the query region (zero-based, exclusive). |
referenceName |
The reference sequence name (e.g., chromosome). |
A data frame where the first 4 columns describe the SNP (rs# variant name, alleles, chrom, pos), and subsequent columns contain numerical genotyping information (0 for reference allele, 1 for heterozygous, and 2 for minor allele).
Khaled Al-Shamaa, [email protected]
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") gigwa_set_run("run1") marker_matrix <- gigwa_get_variants(max_missing = 0.2, min_maf = 0.35, samples = c("ind1", "ind3", "ind7")) }
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") gigwa_set_run("run1") marker_matrix <- gigwa_get_variants(max_missing = 0.2, min_maf = 0.35, samples = c("ind1", "ind3", "ind7")) }
Retrieve the list of available databases from the connected GIGWA server. An active connection is required. If not connected, the function will throw an error.
gigwa_list_dbs()
gigwa_list_dbs()
A list of databases available on the connected GIGWA server.
Khaled Al-Shamaa, [email protected]
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_list_dbs() }
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_list_dbs() }
Retrieve the list of projects available in the currently active GIGWA database, set using 'gigwa_set_db()'. If no database is selected, the function will throw an error.
gigwa_list_projects()
gigwa_list_projects()
A list of project names in the selected database.
Khaled Al-Shamaa, [email protected]
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_list_projects() }
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_list_projects() }
Retrieve the list of available runs in the currently active GIGWA project, set using 'gigwa_set_project()'. If no project is selected, an error will be raised.
gigwa_list_runs()
gigwa_list_runs()
A list of run names associated with the selected project.
Khaled Al-Shamaa, [email protected]
set_qbms_config
, gigwa_set_project
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") gigwa_list_runs() }
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") gigwa_list_runs() }
Select a GIGWA database as the active database for subsequent operations. This updates the internal configuration object and resets any previously selected projects or runs.
gigwa_set_db(db_name)
gigwa_set_db(db_name)
db_name |
The name of the database to set as active. |
No return value. Updates the internal configuration with the selected database.
Khaled Al-Shamaa, [email protected]
set_qbms_config
, gigwa_list_dbs
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") }
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") }
Select a project from the active GIGWA database and set it as the current active project in the internal state. This selection is used for retrieving related data, such as runs or samples.
gigwa_set_project(project_name)
gigwa_set_project(project_name)
project_name |
The name of the project to set as active. |
No return value. Updates the internal state with the selected project.
Khaled Al-Shamaa, [email protected]
set_qbms_config
, gigwa_set_db
, gigwa_list_projects
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") }
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") }
Select a run from the active GIGWA project and set it as the current active run in the internal state, enabling further data retrieval operations.
gigwa_set_run(run_name)
gigwa_set_run(run_name)
run_name |
The name of the run to set as active. |
No return value. Updates the internal state with the selected run.
Khaled Al-Shamaa, [email protected]
set_qbms_config
, gigwa_set_project
, gigwa_list_runs
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") gigwa_set_run("run1") }
if (interactive()) { set_qbms_config("https://gigwa.southgreen.fr/gigwa/", time_out = 300, engine = "gigwa", no_auth = TRUE) gigwa_set_db("Sorghum-JGI_v1") gigwa_set_project("Nelson_et_al_2011") gigwa_set_run("run1") }
Downloads and sets up the HWSD v2.0 data files required to extract soil data offline. The function retrieves the HWSD raster soil unit map and the SQLite database containing soil attributes. If the files already exist in the specified directory, they are used directly. The function returns an object with the raster and SQLite connection for further queries.
ini_hwsd2(data_path = "./data/", timeout = 300)
ini_hwsd2(data_path = "./data/", timeout = 300)
data_path |
String specifying the directory path where HWSD v2.0 data files are stored or should be downloaded (default is './data/'). |
timeout |
Timeout in seconds for downloading each HWSD v2.0 data file (default is 300). |
A list object ('con') containing two items: - 'raster': HWSDv2 raster object for spatial queries. - 'sqlite': Connection to the HWSDv2 SQLite database.
Khaled Al-Shamaa, [email protected]
if (interactive()) { hwsd2 <- ini_hwsd2(data_path = 'C:/Users/Kel-shamaa/Downloads/HWSD v2/') }
if (interactive()) { hwsd2 <- ini_hwsd2(data_path = 'C:/Users/Kel-shamaa/Downloads/HWSD v2/') }
This function facilitates the download of TerraClimate netCDF files for a specified time period and climate variables. TerraClimate data provides monthly climate data for global terrestrial surfaces, and this function allows you to store the data locally for offline extraction and analysis without the need to download the entire dataset.
Users can specify a range of climate variables such as precipitation, temperature, evapotranspiration, soil moisture, and more. The downloaded files are saved in netCDF format, making them accessible for subsequent offline analysis.
ini_terraclimate( from = "2019-09-01", to = "2022-06-30", clim_vars = c("ppt", "tmin", "tmax"), data_path = "./data/", timeout = 300 )
ini_terraclimate( from = "2019-09-01", to = "2022-06-30", clim_vars = c("ppt", "tmin", "tmax"), data_path = "./data/", timeout = 300 )
from |
Start date as a string in the 'YYYY-MM-DD' format. This defines the beginning of the time period for which you want to download the climate data. |
to |
End date as a string in the 'YYYY-MM-DD' format. This defines the end of the time period for which you want to download the climate data. |
clim_vars |
A list of climate variables to download. Valid options include: aet (Actual Evapotranspiration), def (Climate Water Deficit), pet (Potential Evapotranspiration), ppt (Precipitation), q (Runoff), soil (Soil Moisture), srad (Solar Radiation), swe (Snow Water Equivalent), tmax (Maximum Temperature), tmin (Minimum Temperature), vap (Vapor Pressure), ws (Wind Speed), vpd (Vapor Pressure Deficit), and PDSI (Palmer Drought Severity Index). If NULL (default), all available variables will be downloaded. |
data_path |
A string containing the directory path where the downloaded netCDF files will be stored. The default path is './data/'. |
timeout |
Timeout in seconds for downloading each netCDF raster file. The default value is 300 seconds. |
No explicit return value. The downloaded netCDF files are saved to the specified directory for
offline use with the get_terraclimate
function to extract data for a given
coordinate or set of coordinates.
Khaled Al-Shamaa, [email protected]
if (interactive()) { # Initialize TerraClimate data download for specific climate variables between two dates ini_terraclimate('2018-09-01', '2019-06-30', c('ppt', 'tmin', 'tmax')) # Coordinates for the location(s) of interest x <- c(-6.716, 35.917, 76.884) y <- c(33.616, 33.833, 23.111) # Extract TerraClimate data for the specified coordinates (online mode) a <- get_terraclimate(y, x, '2018-09-01', '2019-06-30', c('ppt', 'tmin', 'tmax')) # View the extracted climate data and bioclimatic variables View(a$climate[[1]]) View(a$biovars[[1]]) # Extract TerraClimate data for the specified coordinates (offline mode) b <- get_terraclimate(y, x, '2018-09-01', '2019-06-30', c('ppt', 'tmin', 'tmax'), offline = TRUE) # View the offline-extracted data View(b$climate[[1]]) View(b$biovars[[1]]) }
if (interactive()) { # Initialize TerraClimate data download for specific climate variables between two dates ini_terraclimate('2018-09-01', '2019-06-30', c('ppt', 'tmin', 'tmax')) # Coordinates for the location(s) of interest x <- c(-6.716, 35.917, 76.884) y <- c(33.616, 33.833, 23.111) # Extract TerraClimate data for the specified coordinates (online mode) a <- get_terraclimate(y, x, '2018-09-01', '2019-06-30', c('ppt', 'tmin', 'tmax')) # View the extracted climate data and bioclimatic variables View(a$climate[[1]]) View(a$biovars[[1]]) # Extract TerraClimate data for the specified coordinates (offline mode) b <- get_terraclimate(y, x, '2018-09-01', '2019-06-30', c('ppt', 'tmin', 'tmax'), offline = TRUE) # View the offline-extracted data View(b$climate[[1]]) View(b$biovars[[1]]) }
Retrieves the list of crops supported by the connected server. If the crop list is cached in the internal state, it returns the cached data; otherwise, it sends a BrAPI GET request to fetch the crop list.
list_crops()
list_crops()
A character vector containing the names of supported crops.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
to configure and set the current active crop.
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server list_crops() # Retrieve list of supported crops }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server list_crops() # Retrieve list of supported crops }
Retrieves a list of locations associated with the current active crop, as
configured in the internal state object using the set_crop
function.
list_locations()
list_locations()
A data frame containing information about locations relevant to the current crop.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
for related crop operations.
Retrieves the list of breeding programs available for the currently selected crop.
The crop must be set using the set_crop
function prior to calling this.
list_programs()
list_programs()
A data frame containing the names of breeding programs available for the active crop.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
, list_crops
for managing server connection and crop selection.
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server set_crop("wheat") # Set "wheat" as the active crop list_programs() # Retrieve breeding programs for the active crop }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server set_crop("wheat") # Set "wheat" as the active crop list_programs() # Retrieve breeding programs for the active crop }
Retrieves a list of studies (and associated locations) for the currently active trial, as configured
using the set_trial
function.
list_studies()
list_studies()
A data frame containing study names and associated location names. If no studies are available, an error is thrown.
This function must be called after a trial has been set using set_trial
.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
, set_program
, set_trial
for related operations on crops, programs, and trials.
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server set_crop("wheat") # Set crop set_program("Wheat International Nurseries") # Set breeding program set_trial("IDYT39") # Set trial list_studies() # List studies }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server set_crop("wheat") # Set crop set_program("Wheat International Nurseries") # Set breeding program set_trial("IDYT39") # Set trial list_studies() # List studies }
Retrieves the list of trials for the current active breeding program. Optionally, filters trials by their starting year if specified.
list_trials(year = NULL)
list_trials(year = NULL)
year |
Numeric. An optional parameter to filter trials by their starting year. If not provided, all trials for the active program are returned. |
A data frame containing the names of trials for the active breeding program. If no trials match the query, a warning is issued, and NA is returned.
The year filter is only supported for BMS databases.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
, set_program
for related operations involving crop and program selection.
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server set_crop("wheat") # Set crop set_program("Wheat International Nurseries") # Set breeding program list_trials() # List trials list_trials(2022) # List trials starting in 2022 }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server set_crop("wheat") # Set crop set_program("Wheat International Nurseries") # Set breeding program list_trials() # List trials list_trials(2022) # List trials starting in 2022 }
Connects to the BMS or related server using a username and password. If these are not provided, a pop-up window will prompt the user to enter their credentials. The function handles authentication and stores the resulting access token internally for subsequent requests.
login_bms(username = NULL, password = NULL, encoding = "json")
login_bms(username = NULL, password = NULL, encoding = "json")
username |
The username (optional, default is NULL). If not provided, the pop-up window is triggered. |
password |
The password (optional, default is NULL). If not provided, the pop-up window is triggered. |
encoding |
Specifies how the request body should be encoded: 'form' (application/x-www-form-urlencoded), 'multipart' (multipart/form-data), or 'json' (application/json). Default is "json". |
No return value. The access token is stored internally for future use.
Khaled Al-Shamaa, [email protected]
if(interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() }
if(interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() }
Logs in to the BreedBase server using a username and password. If credentials are not provided, a pop-up window will prompt the user. The function is a wrapper around the 'login_bms()' function, with encoding set to 'form'.
login_breedbase(username = NULL, password = NULL)
login_breedbase(username = NULL, password = NULL)
username |
The username (optional, default is NULL). |
password |
The password (optional, default is NULL). |
No return value. The access token is stored internally for future use.
Khaled Al-Shamaa, [email protected]
Connect to the GIGWA server. If the 'username' or 'password' parameters are missing, a login window will be triggered to capture these details.
All connection settings (server URL, port, API path, and protocol) are read from the 'qbms_config' list. The function will request an authentication token from the server and update the 'qbms_state' list with the token.
login_gigwa(username = NULL, password = NULL)
login_gigwa(username = NULL, password = NULL)
username |
The GIGWA username (optional, default is NULL). |
password |
The GIGWA password (optional, default is NULL). |
No return value. The authentication token will be stored internally.
Khaled Al-Shamaa, [email protected]
if (interactive()) { set_qbms_config("http://localhost:59395/gigwa/index.jsp", time_out = 300, engine = "gigwa") # Login using your GIGWA account (interactive mode) login_gigwa() # You can pass GIGWA username and password as parameters (batch mode) # login_gigwa("gigwadmin", "nimda") }
if (interactive()) { set_qbms_config("http://localhost:59395/gigwa/index.jsp", time_out = 300, engine = "gigwa") # Login using your GIGWA account (interactive mode) login_gigwa() # You can pass GIGWA username and password as parameters (batch mode) # login_gigwa("gigwadmin", "nimda") }
Performs OAuth 2.0 authentication by sending the user to the authorization URL and exchanging the authorization code for an access token. This function supports caching of tokens for subsequent requests.
login_oauth2( authorize_url, access_url, client_id, client_secret = NULL, redirect_uri = "http://localhost:1410" )
login_oauth2( authorize_url, access_url, client_id, client_secret = NULL, redirect_uri = "http://localhost:1410" )
authorize_url |
The URL where the client is redirected for user authorization. |
access_url |
The URL used to exchange an authorization code for an access token. |
client_id |
The client ID (consumer key) provided by the authorization server. |
client_secret |
The client secret provided by the authorization server (optional). |
redirect_uri |
The URL where the user will be redirected after authorization (default is http://localhost:1410). |
No return value. Updates the internal state with the access token and additional details.
Khaled Al-Shamaa, [email protected]
Performs the equivalent of do.call("rbind", x) on data.frames, but much faster.
rbindlistx(x)
rbindlistx(x)
x |
A list containing data.table, data.frame, or list objects. |
An unkeyed data.table containing a concatenation of all the items passed in.
Combines a list of data frames by row, filling in missing columns with NA.
rbindx(..., dfs = list(...))
rbindx(..., dfs = list(...))
... |
The first argument data frame. |
dfs |
Input data frames to row bind together. |
A single data frame.
Scans the available BrAPI endpoints on the configured source server and checks their accessibility. This function allows users to verify which BrAPI endpoints are available based on the provided IDs.
scan_brapi_endpoints(programDbId = 0, trialDbId = 0, studyDbId = 0)
scan_brapi_endpoints(programDbId = 0, trialDbId = 0, studyDbId = 0)
programDbId |
(numeric) The programDbId to scan specific program-related endpoints (default is 0). |
trialDbId |
(numeric) The trialDbId to scan specific trial-related endpoints (default is 0). |
studyDbId |
(numeric) The studyDbId to scan specific study-related endpoints (default is 0). |
A data frame listing the QBMS function, BrAPI endpoint URL, and availability status for each endpoint.
Khaled Al-Shamaa, [email protected]
Updates the internal configuration to set the selected crop as the active one. This must be called before performing crop-specific operations such as retrieving breeding programs.
set_crop(crop_name)
set_crop(crop_name)
crop_name |
A string specifying the name of the crop to set as active. |
No return value. The function updates the global state with the selected crop.
Khaled Al-Shamaa, [email protected]
login_bms
, list_crops
to validate and retrieve the list of supported crops.
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server set_crop("wheat") # Set "wheat" as the active crop }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server set_crop("wheat") # Set "wheat" as the active crop }
Updates the internal state to set the selected breeding program as active using the associated programDbId. This allows subsequent operations to be carried out within the context of this program.
set_program(program_name)
set_program(program_name)
program_name |
A string specifying the name of the breeding program to set as active. |
No return value. The internal state is updated with the selected program.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
, list_programs
for related operations in the crop and program selection process.
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server set_crop("wheat") # Set crop set_program("Wheat International Nurseries") # Set breeding program }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server set_crop("wheat") # Set crop set_program("Wheat International Nurseries") # Set breeding program }
Configures the BMS server connection settings, including URL, API path, page size, and timeout. This function allows you to set up the connection for different server backends like BMS, Gigwa, EBS, and Breedbase, and choose the appropriate BrAPI version.
set_qbms_config( url = "http://localhost", path = NULL, page_size = 1000, time_out = 120, no_auth = FALSE, engine = "bms", brapi_ver = "v1", verbose = TRUE )
set_qbms_config( url = "http://localhost", path = NULL, page_size = 1000, time_out = 120, no_auth = FALSE, engine = "bms", brapi_ver = "v1", verbose = TRUE )
url |
The URL of the BMS login page or API base (default is "http://localhost"). |
path |
The API path to use (default is NULL, which sets a path based on the engine). |
page_size |
The number of records per page when making API calls (default is 1000). |
time_out |
The maximum number of seconds to wait for a response (default is 120). |
no_auth |
Logical, whether the server requires authentication (default is FALSE). |
engine |
The backend system (default is "bms"). Options include "bms", "gigwa", "breedbase", "ebs". |
brapi_ver |
The version of BrAPI to use, either "v1" or "v2" (default is "v1"). |
verbose |
Logical, indicating whether to display progress information when making API calls (default is TRUE). |
No return value.
Khaled Al-Shamaa, [email protected]
set_qbms_config("https://bms.icarda.org/ibpworkbench")
set_qbms_config("https://bms.icarda.org/ibpworkbench")
Sets the QBMS connection object in the current environment, allowing users to restore a saved connection, including configuration settings and session tokens.
set_qbms_connection(env)
set_qbms_connection(env)
env |
A list containing the saved connection configuration and state. |
Khaled Al-Shamaa, [email protected]
if(interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") df1 <- get_germplasm_data("Jabal") con1 <- get_qbms_connection() set_qbms_config("https://gigwa.southgreen.fr/gigwa/", engine = "gigwa", no_auth = TRUE) gigwa_set_db("DIVRICE_NB") gigwa_set_project("refNB") gigwa_set_run("03052022") df2 <- gigwa_get_metadata() con2 <- get_qbms_connection() set_qbms_connection(con1) df3 <- get_germplasm_attributes("Jabal") }
if(interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() set_crop("wheat") set_program("Wheat International Nurseries") df1 <- get_germplasm_data("Jabal") con1 <- get_qbms_connection() set_qbms_config("https://gigwa.southgreen.fr/gigwa/", engine = "gigwa", no_auth = TRUE) gigwa_set_db("DIVRICE_NB") gigwa_set_project("refNB") gigwa_set_run("03052022") df2 <- gigwa_get_metadata() con2 <- get_qbms_connection() set_qbms_connection(con1) df3 <- get_germplasm_attributes("Jabal") }
Updates the internal state to set the selected study as the current active study using the associated studyDbId. This allows operations to be performed within the context of the selected study.
set_study(study_name)
set_study(study_name)
study_name |
A string specifying the name of the study to set as active. |
No return value. The internal state is updated with the selected study.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
, set_program
, set_trial
, list_studies
for related operations on crops, programs, trials, and studies.
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server set_crop("wheat") # Set crop set_program("Wheat International Nurseries") # Set breeding program set_trial("IDYT39") # Set trial set_study("IDYT39 Environment Number 9") # Set study }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server set_crop("wheat") # Set crop set_program("Wheat International Nurseries") # Set breeding program set_trial("IDYT39") # Set trial set_study("IDYT39 Environment Number 9") # Set study }
Stores the access token and associated details (such as username and expiration time) in the internal state. The token is typically retrieved from the server during login and used for subsequent API requests.
set_token(token, user = "", expires_in = 3600)
set_token(token, user = "", expires_in = 3600)
token |
The access token string issued by the authorization server. |
user |
The username associated with the token (optional). |
expires_in |
The lifetime of the access token in seconds (optional, default is 3600 seconds). |
No return value. Updates the internal state with the token info.
Khaled Al-Shamaa, [email protected]
Updates the internal state to set the selected trial as the current active trial using the associated trialDbId. This enables operations to be carried out within the context of the selected trial.
set_trial(trial_name)
set_trial(trial_name)
trial_name |
A string specifying the name of the trial to set as active. |
No return value. The internal state is updated with the selected trial.
Khaled Al-Shamaa, [email protected]
login_bms
, set_crop
, set_program
, list_trials
for operations involving crops, programs, and trials.
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server set_crop("wheat") # Set crop set_program("Wheat International Nurseries") # Set breeding program set_trial("IDYT39") # Set trial }
if (interactive()) { set_qbms_config("https://bms.icarda.org/ibpworkbench") login_bms() # Log in to the server set_crop("wheat") # Set crop set_program("Wheat International Nurseries") # Set breeding program set_trial("IDYT39") # Set trial }