CoreGx

This package provides a foundation for the PharmacoGx, RadioGx and ToxicoGx packages. It is not intended for standalone use, only as a dependency for the aforementioned software. Its' existence allows abstracting generic definitions, method definitions and class structures common to all three of the Gx suite packages.

Importing and Using CoreGx

Load the pacakge:

library(CoreGx)
library(Biobase)
library(SummarizedExperiment)

The CoreSet Class

The CoreSet class is intended as a general purpose data structure for storing multiomic treatment response data. Extensions of this class have been customized for their respective fields of study. For example, the PharmacoSet class inherits form the CoreSet and is specialized for storing and analyzing drug sensitivity and perturbation experiments on cancer cell lines together with associated multiomic data for each sample treatment. The RadioSet class serves a role similar to the PharmacoSet with radiation instead of drug treaments. Finally, the ToxicoSet class is used to store toxicity data for healthy human and rat hepatocytes along with the associated multiomic profile for each treatment.

getClass("CoreSet")
## Class "CoreSet" [package "CoreGx"]
## 
## Slots:
##                                                                               
## Name:         annotation molecularProfiles              cell       datasetType
## Class:              list              list        data.frame         character
##                                                             
## Name:        sensitivity      perturbation          curation
## Class:              list              list              list

The annotation slot holds the CoreSet name, the original constructor call, and a range of metadata about the R session in which the constructor was called. This allows easy comparison of CoreSet versions across time and ensures the code used to generate a CoreSet is documented and reproducible.

The molecularProfiles slot contains a list of SummarizedExperiment objects for each multi-omic molecular datatype available for a given experiment. Within the SummarizedExperiments are feature and sample annotations for each data type.

The cell slot contains a data.frame with annotations for cell lines used in the sensitivty and/or perturbation slots.

The datasetType slot contains a character vector indicating the experiment type the CoreSet contains.

The sensitivty slot contains a list of raw, curated and meta data for sensitivity experiments.

The perturbation slot contains a list of raw, curated and meta data for perturbation experiments.

The curation slot contains a list of ground truth curations sample identifiers such as cell line names/ids, tissue names/ids, drug names/ids, etc. This slot is to assist in curating across experiment and molecular profile slots to esnure consistent nomenclature.

The class provides a set of standardized accessor methods which allow easy curation, annotation and retrieval of data associated with a specfic treatment response experiment. All accessors are implemented as generics to allow new methods to be defined on classes inheriting from the CoreSet.

methods(class="CoreSet")
##  [1] cellInfo                cellInfo<-              cellNames              
##  [4] cellNames<-             dateCreated             fNames                 
##  [7] fNames<-                featureInfo             featureInfo<-          
## [10] mDataNames              molecularProfiles       molecularProfiles<-    
## [13] molecularProfilesSlot   molecularProfilesSlot<- name                   
## [16] pertNumber              pertNumber<-            phenoInfo              
## [19] phenoInfo<-             sensNumber              sensNumber<-           
## [22] sensitivityInfo         sensitivityInfo<-       sensitivityMeasures    
## [25] sensitivityProfiles     sensitivityProfiles<-   show                   
## see '?methods' for accessing help and source code

We have provided a sample CoreSet in this package. In the below code we load the example cSet and demonstrate a few of the accessor methods.

data(clevelandSmall_cSet)
clevelandSmall_cSet
## Name:  Cleveland 
## Date Created:  Wed Oct 25 17:38:42 2017 
## Number of cell lines:  10 
## RNA: 
##  Dim:  1000 9 
## RNASeq: 
##  Dim:  1000 9 
## Drug pertubation: 
##  Please look at pertNumber(cSet) to determine number of experiments for each drug-cell combination.
## Drug sensitivity: 
##  Number of Experiments:  10 
##  Please look at sensNumber(cSet) to determine number of experiments for each drug-cell combination.

Access specific molecular profiles:

