library(devtools) library(dplyr) library(ggplot2) library(tidyr) library(ggrepel) library(lubridate) library(forcats) library(RColorBrewer)
outputFolder <- params$outputFolder minCellCount <- params$minCellCount cohortId <- params$cohortId cohortName <- params$cohortName databaseId <- params$databaseId time_window_for_interventions <- 365 cancerCohortDataTable <- getCancerDataSet(params$cohortDatabaseSchema, params$cohortId, params$connection) writeLines(paste("outputFolder = ", outputFolder, "\n", "minCellCount = ", minCellCount, "\n", "cohortId = ", cohortId, "\n", "cohortName = ", cohortName, "\n", "databaseId = ", databaseId, "\n", "time_window_for_interventions = ", time_window_for_interventions))
cancerSpecificVectors <- getVectorsForSpecificCancer(cohortId) cancerSpecificVectors #function to produce interventions per patient augmentedCancerDataSet <- augmentCancerDataSet(cancerCohortDataTable = cancerCohortDataTable, interventionsVector = cancerSpecificVectors$interventions, drugVector = cancerSpecificVectors$drugs_vector, timeWindowForInterventions = time_window_for_interventions) #clear out previous run data if (file.exists(outputFolder)) { unlink(outputFolder, recursive = TRUE) } else { dir.create(outputFolder, recursive = TRUE) }
# Percent distribution of intervention types, by year plot <- examineInterventionsPerYear(augmentedCancerDataSet, cohortName, databaseId, outputFolder, minCellCount) plot
#plot 1 #counting distinct diagnoses by year plot <- examineDxPerYear(augmentedCancerDataSet, cohortName, databaseId, outputFolder, minCellCount) plot
#plot 2 #average age at diagnosis by year plot <- examineAvgAgeAtDx(augmentedCancerDataSet, cohortName, databaseId, outputFolder, minCellCount) plot
#average drug classes by year plot <- examineAvgNumDrugsByTreatmentClass(augmentedCancerDataSet, cohortName, databaseId, outputFolder, minCellCount) plot
## All the below plots are based on the index date of each patient and the earliest drug intervention for irrespective of the year the drug (intervention) was taken.
#plot 11 - ADT plot #Endocrine distribution in the adjuvant setting #selecting for patients who are labeled as having adjuvant adjuvant_endrocrine_records <- cancerCohortDataTable %>% filter(neoadjuvant == '0', generic_drug_name %in% cancerSpecificVectors$endocrine_drugs) %>% distinct(person_id, dx_year, generic_drug_name, intervention_date) %>% arrange(dx_year, person_id, intervention_date) %>% group_by(person_id) %>% slice(1) plot <- examinePercentEndocrineForAdjuvantTherapy(adjuvant_endrocrine_records, cohortName, databaseId, outputFolder, minCellCount) plot
#Endocrine distribution in the neoadjuvant setting neoadjuvant_endrocrine_records <- cancerCohortDataTable %>% filter(neoadjuvant == '1', generic_drug_name %in% cancerSpecificVectors$endocrine_drugs) %>% distinct(person_id, dx_year, generic_drug_name, intervention_date) %>% arrange(dx_year, person_id, intervention_date) %>% group_by(person_id) %>% slice(1) plot <- examinePercentEndocrineForNeoAdjuvantTherapy(neoadjuvant_endrocrine_records, cohortName, databaseId, outputFolder, minCellCount) plot
#first line chemotherapy in the adjuvant setting adjuvant_chemo_records <- cancerCohortDataTable %>% filter(neoadjuvant == '0', generic_drug_name %in% cancerSpecificVectors$chemo_drugs) %>% distinct(person_id, dx_year, generic_drug_name, intervention_date) %>% arrange(dx_year, person_id, intervention_date) %>% group_by(person_id) %>% slice(1) plot <- examinePercentChemoForAdjuvantTherapy(adjuvant_chemo_records, cohortName, databaseId, outputFolder, minCellCount) plot
#first line chemotherapy in the neoadjuvant setting neoadjuvant_chemo_records <- cancerCohortDataTable %>% filter(neoadjuvant == '1', generic_drug_name %in% cancerSpecificVectors$chemo_drugs) %>% distinct(person_id, dx_year, generic_drug_name, intervention_date) %>% arrange(dx_year, person_id, intervention_date) %>% group_by(person_id) %>% slice(1) plot <- examinePercentChemoForNeoAdjuvantTherapy(neoadjuvant_chemo_records, cohortName, databaseId, outputFolder, minCellCount) plot
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.