| Title: | Use 'Aplos NCA API' for Pharmacokinetic Analysis |
|---|---|
| Description: | Using this package you can interact with the 'Aplos NCA API'<https://docs.aplosanalytics.com/> using standard R functions. This will allow you to authenticate with your 'Aplos NCA' account, upload input datasets, initiate analyses, and download results. |
| Authors: | Nathan Teuscher [aut, cre] |
| Maintainer: | Nathan Teuscher <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.1 |
| Built: | 2026-05-10 06:21:33 UTC |
| Source: | https://github.com/aplosanalytics/aplosnca |
Retrieves download URLs and files from Aplos NCA analysis results.
aplos_download_results(url, token, execution_id)aplos_download_results(url, token, execution_id)
url |
The base API URL. |
token |
JWT token. |
execution_id |
The execution ID. |
A data frame with download URL and filename.
## Not run: df <- aplos_download_results("https://api.app.aplos-nca.com", token, "exec_123") ## End(Not run)## Not run: df <- aplos_download_results("https://api.app.aplos-nca.com", token, "exec_123") ## End(Not run)
Submits and executes an NCA analysis on uploaded data.
aplos_execute_analysis( result, data_cleaning = "{}", analysis = "{}", calcs = "{}", plots = "{}", tables = "{}", metadata = "{}", url, token, name = "NCA Analysis via R", save_body = FALSE )aplos_execute_analysis( result, data_cleaning = "{}", analysis = "{}", calcs = "{}", plots = "{}", tables = "{}", metadata = "{}", url, token, name = "NCA Analysis via R", save_body = FALSE )
result |
Result from aplos_get_upload_url(). |
data_cleaning |
JSON string for data cleaning (default ""). |
analysis |
JSON string for PK parameter calculation (default ""). |
calcs |
JSON string for custom calculations (default ""). |
plots |
JSON string for custom plots (default ""). |
tables |
JSON string for custom tables (default ""). |
metadata |
JSON string for metadata (default ""). |
url |
The base API URL. |
token |
JWT token. |
name |
Analysis name (default "NCA Analysis via R"). |
save_body |
Logical; save body of API POST command to body.txt file? (default FALSE, set to TRUE for debugging). |
The execution ID.
## Not run: exec_id <- aplos_execute_analysis(upload_result, url = "https://api.app.aplos-nca.com", token = token) ## End(Not run)## Not run: exec_id <- aplos_execute_analysis(upload_result, url = "https://api.app.aplos-nca.com", token = token) ## End(Not run)
Polls the status of an NCA analysis execution until complete or failed.
aplos_execution_status(url, token, execution_id, sleep = 10)aplos_execution_status(url, token, execution_id, sleep = 10)
url |
The base API URL. |
token |
JWT token. |
execution_id |
The execution ID from aplos_execute_analysis(). |
sleep |
Numeric value for time (in seconds) between status checks (default 10). |
The status result if succeeded, or stops with error if failed.
## Not run: status <- aplos_execution_status("https://api.app.aplos-nca.com", token, "exec_123") ## End(Not run)## Not run: status <- aplos_execution_status("https://api.app.aplos-nca.com", token, "exec_123") ## End(Not run)
Downloads the results file from the provided download information and optionally unzips it.
aplos_fetch_results(download_info, dest_dir = "", unzip = FALSE)aplos_fetch_results(download_info, dest_dir = "", unzip = FALSE)
download_info |
A data frame from aplos_download_results() containing url and filename. |
dest_dir |
Directory to save the downloaded file (default: current working directory). |
unzip |
Logical; if TRUE, unzip the file to dest_dir/unzip (default: FALSE). |
The path to the downloaded file (or unzip directory if unzip=TRUE).
## Not run: # Assuming status is "succeeded" download_info <- aplos_download_results(url, token, execution_id) file_path <- aplos_fetch_results(download_info, unzip = TRUE) ## End(Not run)## Not run: # Assuming status is "succeeded" download_info <- aplos_download_results(url, token, execution_id) file_path <- aplos_fetch_results(download_info, unzip = TRUE) ## End(Not run)
Authenticates with the Aplos NCA API using AWS Cognito. This function sends a POST request to retrieve a JWT token for subsequent API calls. All API calls require a valid JWT. The JWT is only valid for a period of time (~15 minutes). Each time you make an API call with a valid JWT, that token is refreshed and the valid period is extended. Thus during a normal analysis you will only need to authenticate once as you will be making API calls within the valid time window. However, if you walk away from your computer or there is a long delay between API calls you may need to authenticate again.
Note: Store credentials securely; do not hardcode them in scripts. It is recommended that you use a hidden text file (e.g. ".aplos_creds") stored on your local computer. Read that file in and then parse it to update the required information for authentication. An example credential file may look like the following: APLOS_API_URL="https://api.app.aplos-nca.com" COGNITO_CLIENT_KEY="your_cognito_client_id/key" COGNITO_USER_NAME="your_username" COGNITO_PASSWORD="your_password" COGNITO_REGION="your_aws_region" All of this information can be found in your user profile for your Aplos NCA account under "API Settings".
aplos_get_jwt(client_id, username, password, region)aplos_get_jwt(client_id, username, password, region)
client_id |
The Cognito client ID. |
username |
Your Aplos NCA username. |
password |
Your Aplos NCA password. |
region |
The AWS region (e.g., "us-east-1"). |
A character string containing the JWT token.
## Not run: token <- aplos_get_jwt(client_id = "your_client_id", username = "user", password = "pass", region = "us-east-1") ## End(Not run)## Not run: token <- aplos_get_jwt(client_id = "your_client_id", username = "user", password = "pass", region = "us-east-1") ## End(Not run)
Retrieves a presigned URL for uploading files to Aplos NCA.
aplos_get_upload_url(input_file, url, token)aplos_get_upload_url(input_file, url, token)
input_file |
Path to the input file. |
url |
The base API URL. |
token |
JWT token from aplos_get_jwt(). |
A list with upload details.
## Not run: result <- aplos_get_upload_url("path/to/file.csv", "https://api.app.aplos-nca.com", token) ## End(Not run)## Not run: result <- aplos_get_upload_url("path/to/file.csv", "https://api.app.aplos-nca.com", token) ## End(Not run)
Uploads a file using the presigned URL.
aplos_upload_file(input_file, result, token)aplos_upload_file(input_file, result, token)
input_file |
Path to the input file. |
result |
Result from aplos_get_upload_url(). |
token |
JWT token. |
Invisible NULL. Uploads the file to the API as a side effect; throws an error if the upload fails.
## Not run: aplos_upload_file("path/to/file.csv", upload_result, token) ## End(Not run)## Not run: aplos_upload_file("path/to/file.csv", upload_result, token) ## End(Not run)