mProf <- molecularProfiles(clevelandSmall_cSet, "rna")
mProf[seq_len(5), seq_len(5)]
##                 NIECE_P_NCLE_RNA3_HG-U133_PLUS_2_G10_296152
## ENSG00000000003                                   10.280970
## ENSG00000000005                                    3.647436
## ENSG00000000419                                   11.883769
## ENSG00000000457                                    7.515721
## ENSG00000000460                                    7.808139
##                 GILDS_P_NCLE_RNA11_REDO_HG-U133_PLUS_2_G02_587654
## ENSG00000000003                                         10.304971
## ENSG00000000005                                          4.895494
## ENSG00000000419                                         11.865191
## ENSG00000000457                                          7.187144
## ENSG00000000460                                          7.789921
##                 BUNDS_P_NCLE_RNA5_HG-U133_PLUS_2_B11_419860
## ENSG00000000003                                    9.596987
## ENSG00000000005                                    3.793174
## ENSG00000000419                                   12.498285
## ENSG00000000457                                    8.076655
## ENSG00000000460                                    8.456691
##                 SILOS_P_NCLE_RNA9_HG-U133_PLUS_2_A04_523474
## ENSG00000000003                                    8.620860
## ENSG00000000005                                    3.674918
## ENSG00000000419                                   11.674671
## ENSG00000000457                                    6.790332
## ENSG00000000460                                    6.663846
##                 WATCH_P_NCLE_RNA8_HG-U133_PLUS_2_B04_474582
## ENSG00000000003                                    9.866551
## ENSG00000000005                                    3.748959
## ENSG00000000419                                   12.228260
## ENSG00000000457                                    7.292420
## ENSG00000000460                                    8.869378

Access cell line curations:

cInfo <- cellInfo(clevelandSmall_cSet)
cInfo[seq_len(5), seq_len(5)]
##              cellid          tissueid CellLine       Primarysite     Histology
## SK-N-FI     SK-N-FI autonomic_ganglia    SKNFI autonomic_ganglia neuroblastoma
## IMR-32       IMR-32 autonomic_ganglia    IMR32 autonomic_ganglia neuroblastoma
## SK-N-AS     SK-N-AS autonomic_ganglia    SKNAS autonomic_ganglia neuroblastoma
## CHP-212     CHP-212 autonomic_ganglia   CHP212 autonomic_ganglia neuroblastoma
## KP-N-S19s KP-N-S19s autonomic_ganglia  KPNSI9S autonomic_ganglia neuroblastoma

Access sensitivty data:

sensProf <- sensitivityProfiles(clevelandSmall_cSet)
sensProf[seq_len(5), seq_len(5)]
##                       AUC_published AUC_recomputed     alpha       beta
## SK-N-FI_radiation_1           3.410      2.8616423 0.1521972 0.01783452
## IMR-32_radiation_2            0.634      0.5490508 0.8098218          0
## SK-N-AS_radiation_3           3.789      3.2589305 0.1245542 0.01650291
## CHP-212_radiation_4           1.833      1.3440925 0.4615728          0
## KP-N-S19s_radiation_5         1.477      2.3251731 0.2974555          0
##                             SF2
## SK-N-FI_radiation_1   0.6181713
## IMR-32_radiation_2    0.0824000
## SK-N-AS_radiation_3   0.7827120
## CHP-212_radiation_4   0.4160333
## KP-N-S19s_radiation_5 0.2469118

For more information about the accessor methods available for the CoreSet class please see the class?CoreSet help page.

Extending the CoreSet Class

Given that the CoreSet class is intended for extension, we will show some examples of how to define a new class based on it and implement new methods for the generics provided for the CoreSet class.

Here we will define a new class, the DemoSet, with an additional slot, the demoSlot. We will then view the available methods for this class as well as define new S4 methods on it.

DemoSet <- setClass("DemoSet",
                    representation(demoSlot="character"),
                    contains="CoreSet")
getClass("DemoSet")
## Class "DemoSet" [in ".GlobalEnv"]
## 
## Slots:
##                                                                               
## Name:           demoSlot        annotation molecularProfiles              cell
## Class:         character              list              list        data.frame
##                                                                               
## Name:        datasetType       sensitivity      perturbation          curation
## Class:         character              list              list              list
## 
## Extends: "CoreSet"

