diff --git a/.Rbuildignore b/.Rbuildignore index 29cc3f0..155d859 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -7,3 +7,10 @@ ^pkgdown$ ^\.github$ ^README\.Rmd$ +^CODE_OF_CONDUCT\.md$ +^logo\.png$ +^report.html$ +^LICENSE$ +^reports$ +^CRAN-SUBMISSION$ +^cran-comments\.md$ diff --git a/.gitignore b/.gitignore index 31868fa..bcd0a9e 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,5 @@ po/*~ rsconnect/ docs *.html +CRAN-SUBMISSION +cran-comments.md \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index e999aea..6de145e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,13 +1,30 @@ Package: clintrialx Type: Package -Title: Connect and work with clinical trials data sources with R programming. +Title: Connect and Work with Clinical Trials Data Sources Version: 0.1.0 -Authors@R: person("Indraneel", "Chakraborty",, "hello.indraneel@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-6958-8269")) +Authors@R: + person("Indraneel", "Chakraborty",, "hello.indraneel@gmail.com", + role = c("aut", "cre"), comment = c(ORCID = "0000-0001-6958-8269")) Maintainer: Indraneel Chakraborty -Description: Are you spending too much time fetching and managing clinical trial data? Struggling with complex queries and bulk data extraction? What if you could simplify this process with just a few lines of code? Introducing clintrialx - Fetch clinical trial data from sources like ClinicalTrials.gov and the CTTI AACT database with R, supporting pagination and bulk downloads! -License: Apache License Version 2.0 +Description: Are you spending too much time fetching and managing clinical trial data? Struggling with complex queries and bulk data extraction? What if you could simplify this process with just a few lines of code? Introducing 'clintrialx' - Fetch clinical trial data from sources like 'ClinicalTrials.gov' and the 'Clinical Trials Transformation Initiative - Access to Aggregate Content of ClinicalTrials.gov' database , supporting pagination and bulk downloads. Also, you can generate HTML reports based on the data obtained from the sources! +License: Apache License 2.0 Encoding: UTF-8 LazyData: true -Depends: R (>= 4.0.0), httr, lubridate, readr, dplyr, progress,RPostgreSQL +Depends: + R (>= 4.0.0) +Imports: + httr, + lubridate, + readr, + dplyr, + progress, + RPostgreSQL, + tibble, + DBI, + rmarkdown, + xfun (>= 0.44) +Suggests: + knitr +VignetteBuilder: knitr RoxygenNote: 7.3.2 -URL: http://ineelhere.github.io/clintrialx/ +URL: http://www.indraneelchakraborty.com/clintrialx/ diff --git a/NAMESPACE b/NAMESPACE index d75f824..ba03186 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1 +1,32 @@ -exportPattern("^[[:alpha:]]+") +# Generated by roxygen2: do not edit by hand + +export(aact_check_connection) +export(aact_connection) +export(aact_custom_query) +export(ctg_bulk_fetch) +export(ctg_count) +export(ctg_data_report) +export(ctg_get_fields) +export(ctg_get_nct) +export(hello) +export(version_info) +import(DBI) +import(RPostgreSQL) +import(dplyr) +import(httr) +import(progress) +import(readr) +import(tibble) +importFrom(dplyr,as_tibble) +importFrom(dplyr,bind_rows) +importFrom(grDevices,colorRampPalette) +importFrom(httr,GET) +importFrom(httr,content) +importFrom(httr,status_code) +importFrom(lubridate,ymd_hms) +importFrom(progress,progress_bar) +importFrom(readr,cols) +importFrom(readr,read_csv) +importFrom(rmarkdown,render) +importFrom(utils,install.packages) +importFrom(utils,installed.packages) diff --git a/R/aact_query.R b/R/aact_query.R index 0d1fa61..86b84eb 100644 --- a/R/aact_query.R +++ b/R/aact_query.R @@ -3,12 +3,16 @@ #' @param user Database username #' @param password Database password #' @return A connection object to the AACT database +#' @import DBI +#' @import RPostgreSQL #' @examples +#' \donttest{ #' # Set environment variables for database credentials in .Renviron and load it #' # readRenviron(".Renviron") #' #' # Connect to the database #' con <- aact_connection(Sys.getenv('user'), Sys.getenv('password')) +#' } #' @export aact_connection <- function(user, password) { con <- dbConnect( @@ -26,7 +30,9 @@ aact_connection <- function(user, password) { #' #' @param con Database connection object #' @return A data frame with distinct study types +#' @import DBI #' @examples +#' \donttest{ #' # Set environment variables for database credentials in .Renviron and load it #' # readRenviron(".Renviron") #' @@ -35,6 +41,7 @@ aact_connection <- function(user, password) { #' #' # Check the connection #' aact_check_connection(con) +#' } #' @export aact_check_connection <- function(con) { df <- dbGetQuery(con, "select distinct study_type from studies") @@ -49,8 +56,9 @@ aact_check_connection <- function(con) { #' @param con Database connection object #' @param query SQL query string #' @return A data frame with the query results -#' Check database schema here - https://aact.ctti-clinicaltrials.org/documentation/aact_schema.png +#' @import DBI #' @examples +#' \donttest{ #' # Set environment variables for database credentials in .Renviron and load it #' # readRenviron(".Renviron") #' @@ -63,6 +71,7 @@ aact_check_connection <- function(con) { #' #' # Print the results #' print(results) +#' } #' @export aact_custom_query <- function(con, query) { df <- dbGetQuery(con, query) diff --git a/R/ctg_bulk_fetch.R b/R/ctg_bulk_fetch.R index 8028374..6095a86 100644 --- a/R/ctg_bulk_fetch.R +++ b/R/ctg_bulk_fetch.R @@ -37,9 +37,12 @@ #' #' #' @examples +#' \donttest{ #' trials <- ctg_bulk_fetch(location="india") +#' } #' @export + ctg_bulk_fetch <- function(condition = NULL, location = NULL, title = NULL, intervention = NULL, status = NULL) { @@ -104,7 +107,7 @@ get_total_count <- function(base_url, query_params) { create_progress_bar <- function(total_pages) { progress::progress_bar$new( - format = "Fetching Page :current/:total :spin :bar Completed :percent πŸ•’ :elapsedfull ", + format = "Fetching Page :current/:total :spin :bar Completed :percent :elapsedfull ", total = total_pages, clear = FALSE, width = 80 diff --git a/R/ctg_data_report.R b/R/ctg_data_report.R index cf229a7..f2405db 100644 --- a/R/ctg_data_report.R +++ b/R/ctg_data_report.R @@ -5,7 +5,7 @@ #' It automates the process of data analysis and visualization, providing insights into various #' aspects of clinical trials such as study status, enrollment, duration, and funding sources. #' -#' Visit here for an example report - \url{https://ineelhere.github.io/clintrialx/report.html}. +#' Visit here for an example report - \url{https://www.indraneelchakraborty.com/clintrialx/report.html}. #' @param ctg_data A data frame containing clinical trial data. Required columns include: #' \itemize{ #' \item \code{Study Status}: Current status of each study (e.g., \code{"Completed"}, \code{"Ongoing"}) @@ -85,37 +85,13 @@ #' \item The generated report is self-contained and can be easily shared or published on the web. #' } #' -#' @examples -#' \dontrun{ -#' # Basic usage with default settings -#' ctg_data_report(my_clinical_trial_data) -#' -#' # Customized report with specific settings -#' ctg_data_report( -#' ctg_data = my_clinical_trial_data, -#' title = "Clinical Trials Analysis", -#' author = "Indra", -#' output_file = "reports/clinical_trials.html", -#' theme = "flatly", -#' color_palette = c("#4E79A7", "#F28E2B", "#E15759", "#76B7B2", "#59A14F", "#EDC948"), -#' include_data_quality = TRUE, -#' include_interactive_plots = TRUE, -#' custom_footer = "Proprietary report generated by SomeGreatOrg Inc." -#' ) -#' -#' # Generate a report with static plots and no data quality assessment -#' ctg_data_report( -#' my_clinical_trial_data, -#' title = "Quick Clinical Trial Overview", -#' include_data_quality = FALSE, -#' include_interactive_plots = FALSE -#' ) -#' } -#' #' @seealso -#' \url{https://ineelhere.github.io/clintrialx} for more information about the ClinTrialX package. -#' +#' \url{https://www.indraneelchakraborty.com/clintrialx/} for more information about the ClinTrialX package. +#' @importFrom grDevices colorRampPalette +#' @importFrom utils install.packages installed.packages +#' @importFrom rmarkdown render #' @export + ctg_data_report <- function(ctg_data, title = "Clinical Trial Data Report", author = "Author Name", @@ -125,49 +101,25 @@ ctg_data_report <- function(ctg_data, include_data_quality = TRUE, include_interactive_plots = TRUE, custom_footer = NULL) { + # List of required packages required_packages <- c("rmarkdown", "ggplot2", "plotly", "dplyr", "lubridate", "reactable", "scales", "RColorBrewer", "htmltools") - # Function to check if a package is installed - is_installed <- function(package) { - return(package %in% rownames(installed.packages())) - } - - # Check which packages are missing - missing_packages <- required_packages[!sapply(required_packages, is_installed)] + # Check if required packages are available + missing_packages <- required_packages[!sapply(required_packages, requireNamespace, quietly = TRUE)] - # If there are missing packages, print a message and offer to install them if (length(missing_packages) > 0) { - cat("The following packages are required but not installed:\n") - cat(paste("-", missing_packages, collapse = "\n"), "\n\n") - - install_choice <- readline(prompt = "Would you like to install these packages now? (yes/no): ") - - if (tolower(install_choice) == "yes") { - install.packages(missing_packages) - cat("\nPackages installed successfully.\n") - } else { - cat("\nPlease install the missing packages before running the report generation function.\n") - return() - } - } else { - cat("All required packages are already installed.\n") + stop("The following required packages are not installed: ", + paste(missing_packages, collapse = ", "), + ". Please install these packages before running this function.") } - # Load all required packages - lapply(required_packages, library, character.only = TRUE) - - cat("\nAll necessary packages are now loaded and ready to use.\n") - # Available themes available_themes <- c("default", "cerulean", "journal", "flatly", "readable", "spacelab", "united", "cosmo", "lumen", "paper", "sandstone", "simplex", "yeti") # Check if the provided theme is valid if (!(theme %in% available_themes)) { - cat("Invalid theme selected. Available themes are:\n") - cat(paste("-", available_themes, collapse = "\n"), "\n\n") - theme_choice <- readline(prompt = "Please choose a valid theme: ") - theme <- match.arg(theme_choice, available_themes) + stop("Invalid theme selected. Available themes are: ", paste(available_themes, collapse = ", ")) } # Create a temporary Rmd file @@ -198,7 +150,7 @@ ctg_data_report <- function(ctg_data, footer_content <- if (!is.null(custom_footer)) { paste0('\n\n\n') } else { - '\n\n\n' + '\n\n\n' } # Write the Rmd content dynamically @@ -445,10 +397,10 @@ For any questions or further analysis requests, please contact the report author writeLines(rmd_content, temp_rmd) # Render the Rmd file to HTML -render(temp_rmd, output_file = output_file, output_dir = dirname(output_file)) +rmarkdown::render(temp_rmd, output_file = output_file, output_dir = dirname(output_file)) # Clean up the temporary file unlink(temp_rmd) -cat("Report successfully generated at:", normalizePath(output_file), "\n") +message("Report successfully generated at:", normalizePath(output_file), "\n") } diff --git a/R/hello.R b/R/hello.R index 240bd57..8e9d8c5 100644 --- a/R/hello.R +++ b/R/hello.R @@ -1,13 +1,13 @@ #' Print a Welcome Message #' -#' This function prints a welcome message for ClinTrialX. +#' This function returns a welcome message for ClinTrialX. #' #' @return A character string containing the welcome message. #' @export #' @examples #' hello() hello <- function() { - message <- "πŸ‘‹ Welcome to ClinTrialX!" - Encoding(message) <- "UTF-8" - print(message) + msg <- "Welcome to ClinTrialX!" + Encoding(msg) <- "UTF-8" + return(msg) # Return the message for further use } diff --git a/README.Rmd b/README.Rmd index 1edc9e4..6153c1d 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,12 +19,15 @@ knitr::opts_chunk$set( # `ClinTrialX` - [![R-CMD-check](https://github.com/ineelhere/clintrialx/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ineelhere/clintrialx/actions/workflows/R-CMD-check.yaml) [![License: -Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -[![pkgdown](https://img.shields.io/badge/pkgdown-docs-blue.svg)](https://ineelhere.github.io/clintrialx/) +Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://opensource.org/license/apache-2-0) +[![pkgdown](https://img.shields.io/badge/pkgdown-docs-blue.svg)](https://www.indraneelchakraborty.com/clintrialx/) [![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fineelhere%2Fclintrialx&label=Visitors&labelColor=%23f47373&countColor=%2337d67a&style=flat&labelStyle=upper)](https://github.com/ineelhere/clintrialx) +[![CRAN +status](https://www.r-pkg.org/badges/version/clintrialx)](https://CRAN.R-project.org/package=clintrialx) +[![CRAN +downloads](https://cranlogs.r-pkg.org/badges/clintrialx)](https://CRAN.R-project.org/package=clintrialx) [![Data Sources: ClinicalTrials.gov](https://img.shields.io/badge/Data_Sources-ClinicalTrials.gov-blue)](https://clinicaltrials.gov/data-api/api) @@ -44,9 +47,15 @@ available registries. Currently, it supports querying the ## Installation +Install the package from [CRAN](https://CRAN.R-project.org/package=clintrialx) with: +```r +install.packages("clintrialx") +``` You can install this package from [GitHub](https://github.com/ineelhere/clintrialx) with: +*you'll need the `devtools` package for this* + ``` r # install.packages("devtools") devtools::install_github("ineelhere/clintrialx") @@ -113,7 +122,7 @@ ctg_get_fields( ``` -#### Based on fileds - Bulk download +#### Based on fields - Bulk download Download all available data for your query. No limits! @@ -144,9 +153,12 @@ print(results) ``` ## Trial Data HTML Reports + *Currently works for data from ClinicalTrials.Gov* -Visit here for an exqample report - https://ineelhere.github.io/clintrialx/report.html +Visit here for an exqample report - + + ```{r example6, eval = FALSE} #first get the data in a R dataframe my_clinical_trial_data <- ctg_bulk_fetch(condition="cancer") @@ -163,8 +175,18 @@ ctg_data_report( custom_footer = "Proprietary report generated by SomeGreatOrg Inc." ) +# Generate a report with static plots and no data quality assessment +ctg_data_report( + ctg_data = my_clinical_trial_data, + title = "Quick Clinical Trial Overview", + include_data_quality = FALSE, + include_interactive_plots = FALSE +) + ``` -Check the path `reports/clinical_trials.html` on your local. It will have the html report file. + +Check the path `reports/clinical_trials.html` on your local. It will +have the html report file. Cool stuff - It also has the codes to the plots! @@ -180,13 +202,19 @@ version_info(source = "clinicaltrials.gov") ## Get Involved -πŸš€ **Ready to contribute?** Lets make`clintrialx` even better. -Check out the [contributing guidelines](https://github.com/ineelhere/clintrialx/blob/main/CONTRIBUTING.md) -to get started. +πŸš€ Ready to contribute? Let's make clintrialx even better! + +- Fork the [GitHub](https://github.com/ineelhere/clintrialx) repo. +- Check out your development branch from the dev branch. +- Do your work on a feature (ftr) branch. +- Raise a PR against the dev branch of the [clintrialx](https://github.com/ineelhere/clintrialx) repo. +- Sit back and [relax](https://www.youtube.com/watch?v=Uffjii1hXzU) while I review it! -πŸ’¬ **Questions or Feedback?** Feel free to open an issue on [GitHub Issues page](https://github.com/ineelhere/clintrialx/issues). +πŸ’¬ **Questions or Feedback?** Feel free to open an issue on [GitHub +Issues page](https://github.com/ineelhere/clintrialx/issues). -🌟 **Enjoying `clintrialx`?** Please consider giving it a star on [GitHub](https://github.com/ineelhere/clintrialx)! Your support helps this project -grow and improve. +🌟 **Enjoying `clintrialx`?** Please consider giving it a star on +[GitHub](https://github.com/ineelhere/clintrialx)! Your support helps +this project grow and improve. More updates to come. Happy coding! πŸŽ‰ diff --git a/README.md b/README.md index f2fb904..5706334 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,13 @@ [![R-CMD-check](https://github.com/ineelhere/clintrialx/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ineelhere/clintrialx/actions/workflows/R-CMD-check.yaml) [![License: -Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -[![pkgdown](https://img.shields.io/badge/pkgdown-docs-blue.svg)](https://ineelhere.github.io/clintrialx/) +Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://opensource.org/license/apache-2-0) +[![pkgdown](https://img.shields.io/badge/pkgdown-docs-blue.svg)](https://www.indraneelchakraborty.com/clintrialx/) [![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fineelhere%2Fclintrialx&label=Visitors&labelColor=%23f47373&countColor=%2337d67a&style=flat&labelStyle=upper)](https://github.com/ineelhere/clintrialx) +[![CRAN +status](https://www.r-pkg.org/badges/version/clintrialx)](https://CRAN.R-project.org/package=clintrialx) +[![CRAN +downloads](https://cranlogs.r-pkg.org/badges/clintrialx)](https://CRAN.R-project.org/package=clintrialx) [![Data Sources: ClinicalTrials.gov](https://img.shields.io/badge/Data_Sources-ClinicalTrials.gov-blue)](https://clinicaltrials.gov/data-api/api) @@ -29,9 +33,18 @@ available registries. Currently, it supports querying the ## Installation +Install the package from +[CRAN](https://CRAN.R-project.org/package=clintrialx) with: + +``` r +install.packages("clintrialx") +``` + You can install this package from [GitHub](https://github.com/ineelhere/clintrialx) with: +*you’ll need the `devtools` package for this* + ``` r # install.packages("devtools") devtools::install_github("ineelhere/clintrialx") @@ -95,7 +108,7 @@ ctg_get_fields( ) ``` -#### Based on fileds - Bulk download +#### Based on fields - Bulk download Download all available data for your query. No limits! @@ -130,7 +143,7 @@ print(results) *Currently works for data from ClinicalTrials.Gov* Visit here for an exqample report - - + ``` r #first get the data in a R dataframe @@ -147,6 +160,14 @@ ctg_data_report( include_interactive_plots = TRUE, custom_footer = "Proprietary report generated by SomeGreatOrg Inc." ) + +# Generate a report with static plots and no data quality assessment +ctg_data_report( + ctg_data = my_clinical_trial_data, + title = "Quick Clinical Trial Overview", + include_data_quality = FALSE, + include_interactive_plots = FALSE +) ``` Check the path `reports/clinical_trials.html` on your local. It will @@ -164,10 +185,15 @@ version_info(source = "clinicaltrials.gov") ## Get Involved -πŸš€ **Ready to contribute?** Lets make`clintrialx` even better. Check out -the [contributing -guidelines](https://github.com/ineelhere/clintrialx/blob/main/CONTRIBUTING.md) -to get started. +πŸš€ Ready to contribute? Let’s make clintrialx even better! + +- Fork the [GitHub](https://github.com/ineelhere/clintrialx) repo. +- Check out your development branch from the dev branch. +- Do your work on a feature (ftr) branch. +- Raise a PR against the dev branch of the + [clintrialx](https://github.com/ineelhere/clintrialx) repo. +- Sit back and [relax](https://www.youtube.com/watch?v=Uffjii1hXzU) + while I review it! πŸ’¬ **Questions or Feedback?** Feel free to open an issue on [GitHub Issues page](https://github.com/ineelhere/clintrialx/issues). diff --git a/_pkgdown.yml b/_pkgdown.yml index 8815635..12d5360 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,4 +1,4 @@ -url: http://ineelhere.github.io/clintrialx/ +url: http://www.indraneelchakraborty.com/clintrialx/ template: bootstrap: 5 diff --git a/clintrialx.Rproj b/clintrialx.Rproj index 497f8bf..e5c3f7c 100644 --- a/clintrialx.Rproj +++ b/clintrialx.Rproj @@ -18,3 +18,5 @@ StripTrailingWhitespace: Yes BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source +PackageCheckArgs: --as-cran +PackageRoxygenize: rd,collate,namespace,vignette diff --git a/man/aact_check_connection.Rd b/man/aact_check_connection.Rd index 002063e..4f05ad5 100644 --- a/man/aact_check_connection.Rd +++ b/man/aact_check_connection.Rd @@ -16,6 +16,7 @@ A data frame with distinct study types Check database connection } \examples{ +\donttest{ # Set environment variables for database credentials in .Renviron and load it # readRenviron(".Renviron") @@ -25,3 +26,4 @@ con <- aact_connection(Sys.getenv('user'), Sys.getenv('password')) # Check the connection aact_check_connection(con) } +} diff --git a/man/aact_connection.Rd b/man/aact_connection.Rd index 11c3e02..c5426e1 100644 --- a/man/aact_connection.Rd +++ b/man/aact_connection.Rd @@ -18,9 +18,11 @@ A connection object to the AACT database Connect to AACT PostgreSQL database } \examples{ +\donttest{ # Set environment variables for database credentials in .Renviron and load it # readRenviron(".Renviron") # Connect to the database con <- aact_connection(Sys.getenv('user'), Sys.getenv('password')) } +} diff --git a/man/aact_custom_query.Rd b/man/aact_custom_query.Rd index f4dfed5..05be731 100644 --- a/man/aact_custom_query.Rd +++ b/man/aact_custom_query.Rd @@ -13,12 +13,12 @@ aact_custom_query(con, query) } \value{ A data frame with the query results -Check database schema here - https://aact.ctti-clinicaltrials.org/documentation/aact_schema.png } \description{ Run a custom query } \examples{ +\donttest{ # Set environment variables for database credentials in .Renviron and load it # readRenviron(".Renviron") @@ -32,3 +32,4 @@ results <- aact_custom_query(con, query) # Print the results print(results) } +} diff --git a/man/ctg_bulk_fetch.Rd b/man/ctg_bulk_fetch.Rd index c1c9533..7ae7658 100644 --- a/man/ctg_bulk_fetch.Rd +++ b/man/ctg_bulk_fetch.Rd @@ -50,5 +50,7 @@ This function retrieves clinical trial data in bulk from the ClinicalTrials.gov specified parameters. It handles pagination and returns a combined dataset. } \examples{ +\donttest{ trials <- ctg_bulk_fetch(location="india") } +} diff --git a/man/ctg_data_report.Rd b/man/ctg_data_report.Rd index 09c5810..c62d15e 100644 --- a/man/ctg_data_report.Rd +++ b/man/ctg_data_report.Rd @@ -63,7 +63,7 @@ This function creates a detailed, visually appealing HTML report from clinical t It automates the process of data analysis and visualization, providing insights into various aspects of clinical trials such as study status, enrollment, duration, and funding sources. -Click here for an example report - \url{https://ineelhere.github.io/clintrialx/report.html}{report.html}. +Visit here for an example report - \url{https://www.indraneelchakraborty.com/clintrialx/report.html}. } \details{ The function performs these key steps: @@ -114,34 +114,6 @@ The function performs these key steps: } } -\examples{ -\dontrun{ -# Basic usage with default settings -ctg_data_report(my_clinical_trial_data) - -# Customized report with specific settings -ctg_data_report( - ctg_data = my_clinical_trial_data, - title = "Clinical Trials Analysis", - author = "Indra", - output_file = "reports/clinical_trials.html", - theme = "flatly", - color_palette = c("#4E79A7", "#F28E2B", "#E15759", "#76B7B2", "#59A14F", "#EDC948"), - include_data_quality = TRUE, - include_interactive_plots = TRUE, - custom_footer = "Proprietary report generated by SomeGreatOrg Inc." -) - -# Generate a report with static plots and no data quality assessment -ctg_data_report( - my_clinical_trial_data, - title = "Quick Clinical Trial Overview", - include_data_quality = FALSE, - include_interactive_plots = FALSE -) -} - -} \seealso{ -\url{https://ineelhere.github.io/clintrialx} for more information about the ClinTrialX package. +\url{https://www.indraneelchakraborty.com/clintrialx/} for more information about the ClinTrialX package. } diff --git a/man/hello.Rd b/man/hello.Rd index e1bc7e5..2c460a5 100644 --- a/man/hello.Rd +++ b/man/hello.Rd @@ -10,7 +10,7 @@ hello() A character string containing the welcome message. } \description{ -This function prints a welcome message for ClinTrialX. +This function returns a welcome message for ClinTrialX. } \examples{ hello() diff --git a/pkgdown/favicon/apple-touch-icon-120x120.png b/pkgdown/favicon/apple-touch-icon-120x120.png index edd5c40..0821bce 100644 Binary files a/pkgdown/favicon/apple-touch-icon-120x120.png and b/pkgdown/favicon/apple-touch-icon-120x120.png differ diff --git a/pkgdown/favicon/apple-touch-icon-152x152.png b/pkgdown/favicon/apple-touch-icon-152x152.png index bd09f89..3c8afce 100644 Binary files a/pkgdown/favicon/apple-touch-icon-152x152.png and b/pkgdown/favicon/apple-touch-icon-152x152.png differ diff --git a/pkgdown/favicon/apple-touch-icon-180x180.png b/pkgdown/favicon/apple-touch-icon-180x180.png index 5c41139..5ad0a97 100644 Binary files a/pkgdown/favicon/apple-touch-icon-180x180.png and b/pkgdown/favicon/apple-touch-icon-180x180.png differ diff --git a/pkgdown/favicon/apple-touch-icon-60x60.png b/pkgdown/favicon/apple-touch-icon-60x60.png index 2cb8dec..612cb14 100644 Binary files a/pkgdown/favicon/apple-touch-icon-60x60.png and b/pkgdown/favicon/apple-touch-icon-60x60.png differ diff --git a/pkgdown/favicon/apple-touch-icon-76x76.png b/pkgdown/favicon/apple-touch-icon-76x76.png index 7e5db17..e9ba0b4 100644 Binary files a/pkgdown/favicon/apple-touch-icon-76x76.png and b/pkgdown/favicon/apple-touch-icon-76x76.png differ diff --git a/pkgdown/favicon/apple-touch-icon.png b/pkgdown/favicon/apple-touch-icon.png index 9e9e15b..e51523b 100644 Binary files a/pkgdown/favicon/apple-touch-icon.png and b/pkgdown/favicon/apple-touch-icon.png differ diff --git a/pkgdown/favicon/favicon-16x16.png b/pkgdown/favicon/favicon-16x16.png index 5f8fc1c..0fe8507 100644 Binary files a/pkgdown/favicon/favicon-16x16.png and b/pkgdown/favicon/favicon-16x16.png differ diff --git a/pkgdown/favicon/favicon-32x32.png b/pkgdown/favicon/favicon-32x32.png index 8c48d4f..1addb65 100644 Binary files a/pkgdown/favicon/favicon-32x32.png and b/pkgdown/favicon/favicon-32x32.png differ diff --git a/renv.lock b/renv.lock index 7de2e2c..8b4cd81 100644 --- a/renv.lock +++ b/renv.lock @@ -52,6 +52,16 @@ ], "Hash": "cad6cf7f1d5f6e906700b9d3e718c796" }, + "base64enc": { + "Package": "base64enc", + "Version": "0.1-3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "543776ae6848fde2f48ff3816d0628bc" + }, "bit": { "Package": "bit", "Version": "4.0.5", @@ -76,6 +86,39 @@ ], "Hash": "9fe98599ca456d6552421db0d6772d8f" }, + "bslib": { + "Package": "bslib", + "Version": "0.7.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "base64enc", + "cachem", + "fastmap", + "grDevices", + "htmltools", + "jquerylib", + "jsonlite", + "lifecycle", + "memoise", + "mime", + "rlang", + "sass" + ], + "Hash": "8644cc53f43828f19133548195d7e59e" + }, + "cachem": { + "Package": "cachem", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "fastmap", + "rlang" + ], + "Hash": "cd9a672193789068eb5a2aad65a0dedf" + }, "cli": { "Package": "cli", "Version": "3.6.3", @@ -129,6 +172,17 @@ ], "Hash": "411ca2c03b1ce5f548345d2fc2685f7a" }, + "digest": { + "Package": "digest", + "Version": "0.6.36", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "utils" + ], + "Hash": "fd6824ad91ede64151e93af67df6376b" + }, "dplyr": { "Package": "dplyr", "Version": "1.1.4", @@ -152,6 +206,17 @@ ], "Hash": "fedd9d00c2944ff00a0e2696ccf048ec" }, + "evaluate": { + "Package": "evaluate", + "Version": "0.24.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "methods" + ], + "Hash": "a1066cbc05caee9a4bf6d90f194ff4da" + }, "fansi": { "Package": "fansi", "Version": "1.0.6", @@ -164,6 +229,36 @@ ], "Hash": "962174cf2aeb5b9eea581522286a911f" }, + "fastmap": { + "Package": "fastmap", + "Version": "1.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "aa5e1cd11c2d15497494c5292d7ffcc8" + }, + "fontawesome": { + "Package": "fontawesome", + "Version": "0.5.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "htmltools", + "rlang" + ], + "Hash": "c2efdd5f0bcd1ea861c2d4e2a883a67d" + }, + "fs": { + "Package": "fs", + "Version": "1.6.4", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "methods" + ], + "Hash": "15aeb8c27f5ea5161f9f6a641fafd93a" + }, "generics": { "Package": "generics", "Version": "0.1.3", @@ -186,6 +281,17 @@ ], "Hash": "e0b3a53876554bd45879e596cdb10a52" }, + "highr": { + "Package": "highr", + "Version": "0.11", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "xfun" + ], + "Hash": "d65ba49117ca223614f71b60d85b8ab7" + }, "hms": { "Package": "hms", "Version": "1.1.3", @@ -200,6 +306,22 @@ ], "Hash": "b59377caa7ed00fa41808342002138f9" }, + "htmltools": { + "Package": "htmltools", + "Version": "0.5.8.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "base64enc", + "digest", + "fastmap", + "grDevices", + "rlang", + "utils" + ], + "Hash": "81d371a9cc60640e74e4ab6ac46dcedc" + }, "httr": { "Package": "httr", "Version": "1.4.7", @@ -215,6 +337,16 @@ ], "Hash": "ac107251d9d9fd72f0ca8049988f1d7f" }, + "jquerylib": { + "Package": "jquerylib", + "Version": "0.1.4", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "htmltools" + ], + "Hash": "5aab57a3bd297eee1c1d862735972182" + }, "jsonlite": { "Package": "jsonlite", "Version": "1.8.8", @@ -225,6 +357,22 @@ ], "Hash": "e1b9c55281c5adc4dd113652d9e26768" }, + "knitr": { + "Package": "knitr", + "Version": "1.48", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "evaluate", + "highr", + "methods", + "tools", + "xfun", + "yaml" + ], + "Hash": "acf380f300c721da9fde7df115a5f86f" + }, "lifecycle": { "Package": "lifecycle", "Version": "1.0.4", @@ -261,6 +409,17 @@ ], "Hash": "7ce2733a9826b3aeb1775d56fd305472" }, + "memoise": { + "Package": "memoise", + "Version": "2.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "cachem", + "rlang" + ], + "Hash": "e2817ccf4a065c5d9d7f2cfbe7c1d78c" + }, "mime": { "Package": "mime", "Version": "0.12", @@ -332,6 +491,16 @@ ], "Hash": "f4625e061cb2865f111b47ff163a5ca6" }, + "rappdirs": { + "Package": "rappdirs", + "Version": "0.3.3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "5e3c5dc0b071b21fa128676560dbe94d" + }, "readr": { "Package": "readr", "Version": "2.1.5", @@ -376,6 +545,43 @@ ], "Hash": "3eec01f8b1dee337674b2e34ab1f9bc1" }, + "rmarkdown": { + "Package": "rmarkdown", + "Version": "2.27", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "bslib", + "evaluate", + "fontawesome", + "htmltools", + "jquerylib", + "jsonlite", + "knitr", + "methods", + "tinytex", + "tools", + "utils", + "xfun", + "yaml" + ], + "Hash": "27f9502e1cdbfa195f94e03b0f517484" + }, + "sass": { + "Package": "sass", + "Version": "0.4.9", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R6", + "fs", + "htmltools", + "rappdirs", + "rlang" + ], + "Hash": "d53dbfddf695303ea4ad66f86e99b95d" + }, "sys": { "Package": "sys", "Version": "3.4.2", @@ -429,6 +635,16 @@ ], "Hash": "c5f3c201b931cd6474d17d8700ccb1c8" }, + "tinytex": { + "Package": "tinytex", + "Version": "0.52", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "xfun" + ], + "Hash": "cfbad971a71f0e27cec22e544a08bc3b" + }, "tzdb": { "Package": "tzdb", "Version": "0.4.0", @@ -501,6 +717,26 @@ "graphics" ], "Hash": "d31b6c62c10dcf11ec530ca6b0dd5d35" + }, + "xfun": { + "Package": "xfun", + "Version": "0.47", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "grDevices", + "stats", + "tools" + ], + "Hash": "36ab21660e2d095fef0d83f689e0477c" + }, + "yaml": { + "Package": "yaml", + "Version": "2.3.9", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "9cb28d11799d93c953f852083d55ee9e" } } } diff --git a/tests/testthat/test-aact_query.R b/tests/testthat/test-aact_query.R index fec18cc..f886ed5 100644 --- a/tests/testthat/test-aact_query.R +++ b/tests/testthat/test-aact_query.R @@ -1,9 +1,16 @@ # Test for aact_connection function test_that("aact_connection function works correctly", { + skip_on_cran() # Skip on CRAN + # Mock credentials user <- Sys.getenv('user') password <- Sys.getenv('password') + # Skip if credentials are not set + if (user == "" || password == "") { + skip("Database credentials are not set in the environment.") + } + # Test connection con <- aact_connection(user, password) @@ -16,10 +23,17 @@ test_that("aact_connection function works correctly", { # Test for aact_check_connection function test_that("aact_check_connection function works correctly", { + skip_on_cran() # Skip on CRAN + # Mock credentials user <- Sys.getenv('user') password <- Sys.getenv('password') + # Skip if credentials are not set + if (user == "" || password == "") { + skip("Database credentials are not set in the environment.") + } + # Establish connection con <- aact_connection(user, password) @@ -38,10 +52,17 @@ test_that("aact_check_connection function works correctly", { # Test for aact_custom_query function test_that("aact_custom_query function works correctly", { + skip_on_cran() # Skip on CRAN + # Mock credentials user <- Sys.getenv('user') password <- Sys.getenv('password') + # Skip if credentials are not set + if (user == "" || password == "") { + skip("Database credentials are not set in the environment.") + } + # Establish connection con <- aact_connection(user, password) diff --git a/tests/testthat/test-hello.R b/tests/testthat/test-hello.R index b839815..c349858 100644 --- a/tests/testthat/test-hello.R +++ b/tests/testthat/test-hello.R @@ -3,5 +3,5 @@ library(clintrialx) test_that("hello function works correctly", { output <- hello() - expect_equal(output, "πŸ‘‹ Welcome to ClinTrialX!") + expect_equal(output, "Welcome to ClinTrialX!") }) diff --git a/vignettes/usecase-doc.R b/vignettes/usecase-doc.R new file mode 100644 index 0000000..9a3468a --- /dev/null +++ b/vignettes/usecase-doc.R @@ -0,0 +1,74 @@ +## ----eval=FALSE--------------------------------------------------------------- +# # Load required libraries +# invisible(suppressPackageStartupMessages({ +# library(clintrialx) # For fetching clinical trial data +# library(ggplot2) # For data visualization +# library(plotly) # For interactive plots +# library(dplyr) # For data manipulation +# library(lubridate) # For date handling +# })) + +## ----eval=FALSE--------------------------------------------------------------- +# # Fetch cancer study data in India +# df <- ctg_bulk_fetch(condition = "cancer", location = "India") + +## ----eval=FALSE--------------------------------------------------------------- +# # Create a table of study statuses +# status_counts <- table(df$`Study Status`) +# +# # Convert the table to a data frame +# status_df <- data.frame(status = names(status_counts), count = as.numeric(status_counts)) +# +# # Generate the bar plot +# ggplotly(ggplot(status_df, aes(x = reorder(status, -count), y = count)) + +# geom_bar(stat = "identity", fill = "orange") + +# theme_minimal() + +# labs(title = "Distribution of Study Statuses", +# x = "Study Status", +# y = "Count") + +# theme(axis.text.x = element_text(angle = 45, hjust = 1)) + +# geom_text(aes(label = count), vjust = -0.5)) + +## ----eval=FALSE--------------------------------------------------------------- +# # Create an interactive box plot of enrollment by study phase +# ggplotly(ggplot(df, aes(x = Phases, y = Enrollment)) + +# geom_boxplot(fill = "lightblue", outlier.colour = "red", outlier.shape = 1) + +# geom_jitter(color = "darkblue", size = 0.5, alpha = 0.5, width = 0.2) + +# theme_minimal(base_size = 14) + +# labs(title = "Enrollment by Study Phase", +# x = "Study Phase", +# y = "Enrollment") + +# theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 12), +# plot.title = element_text(hjust = 0.5))) + +## ----eval=FALSE--------------------------------------------------------------- +# # Convert date strings to Date objects +# df$start_date <- as.Date(df$`Start Date`, format = "%Y-%m-%d") +# df$completion_date <- as.Date(df$`Completion Date`, format = "%Y-%m-%d") +# +# # Create a scatter plot with a horizontal line at 2024 +# ggplot(df, aes(x = start_date, y = completion_date, color = `Study Status`)) + +# geom_point(alpha = 0.6) + +# geom_hline(yintercept = as.Date("2024-01-01"), linetype = "dashed", color = "blue") + +# theme_minimal() + +# labs(title = "Study Duration Timeline", +# x = "Start Date", +# y = "Completion Date") + +# scale_color_brewer(palette = "Set1") + +## ----eval=FALSE--------------------------------------------------------------- +# # Summarize and plot funding sources by study type +# df_summary <- df %>% +# count(`Funder Type`, `Study Type`) %>% +# group_by(`Funder Type`) %>% +# mutate(prop = n / sum(n)) +# +# ggplotly(ggplot(df_summary, aes(x = `Funder Type`, y = prop, fill = `Study Type`)) + +# geom_bar(stat = "identity", position = "dodge") + +# theme_minimal() + +# labs(title = "Funding Sources and Study Types", +# x = "Funder Type", +# y = "Proportion") + +# scale_fill_brewer(palette = "Set2") + +# theme(axis.text.x = element_text(angle = 45, hjust = 1))) + diff --git a/vignettes/usecase-doc.Rmd b/vignettes/usecase-doc.Rmd index 40e303d..1d76b12 100644 --- a/vignettes/usecase-doc.Rmd +++ b/vignettes/usecase-doc.Rmd @@ -2,12 +2,11 @@ title: "Exploring Clinical Trial Data with clintrialx" author: "Indraneel Chakraborty" date: "`r Sys.Date()`" -output: - html_document: - theme: cerulean - highlight: tango - toc: true - toc_float: true +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Exploring Clinical Trial Data with clintrialx} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} --- ## Introduction @@ -18,7 +17,7 @@ Welcome to the `clintrialx` vignette! This package simplifies the process of fet To start, load the necessary libraries. We use `suppressPackageStartupMessages` to keep the output clean: -```{r} +```{r, eval=FALSE} # Load required libraries invisible(suppressPackageStartupMessages({ library(clintrialx) # For fetching clinical trial data @@ -33,16 +32,16 @@ invisible(suppressPackageStartupMessages({ Retrieve clinical trial data related to cancer studies in India using the `ctg_bulk_fetch` function: -```{r} +```{r, eval=FALSE} # Fetch cancer study data in India df <- ctg_bulk_fetch(condition = "cancer", location = "India") ``` -## Visualizing Study Status Distribution +## Visualizing Study Status Distribution Understand the distribution of study statuses by creating a bar plot: -```{r} +```{r, eval=FALSE} # Create a table of study statuses status_counts <- table(df$`Study Status`) @@ -60,13 +59,15 @@ ggplotly(ggplot(status_df, aes(x = reorder(status, -count), y = count)) + geom_text(aes(label = count), vjust = -0.5)) ``` +![image](https://github.com/user-attachments/assets/633ed6a3-7fe9-4044-92c4-4ec4c26f4cf6) + This plot provides an overview of the number of studies in each status category. πŸ“‰ -## Analyzing Enrollment by Study Phase +## Analyzing Enrollment by Study Phase Compare enrollment numbers across different study phases using an interactive box plot: -```{r} +```{r, eval=FALSE} # Create an interactive box plot of enrollment by study phase ggplotly(ggplot(df, aes(x = Phases, y = Enrollment)) + geom_boxplot(fill = "lightblue", outlier.colour = "red", outlier.shape = 1) + @@ -79,13 +80,15 @@ ggplotly(ggplot(df, aes(x = Phases, y = Enrollment)) + plot.title = element_text(hjust = 0.5))) ``` +![image](https://github.com/user-attachments/assets/3aef0bff-792b-4689-a80e-ef56b3074765) + This interactive plot allows you to explore enrollment numbers across different phases and identify trends. πŸ” -## Visualizing Study Duration Timeline +## Visualizing Study Duration Timeline Examine the timeline of studies with a scatter plot: -```{r} +```{r, eval=FALSE} # Convert date strings to Date objects df$start_date <- as.Date(df$`Start Date`, format = "%Y-%m-%d") df$completion_date <- as.Date(df$`Completion Date`, format = "%Y-%m-%d") @@ -101,13 +104,15 @@ ggplot(df, aes(x = start_date, y = completion_date, color = `Study Status`)) + scale_color_brewer(palette = "Set1") ``` +![image](https://github.com/user-attachments/assets/353f12d2-1a08-4e30-879b-bbac1d5d9651) + This scatter plot helps visualize study durations and their statuses, providing insights into timelines. ⏳ ## Analyzing Funding Sources and Study Types Examine the relationship between funding sources and study types using a stacked bar plot: -```{r} +```{r, eval=FALSE} # Summarize and plot funding sources by study type df_summary <- df %>% count(`Funder Type`, `Study Type`) %>% @@ -124,8 +129,10 @@ ggplotly(ggplot(df_summary, aes(x = `Funder Type`, y = prop, fill = `Study Type` theme(axis.text.x = element_text(angle = 45, hjust = 1))) ``` +![image](https://github.com/user-attachments/assets/ec71369c-491f-4b26-9b65-cbde1f4e99f0) + This plot uncovers patterns in how different funders support various study types. πŸ’‘ -## Conclusion +## Conclusion Using the `clintrialx` package along with visualization tools like `ggplot2` and `plotly`, you can extract valuable insights from clinical trial data. This vignette has illustrated techniques for analyzing cancer clinical trials in India, and these methods are adaptable to other datasets fetched with `clintrialx`. Happy analyzing! 😊