Contents

library(gDRimport)
library(gDRtestData)
library(gDRcore)
log_level <- futile.logger::flog.threshold("ERROR")

1 Overview

The gDRcore is the part of the gDR suite. The package provides set of tools to proces and analyze drug response data.

2 Introduction

2.1 Data model

The data model is built on the MultiAssayExperiments (MAE) structure. Within an MAE, each SummarizedExperiment (SE) contains a different unit type (e.g. single-agent, or combination treatment). Columns of the MAE are defined by the cell lines and any modification of them and are shared with the SEs. Rows are defined by the treatments (e.g drugs, perturbations) and are specific to each SE. Assays of the SE are the different levels of data processing (raw, control, normalized, averaged data, as well as metrics). Each nested element of the assays of the SEs comprises the series themselves as a table (data.table in practice). Although not all elements need to have a series or the same number of elements, the attributes (columns of the table) should be consistent across the SE.

2.2 Drug processing

For drug response data, the input files need to be merged such that each measurement (data) is associated with the right metadata (cell line properties and treatment definition). Metadata can be added with the function cleanup_metadata if the right reference databases are in place.

When the data and metadata are merged into a long table, the wrapper function runDrugResponseProcessingPipeline can be used to generate an MAE with processed and analyzed data. In practice runDrugResponseProcessingPipeline does the following steps: * create_SE creates the structure of the MAE and the associated SEs by assigning metadata into the row and column attributes. The assignment is performed in the function split_SE_components (see details below for the assumption made when building SE structures). create_SE also dispatches the raw data and controls into the right nested tables. Note that data may be duplicated between different SEs to make them self-contained. * normalize_SE normalizes the raw data based on the control. Calculation of the GR value is based on a cell line division time provided by the reference database if no pre-treatment control is provided. If both information are missing, GR values cannot be calculated. Additional normalization can be added as new rows in the nested table. * average_SE averages technical replicates that are stored in the same nested table are averaged. * fit_SE fits the dose-response curves and calculates response metrics for each normalization type. * fit_SE.combinations calculates synergy scores for drug combination data and, if the data is appropriate, fits along the two drugs and matrix-level metrics (e.g. isobolograms) are calculated. This is also performed for each normalization type independently.

The functions to process the data have parameters for specifying the names of the variables and assays. Additional parameters are available to personalize the processing steps such as force the nesting (or not) of an attribute, specify attributes that should be considered as technical replicates or not.

3 Use Cases

3.1 Data preprocessing

Please familiarize with gDRimport package containing bunch of tools allowing to prepare input data for gDRcore.

This example is made up based on the artificial dataset called data1 available within gDRimport package. gDR required three types of data that should be used as the raw input: Template, Manifest, and RawData. More info about these three types of data you could find in our general documentation.

td <- gDRimport::get_test_data()

Provided dataset needs to be merged into the one data.table object to be able to run gDR pipeline. This process can be done using two functions – gDRimport::load_data() and gDRcore::merge_data().

loaded_data <-
  suppressMessages(
    gDRimport::load_data(
      gDRimport::manifest_path(td),
      gDRimport::template_path(td),
      gDRimport::result_path(td)
    )
  )
input_df <- merge_data(loaded_data$manifest, loaded_data$treatments, loaded_data$data)
head(input_df)
#>    CellLineName Tissue Duration DrugName Concentration DrugName_2
#>          <char> <char>    <num>   <char>         <num>     <char>
#> 1:  cellline_BA breast        0  vehicle             0    vehicle
#> 2:  cellline_BA breast        0  vehicle             0    vehicle
#> 3:  cellline_BA breast        0  vehicle             0    vehicle
#> 4:  cellline_BA breast        0  vehicle             0    vehicle
#> 5:  cellline_BA breast        0  vehicle             0    vehicle
#> 6:  cellline_BA breast        0  vehicle             0    vehicle
#>    Concentration_2 drug_moa_2 drug_moa parental_identifier subtype    Barcode
#>              <num>     <char>   <char>              <char>  <char>     <char>
#> 1:               0    vehicle  vehicle         cellline_BA unknown 201904190a
#> 2:               0    vehicle  vehicle         cellline_BA unknown 201904190a
#> 3:               0    vehicle  vehicle         cellline_BA unknown 201904190a
#> 4:               0    vehicle  vehicle         cellline_BA unknown 201904190a
#> 5:               0    vehicle  vehicle         cellline_BA unknown 201904190a
#> 6:               0    vehicle  vehicle         cellline_BA unknown 201904190a
#>    ReadoutValue BackgroundValue ReferenceDivisionTime    clid Gnumber Gnumber_2
#>           <num>           <num>                 <num>  <char>  <char>    <char>
#> 1:        91452             570                    26 CL00011 vehicle   vehicle
#> 2:       126448             570                    26 CL00011 vehicle   vehicle
#> 3:        91461             570                    26 CL00011 vehicle   vehicle
#> 4:       126449             570                    26 CL00011 vehicle   vehicle
#> 5:        91459             570                    26 CL00011 vehicle   vehicle
#> 6:       126448             570                    26 CL00011 vehicle   vehicle
#>                   Template WellRow WellColumn
#>                     <char>  <char>     <char>
#> 1: Template_Untreated.xlsx       A          3
#> 2: Template_Untreated.xlsx       B          3
#> 3: Template_Untreated.xlsx       C          3
#> 4: Template_Untreated.xlsx       D          3
#> 5: Template_Untreated.xlsx       E          3
#> 6: Template_Untreated.xlsx       F          3

3.2 Running gDR pipeline

We provide an all-in-one function that splits data into appropriate data types, creates the SummarizedExperiment object for each data type, splits data into treatment and control assays, normalizes, averages, calculates gDR metrics, and finally, creates the MultiAssayExperiment object. This function is called runDrugResponseProcessingPipeline.