Here we can see the class extending CoreSet has all of the same slots as the original CoreSet, plus the new slot we defined: demoSlot.

We can see which methods are available for this new class.

methods(class="DemoSet")
##  [1] cellInfo                cellInfo<-              cellNames              
##  [4] cellNames<-             dateCreated             fNames                 
##  [7] fNames<-                featureInfo             featureInfo<-          
## [10] mDataNames              molecularProfiles       molecularProfiles<-    
## [13] molecularProfilesSlot   molecularProfilesSlot<- name                   
## [16] pertNumber              pertNumber<-            phenoInfo              
## [19] phenoInfo<-             sensNumber              sensNumber<-           
## [22] sensitivityInfo         sensitivityInfo<-       sensitivityMeasures    
## [25] sensitivityProfiles     sensitivityProfiles<-   show                   
## see '?methods' for accessing help and source code

We see that all the accessors defined for the CoreSet are also defined for the inherting DemoSet. These methods all assume the inherit slots have the same structure as the CoreSet. If this is not true, for example, if molecularProfiles holds ExpressionSets instead of SummarizedExperiments, we can redefine existing methods as follows:

clevelandSmall_dSet <- DemoSet(clevelandSmall_cSet)
class(clevelandSmall_dSet@molecularProfiles$rna)
## [1] "SummarizedExperiment"
## attr(,"package")
## [1] "SummarizedExperiment"
expressionSets <- lapply(molecularProfilesSlot(clevelandSmall_dSet), as, 'ExpressionSet')
molecularProfilesSlot(clevelandSmall_dSet) <- expressionSets

# Now this will error
tryCatch({molecularProfiles(clevelandSmall_dSet, 'rna')}, error=function(e) print(paste("Error: ", e$message)))
## [1] "Error:  unable to find an inherited method for function 'assay' for signature '\"ExpressionSet\", \"numeric\"'"

Since we changed the data in the molecularProfiles slot of the DemoSet, the original method from CoreGx no longer works. Thus we get an error when trying to access that slot. To fix this we will need to set a new S4 method for the molecularProfiles generic function defined in CoreGx.

setMethod(molecularProfiles, 
          signature("DemoSet"), 
          function(object, mDataType) {
            pData(object@molecularProfiles[[mDataType]])
          })

This new method is now called whenever we use the molecularProfiles method on a DemoSet. Since the new method uses ExpressionSet accessor methods instead of SummarizedExperiment accessor methods, we now expect to be able to access the data in our modified slot.

