Skip to content

Commit

Permalink
[CRAN-MOD] modifications for CRAN pretests
Browse files Browse the repository at this point in the history
  • Loading branch information
ineelhere committed Aug 22, 2024
1 parent 82c2c27 commit 6ddb1e4
Show file tree
Hide file tree
Showing 15 changed files with 180 additions and 28 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
^pkgdown$
^\.github$
^README\.Rmd$
^CODE_OF_CONDUCT\.md$
^logo\.png$
30 changes: 24 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
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 with R Programming
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 <hello.indraneel@gmail.com>
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. Also, you can generate html reports based on the data obtained from the sources!
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 CTTI AACT database with R, supporting pagination and bulk downloads. Also, you can generate HTML reports based on the data obtained from the sources!
License: Apache License 2.0 | file LICENSE
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
Suggests:
knitr
VignetteBuilder: knitr
RoxygenNote: 7.3.2
URL: http://ineelhere.github.io/clintrialx/
URL: http://www.indraneelchakraborty.com/clintrialx/
ExtraLicense: LICENSE
ExtraFiles: CODE_OF_CONDUCT.md, logo.png
33 changes: 32 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ knitr::opts_chunk$set(
[![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/)
[![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)

[![Data Sources:
Expand Down Expand Up @@ -146,7 +146,7 @@ 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 - https://www.indraneelchakraborty.com/clintrialx/report.html
```{r example6, eval = FALSE}
#first get the data in a R dataframe
my_clinical_trial_data <- ctg_bulk_fetch(condition="cancer")
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![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/)
[![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)

[![Data Sources:
Expand Down Expand Up @@ -130,7 +130,7 @@ print(results)
*Currently works for data from ClinicalTrials.Gov*

Visit here for an exqample report -
<https://ineelhere.github.io/clintrialx/report.html>
<https://www.indraneelchakraborty.com/clintrialx/report.html>

``` r
#first get the data in a R dataframe
Expand Down
2 changes: 1 addition & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
url: http://ineelhere.github.io/clintrialx/
url: http://www.indraneelchakraborty.com/clintrialx/

template:
bootstrap: 5
Expand Down
2 changes: 2 additions & 0 deletions clintrialx.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageCheckArgs: --as-cran
PackageRoxygenize: rd,collate,namespace,vignette
2 changes: 2 additions & 0 deletions man/aact_check_connection.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/aact_connection.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/aact_custom_query.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/ctg_data_report.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions tests/testthat/test-aact_query.R
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-hello.R
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
})
74 changes: 74 additions & 0 deletions vignettes/usecase-doc.R
Original file line number Diff line number Diff line change
@@ -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)))

23 changes: 11 additions & 12 deletions vignettes/usecase-doc.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -33,7 +32,7 @@ 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")
```
Expand All @@ -42,7 +41,7 @@ df <- ctg_bulk_fetch(condition = "cancer", location = "India")

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`)
Expand All @@ -66,7 +65,7 @@ This plot provides an overview of the number of studies in each status category.

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) +
Expand All @@ -85,7 +84,7 @@ This interactive plot allows you to explore enrollment numbers across different

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")
Expand All @@ -107,7 +106,7 @@ This scatter plot helps visualize study durations and their statuses, providing

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`) %>%
Expand Down

0 comments on commit 6ddb1e4

Please sign in to comment.