mae <- runDrugResponseProcessingPipeline(input_df)
mae
#> A MultiAssayExperiment object of 2 listed
#>  experiments with user-defined names and respective classes.
#>  Containing an ExperimentList class object of length 2:
#>  [1] matrix: SummarizedExperiment with 2 rows and 6 columns
#>  [2] single-agent: SummarizedExperiment with 3 rows and 6 columns
#> Functionality:
#>  experiments() - obtain the ExperimentList instance
#>  colData() - the primary/phenotype DataFrame
#>  sampleMap() - the sample coordination DataFrame
#>  `$`, `[`, `[[` - extract colData columns, subset, or experiment
#>  *Format() - convert into a long or wide DataFrame
#>  assays() - convert ExperimentList to a SimpleList of matrices
#>  exportClass() - save data to flat files

And we can subset the MultiAssayExperiment to receive the SummarizedExperiment specific to any data type, e.g.

mae[["single-agent"]]
#> class: SummarizedExperiment 
#> dim: 3 6 
#> metadata(5): identifiers experiment_metadata Keys fit_parameters
#>   .internal
#> assays(5): RawTreated Controls Normalized Averaged Metrics
#> rownames(3): G00002_drug_002_moa_A_168 G00004_drug_004_moa_A_168
#>   G00011_drug_011_moa_B_168
#> rowData names(4): Gnumber DrugName drug_moa Duration
#> colnames(6): CL00011_cellline_BA_breast_cellline_BA_unknown_26
#>   CL00012_cellline_CA_breast_cellline_CA_unknown_30 ...
#>   CL00015_cellline_FA_breast_cellline_FA_unknown_42
#>   CL00018_cellline_IB_breast_cellline_IB_unknown_54
#> colData names(6): clid CellLineName ... subtype ReferenceDivisionTime

3.3 Data extraction

Extraction of the data from either MultiAssayExperiment or SummarizedExperiment objects into more user-friendly structures as well as other data transformations can be done using gDRutils. We encourage to read gDRutils vignette to familiarize with these functionalities.

SessionInfo

sessionInfo()
#> R version 4.3.2 Patched (2023-11-13 r85521)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 22.04.3 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.18-bioc/R/lib/libRblas.so 
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_GB              LC_COLLATE=C              
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: America/New_York
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] gDRcore_1.0.1     gDRtestData_1.0.0 gDRimport_1.0.0   BiocStyle_2.30.0 
#> 
#> loaded via a namespace (and not attached):
#>  [1] bitops_1.0-7                fastmap_1.1.1              
#>  [3] RCurl_1.98-1.14             BumpyMatrix_1.10.0         
#>  [5] TH.data_1.1-2               digest_0.6.34              
#>  [7] lifecycle_1.0.4             gDRutils_1.0.0             
#>  [9] survival_3.5-8              magrittr_2.0.3             
#> [11] compiler_4.3.2              rlang_1.1.3                
#> [13] sass_0.4.8                  drc_3.0-1                  
#> [15] tools_4.3.2                 plotrix_3.8-4              
#> [17] utf8_1.2.4                  yaml_2.3.8                 
#> [19] data.table_1.15.0           knitr_1.45                 
#> [21] lambda.r_1.2.4              S4Arrays_1.2.0             
#> [23] DelayedArray_0.28.0         abind_1.4-5                
#> [25] multcomp_1.4-25             BiocParallel_1.36.0        
#> [27] purrr_1.0.2                 BiocGenerics_0.48.1        
#> [29] grid_4.3.2                  stats4_4.3.2               
#> [31] fansi_1.0.6                 colorspace_2.1-0           
#> [33] scales_1.3.0                gtools_3.9.5               
#> [35] MASS_7.3-60.0.1             MultiAssayExperiment_1.28.0
#> [37] SummarizedExperiment_1.32.0 cli_3.6.2                  
#> [39] mvtnorm_1.2-4               rmarkdown_2.25             
#> [41] crayon_1.5.2                readxl_1.4.3               
#> [43] cachem_1.0.8                stringr_1.5.1              
#> [45] zlibbioc_1.48.0             splines_4.3.2              
#> [47] assertthat_0.2.1            parallel_4.3.2             
#> [49] formatR_1.14                BiocManager_1.30.22        
#> [51] cellranger_1.1.0            XVector_0.42.0             
#> [53] matrixStats_1.2.0           vctrs_0.6.5                
#> [55] Matrix_1.6-5                sandwich_3.1-0             
#> [57] jsonlite_1.8.8              carData_3.0-5              
#> [59] bookdown_0.37               car_3.1-2                  
#> [61] IRanges_2.36.0              S4Vectors_0.40.2           
#> [63] testthat_3.2.1              jquerylib_0.1.4            
#> [65] rematch_2.0.0               glue_1.7.0                 
#> [67] codetools_0.2-19            stringi_1.8.3              
#> [69] futile.logger_1.4.3         GenomeInfoDb_1.38.6        
#> [71] GenomicRanges_1.54.1        munsell_0.5.0              
#> [73] tibble_3.2.1                pillar_1.9.0               
#> [75] htmltools_0.5.7             brio_1.1.4                 
#> [77] GenomeInfoDbData_1.2.11     R6_2.5.1                   
#> [79] evaluate_0.23               lattice_0.22-5             
#> [81] Biobase_2.62.0              futile.options_1.0.1       
#> [83] backports_1.4.1             bslib_0.6.1                
#> [85] SparseArray_1.2.4           checkmate_2.3.1            
#> [87] xfun_0.42                   MatrixGenerics_1.14.0      
#> [89] zoo_1.8-12                  pkgconfig_2.0.3