Sends a query to the Synthesize Bio API for prediction and retrieves gene expression samples. This function validates the query, sends it to the API, and processes the response into usable data frames.
Usage
predict_query(
query,
as_counts = TRUE,
api_base_url = API_BASE_URL,
poll_interval_seconds = DEFAULT_POLL_INTERVAL_SECONDS,
poll_timeout_seconds = DEFAULT_POLL_TIMEOUT_SECONDS,
return_download_url = FALSE
)
Arguments
- query
A list representing the query data to send to the API. Use `get_valid_query()` to generate an example.
- as_counts
Logical, if FALSE, transforms the predicted expression counts into logCPM (default is TRUE, returning raw counts).
- api_base_url
The base URL for the API server. Default is API_BASE_URL.
- poll_interval_seconds
Seconds between polling attempts of the status endpoint. Default is DEFAULT_POLL_INTERVAL_SECONDS (2).
- poll_timeout_seconds
Maximum total seconds to wait before timing out. Default is DEFAULT_POLL_TIMEOUT_SECONDS (900 = 15 minutes).
- return_download_url
Logical, if TRUE, returns a list containing the signed download URL instead of parsing into data frames. Default is FALSE.
Value
A list. If `return_download_url` is `FALSE` (default), the list contains two data frames: `metadata` and `expression`. If `TRUE`, the list contains `download_url` and empty `metadata` and `expression` data frames.
Examples
# Set your API key (in practice, use a more secure method)
if (FALSE) { # \dontrun{
# To start using rsynthbio, first you need to have an account with synthesize.bio.
# Go here to create one: https://app.synthesize.bio/
set_synthesize_token()
# Create a query
query <- get_valid_query()
# Request raw counts
result <- predict_query(query, as_counts = TRUE)
# Access the results
metadata <- result$metadata
expression <- result$expression
# Request log CPM transformed data
log_result <- predict_query(query, as_counts = FALSE)
log_expression <- log_result$expression
# Explore the top expressed genes in the first sample
head(sort(expression[1, ], decreasing = TRUE))
} # }