# Now we test our new method
mProf <- molecularProfiles(clevelandSmall_dSet, 'rna')
head(mProf)[seq_len(5), seq_len(5)]
##                                                                                          samplename
## NIECE_P_NCLE_RNA3_HG-U133_PLUS_2_G10_296152             NIECE_p_NCLE_RNA3_HG-U133_Plus_2_G10_296152
## GILDS_P_NCLE_RNA11_REDO_HG-U133_PLUS_2_G02_587654 GILDS_p_NCLE_RNA11_Redo_HG-U133_Plus_2_G02_587654
## BUNDS_P_NCLE_RNA5_HG-U133_PLUS_2_B11_419860             BUNDS_p_NCLE_RNA5_HG-U133_Plus_2_B11_419860
## SILOS_P_NCLE_RNA9_HG-U133_PLUS_2_A04_523474             SILOS_p_NCLE_RNA9_HG-U133_Plus_2_A04_523474
## WATCH_P_NCLE_RNA8_HG-U133_PLUS_2_B04_474582             WATCH_p_NCLE_RNA8_HG-U133_Plus_2_B04_474582
##                                                                                                   filename
## NIECE_P_NCLE_RNA3_HG-U133_PLUS_2_G10_296152             NIECE_p_NCLE_RNA3_HG-U133_Plus_2_G10_296152.CEL.gz
## GILDS_P_NCLE_RNA11_REDO_HG-U133_PLUS_2_G02_587654 GILDS_p_NCLE_RNA11_Redo_HG-U133_Plus_2_G02_587654.CEL.gz
## BUNDS_P_NCLE_RNA5_HG-U133_PLUS_2_B11_419860             BUNDS_p_NCLE_RNA5_HG-U133_Plus_2_B11_419860.CEL.gz
## SILOS_P_NCLE_RNA9_HG-U133_PLUS_2_A04_523474             SILOS_p_NCLE_RNA9_HG-U133_Plus_2_A04_523474.CEL.gz
## WATCH_P_NCLE_RNA8_HG-U133_PLUS_2_B04_474582             WATCH_p_NCLE_RNA8_HG-U133_Plus_2_B04_474582.CEL.gz
##                                                         chiptype
## NIECE_P_NCLE_RNA3_HG-U133_PLUS_2_G10_296152       HG-U133_Plus_2
## GILDS_P_NCLE_RNA11_REDO_HG-U133_PLUS_2_G02_587654 HG-U133_Plus_2
## BUNDS_P_NCLE_RNA5_HG-U133_PLUS_2_B11_419860       HG-U133_Plus_2
## SILOS_P_NCLE_RNA9_HG-U133_PLUS_2_A04_523474       HG-U133_Plus_2
## WATCH_P_NCLE_RNA8_HG-U133_PLUS_2_B04_474582       HG-U133_Plus_2
##                                                   hybridization.date
## NIECE_P_NCLE_RNA3_HG-U133_PLUS_2_G10_296152                 07/15/08
## GILDS_P_NCLE_RNA11_REDO_HG-U133_PLUS_2_G02_587654         2010-05-21
## BUNDS_P_NCLE_RNA5_HG-U133_PLUS_2_B11_419860                 12/19/08
## SILOS_P_NCLE_RNA9_HG-U133_PLUS_2_A04_523474               2009-12-08
## WATCH_P_NCLE_RNA8_HG-U133_PLUS_2_B04_474582               2009-08-14
##                                                   hybridization.hour
## NIECE_P_NCLE_RNA3_HG-U133_PLUS_2_G10_296152                 12:54:10
## GILDS_P_NCLE_RNA11_REDO_HG-U133_PLUS_2_G02_587654          16:45:06Z
## BUNDS_P_NCLE_RNA5_HG-U133_PLUS_2_B11_419860                 11:43:19
## SILOS_P_NCLE_RNA9_HG-U133_PLUS_2_A04_523474                20:44:59Z
## WATCH_P_NCLE_RNA8_HG-U133_PLUS_2_B04_474582                17:15:45Z

We can see our new method works! In order to finish updating the methods for our new class, we would have to redefine all the generics which access the modified slot.

However, additional work needs to be done to define accessors for the new demoSlot. Since no generics are available in CoreGx to access this slot, we need to first define a generic, then implement methods which distpatch on the 'DemoSet' class to retrieve data int he slot.

# Define generic for setter method
setGeneric('demoSlot<-', function(object, value) standardGeneric('demoSlot<-'))
## [1] "demoSlot<-"
# Define a setter method
setReplaceMethod('demoSlot', 
                 signature(object='DemoSet', value="character"),
                 function(object, value) {
                   object@demoSlot <- value
                   return(object)
                 })

# Lets add something to our demoSlot
demoSlot(clevelandSmall_dSet) <- c("This", "is", "the", "demoSlot")
# Define generic for getter method
setGeneric('demoSlot', function(object, ...) standardGeneric("demoSlot"))
## [1] "demoSlot"
# Define a getter method
setMethod("demoSlot",
          signature("DemoSet"),
          function(object) {
            paste(object@demoSlot, collapse=" ")
          })

# Test our getter method
demoSlot(clevelandSmall_dSet)
## [1] "This is the demoSlot"

Now you should have all the knowledge you need to extend the CoreSet class for use in other treatment-response experiments!

For more information about this package and the possibility of collaborating on its extension please contact benjamin.haibe.kains@utoronto.ca.