## ----style, echo = FALSE, results = 'asis'------------------------------------
BiocStyle::markdown()

## ----load-data----------------------------------------------------------------
library("curatedBreastData")
#load up datasets that are in S4 expressionSet format.
#clinical data from master clinicalTable already linked to each sample
#in these ExpressionSets in the phenoData slot.
curatedBreastDataExprSetList <- getCuratedBreastDataExprSetList(test=TRUE);

## ----view-clinical------------------------------------------------------------
#check out the clinical data for dataset 1
#first look at the GEO study name
names(curatedBreastDataExprSetList)[1]
#only take the first 3 patients for sake of printing to screen
#look at first 10 clinical variables
head(pData(curatedBreastDataExprSetList[[1]])[c(1:3), c(1:10)])

## ----post-process-list--------------------------------------------------------
#process only the first two datasets to avoid a long-running example:
#take top 5000 genes by variance from each dataset.
proc_curatedBreastDataExprSetList <- processExpressionSetList(exprSetList=curatedBreastDataExprSetList[1:2], outputFileDirectory = tempdir(), numTopVarGenes=5000)

## ----view-treatment-----------------------------------------------------------
#load up master clinical data table
clinicalData <- getClinicalData(test=TRUE)
#look at some of the clinical variable name definitions
clinicalData$clinicalVarDef[c(1:2),]
#Check out the treatment information.
#just do first three patients
head(clinicalData$clinicalTable)[c(1:3),
                                 c(112:ncol(clinicalData$clinicalTable))]
#how many had chemotherapy?
numChemoPatients <- length(which(
  clinicalData$clinicalTable$chemotherapyClass==1))
#around 1500 had chemotherapy
numChemoPatients
#which patients specifically had a taxane chemotherapy?
numChemoTaxane <- length(which(clinicalData$clinicalTable$taxane==1))
numChemoTaxane

## ----view-adjuvant------------------------------------------------------------
#how many had adjuvant therapy?
numAdjPatients <- length(which(
  clinicalData$clinicalTable$neoadjuvant_or_adjuvant=="adj"))
#over a 1000 had (documented) adjuvant therapy
numAdjPatients 

## ----view-pdata---------------------------------------------------------------
# Load the pre-concatenated pData dataset
data(curatedBreastData_pData)

# View its dimensions and structure
dim(curatedBreastData_pData)
head(curatedBreastData_pData)[1:5, 1:5]

## ----view-survival-and-session------------------------------------------------
#how many patients have non-NA OS binary data?
length(which(!is.na(clinicalData$clinicalTable$OS)))
#how many have OS data in the more granular form of months until OS? 
#this variable includes studies that had a cieling for tracking OS
length(which(!is.na(clinicalData$clinicalTable$OS_months_or_MIN_months_of_OS)))
#how many patients have OS information that is definitively 
#followed up until their death (details on how studies collect OS data can be surprising!)
length(which(!is.na(clinicalData$clinicalTable$OS_up_until_death)))

#finish up with sessionInfo
sessionInfo()

