-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.qmd
172 lines (142 loc) · 5.03 KB
/
index.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
---
title: "Dashboarding with Quarto"
author: "Joshua J. Cook, Kirk Paul Lafler"
format:
dashboard:
theme: united
scrolling: true
logo: images/logo.png
nav-buttons:
- website
- icon: person-raised-hand
href: https://joshua-j-cook-portfolios.netlify.app/
- li
- icon: linkedin
href: https://www.linkedin.com/in/KirkPaulLafler/
- github
embed-resources: true
---
```{r}
#| include: false
packages <- c("tidyverse", "gt", "quarto")
if (any(!sapply(packages, requireNamespace, quietly = TRUE))) {
install.packages(packages[!sapply(packages, requireNamespace, quietly = TRUE)])
}
library(tidyverse)
library(RColorBrewer)
library(plotly)
library(gt)
library(quarto)
clinical_trials_fl <- readRDS("query_results_clean_final.rds")
str(clinical_trials_fl)
clinical_trials_fl %>%
select(nct_id, overall_status)
clinical_trials_fl_completed <- clinical_trials_fl %>%
filter(overall_status == "Completed") %>%
summarise(total_unique_completed = n_distinct(nct_id)) %>%
pull(1)
clinical_trials_fl_recruiting <- clinical_trials_fl %>%
filter(overall_status == "Recruiting") %>%
summarise(total_unique_completed = n_distinct(nct_id)) %>%
pull(1)
clinical_trials_fl_terminated <- clinical_trials_fl %>%
filter(overall_status == "Terminated") %>%
summarise(total_unique_completed = n_distinct(nct_id)) %>%
pull(1)
unique_study_types <- unique(clinical_trials_fl$study_type)
```
## Row 1 - Value Boxes
```{r}
#| content: valuebox
#| title: "Total Trials Completed"
list(
icon = "person-check-fill",
color = "success",
value = clinical_trials_fl_completed
)
```
```{r}
#| content: valuebox
#| title: "Total Trials Recruiting"
list(
icon = "person-fill-add",
color = "warning",
value = clinical_trials_fl_recruiting
)
```
```{r}
#| content: valuebox
#| title: "Total Trials Terminated"
list(
icon = "person-fill-x",
color = "danger",
value = clinical_trials_fl_terminated
)
```
## Row 2 - Big Line Plot
::: {.card title="Annual Clinical Trial Completion in Florida"}
```{r}
#| title: "Annual Clinical Trial Completion in Florida"
#| padding: 10px
clinical_trials_fl_yearly_summary <- clinical_trials_fl %>%
mutate(year = year(completion_date)) %>%
group_by(year) %>%
summarise(count = n_distinct(nct_id)) %>%
filter(year >= 2014 & year <= 2023)
# Extract the 7th color from the "Oranges" palette
oranges_palette <- brewer.pal(8, "Oranges")
dark_orange <- oranges_palette[7]
# Line chart
gg <- ggplot(clinical_trials_fl_yearly_summary, aes(x = year, y = count)) +
geom_line(color = dark_orange, size = 1) + # Specify the color and size of the line
geom_point(color = dark_orange, size = 2) + # Specify the color and size of the points
scale_x_continuous(breaks = 2014:2023) + # Ensure all years are shown
labs(x = "Year",
y = "Successfully Completed Clinical Trials") +
theme_minimal() # Use a minimal theme for aesthetics
# Convert the ggplot object to a plotly object
ggplotly(gg)
```
These figures are only for the last 10 years. It is also important to consider the dramatic regulatory changes that occured in 2004/2005, and then again in 2015/2017, which potentially led to major shifts in registration and results submission compliance for ClinicalTrials.gov. <https://aact.ctti-clinicaltrials.org/points_to_consider/>
:::
## Row 3 - Two small bar and pie plots
```{r}
#| title: "Phases of Clinical Trials Completed in Florida"
#| padding: 10px
clinical_trials_fl_phase_summary <- clinical_trials_fl %>%
distinct(nct_id, .keep_all = TRUE) %>% # Keep only unique NCT_IDs
count(phase) # Count the number of NCT_IDs for each phase
clinical_trials_fl_phase_summary <- clinical_trials_fl_phase_summary %>%
mutate(across(where(is.character), ~na_if(., "Not Applicable")))
# Bar chart; ggplotly() didn't work because of scales, reverted to full plotly
plot_ly(data = clinical_trials_fl_phase_summary,
x = ~phase,
y = ~n,
type = 'bar',
color = ~phase,
colors = "Oranges") %>%
layout(xaxis = list(title = "Phase"),
yaxis = list(title = "Successfully Completed Clinical Trials"))
```
```{r}
#| title: "Top 10 Conditions of Clinical Trials Completed in Florida"
#| padding: 10px
clinical_trials_fl_condition_summary <- clinical_trials_fl %>%
group_by(condition_name) %>%
summarise(n = n_distinct(nct_id)) %>%
ungroup() %>%
arrange(desc(n)) %>%
top_n(10, n) # Adjust this to include more or fewer conditions
# 2. Create a pie chart; same as above
plot_ly(clinical_trials_fl_condition_summary,
labels = ~condition_name,
values = ~n,
type = 'pie',
textinfo = 'label+percent',
marker = list(colors = RColorBrewer::brewer.pal(n = 8, name = "Oranges")),
hole = 0.0) %>%
layout(title = 'Condition Distribution in Clinical Trials',
showlegend = TRUE,
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
```