---
title: "gDRimport"
author: "gDR team"
output: BiocStyle::html_document
vignette: >
  %\VignetteIndexEntry{gDRimport}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r init-import, echo=FALSE}
library(gDRimport)
log_level <- futile.logger::flog.threshold("ERROR")
```

# Overview

The `gDRimport` package is a part of the gDR suite. It helps to prepare raw drug response data for downstream processing. It mainly contains helper functions for importing/loading/validating dose response data provided in different file formats.

# Use Cases

## Test Data
There are currently four test datasets that can be used to see what's the expected input data for the gDRimport.

```{r load-test-datasets}
# primary test data
td1 <- get_test_data()
summary(td1)
td1

# test data in Tecan format
td2 <- get_test_Tecan_data()
summary(td2)

# test data in D300 format
td3 <- get_test_D300_data()
summary(td3)

# test data obtained from EnVision
td4 <- get_test_EnVision_data()
summary(td4)
```

## Load data
The `load_data` is the key function. It wraps `load_manifest`, `load_templates` and `load_results` functions and supports different file formats.

```{r execute-data-loading}
ml <- load_manifest(manifest_path(td1))
summary(ml)

t_df <- load_templates(template_path(td1))
summary(t_df)

r_df <- suppressMessages(load_results(result_path(td1)))
summary(r_df)

l_tbl <-
  suppressMessages(
    load_data(manifest_path(td1), template_path(td1), result_path(td1)))
summary(l_tbl)
```

# PRISM

PRISM, the Multiplexed cancer cell line screening platform, facilitates rapid screening of a broad spectrum of drugs across more than 900 human cancer cell line models, employing a high-throughput, multiplexed approach. Publicly available PRISM data can be downloaded from the DepMap website ([DepMap](https://depmap.org/portal/download/all/)).

The `gDRimport` package provides support for processing PRISM data at two levels: LEVEL5 and LEVEL6.

* LEVEL5 Data: This format encapsulates all information about drugs, cell lines, and viability within a single file. To process LEVEL5 PRISM data, you can use the `convert_LEVEL5_prism_to_gDR_input()` function. This function not only transforms and cleans the data but also executes the gDR pipeline for further analysis.

* LEVEL6 Data: In LEVEL6, PRISM data is distributed across three separate files:

prism_data: containing collapsed log fold change data for viability assays.
cell_line_data: providing information about cell lines.
treatment_data: containing treatment data.

Processing LEVEL6 PRISM data can be accomplished using the `convert_LEVEL6_prism_to_gDR_input()` function, which requires paths to these three files as input arguments.

### Processing LEVEL5 PRISM Data

To process LEVEL5 PRISM data, you can use the following function:

```{r process-prism-level5, echo=TRUE, eval=FALSE}
convert_LEVEL5_prism_to_gDR_input("path_to_file")
```

Replace "path_to_file" with the actual path to your LEVEL5 PRISM data file. This function will handle the transformation, cleaning, and execution of the gDR pipeline automatically.


### Processing LEVEL6 PRISM Data

To process LEVEL6 PRISM data, you can use the following function:

```{r process-prism-level6, echo=TRUE, eval=FALSE}
convert_LEVEL6_prism_to_gDR_input("prism_data_path", "cell_line_data_path", "treatment_data_path")
```

Replace "prism_data_path", "cell_line_data_path", and "treatment_data_path" with the respective paths to your LEVEL6 PRISM data files.


## Package installation
The function `installAllDeps` assists in installing package dependencies.

# SessionInfo {-}

```{r session-info}
sessionInfo()
```
