Skip to content

Commit 5c37307

Browse files
committed
Adding new function selectNoReplicateOrganoids(); refactoring code; update documentation
1 parent c25ab4f commit 5c37307

19 files changed

+408
-162
lines changed

NAMESPACE

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
S3method(is,DrugAUCQuantile)
44
S3method(is,DrugAUCQuantileNoReplicate)
5+
export(fisherCategoricalVariable)
6+
export(getClassNoReplicateOneDrug)
7+
export(getClassOneDrug)
58
export(plotDrugAUCDensityCurve)
69
export(plotDrugAUCViolinPlot)
7-
export(selectOrgForOneDrug)
8-
export(selectOrgWithoutReplicateForOneDrug)
10+
export(selectNoReplicateOrganoids)
911
importFrom(S4Vectors,isSingleNumber)
1012
importFrom(ggplot2,.data)
1113
importFrom(ggplot2,aes)
@@ -28,4 +30,5 @@ importFrom(ggplot2,ylim)
2830
importFrom(ggridges,geom_density_ridges)
2931
importFrom(ggridges,position_points_jitter)
3032
importFrom(methods,is)
33+
importFrom(stats,fisher.test)
3134
importFrom(stats,quantile)

R/OrganoidsToolBox.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#'
1717
#' @seealso
1818
#' \itemize{
19-
#' \item \code{\link{selectOrgForOneDrug}} {for selecting the organoids
19+
#' \item \code{\link{getClassOneDrug}} {for selecting the organoids
2020
#' with sensitive and resistant behavior for a specific drug screening.}
2121
#' }
2222
#' @encoding UTF-8
@@ -90,7 +90,7 @@ NULL
9090
#'
9191
#' @seealso
9292
#' \itemize{
93-
#' \item \code{\link{selectOrgForOneDrug}} { for selecting the organoids
93+
#' \item \code{\link{getClassOneDrug}} { for selecting the organoids
9494
#' with sensitive and resistant behavior for a
9595
#' specific drug screening.}
9696
#' }
@@ -106,7 +106,7 @@ NULL
106106
#'
107107
#' ## Calculate the extreme organoids for the methotrexate drug screening
108108
#' ## using a quantile of 1/3
109-
#' results <- selectOrgForOneDrug(drugScreening=simpleDrugScreening,
109+
#' results <- getClassOneDrug(drugScreening=simpleDrugScreening,
110110
#' drugName="Methotrexate", study="MEGA-TEST", screenType="TEST-01",
111111
#' doseType="Averaged", quantile=1/3)
112112
#'
@@ -183,7 +183,7 @@ NULL
183183
#'
184184
#' @seealso
185185
#' \itemize{
186-
#' \item \code{\link{selectOrgForOneDrug}} { for selecting the organoids
186+
#' \item \code{\link{getClassOneDrug}} { for selecting the organoids
187187
#' with sensitive and resistant behavior for a
188188
#' specific drug screening.}
189189
#' }
@@ -199,7 +199,7 @@ NULL
199199
#'
200200
#' ## Calculate the extreme organoids for the methotrexate drug screening
201201
#' ## using a quantile of 1/3
202-
#' results <- selectOrgForOneDrug(drugScreening=drugScreening,
202+
#' results <- getClassOneDrug(drugScreening=drugScreening,
203203
#' drugName="Methotrexate", study="MEGA-TEST", screenType="TEST-01",
204204
#' doseType="Averaged", quantile=1/4)
205205
#'
@@ -229,11 +229,11 @@ NULL
229229
#'
230230
#' @seealso
231231
#' \itemize{
232-
#' \item \code{\link{selectOrgForOneDrug}} { for selecting the organoids
232+
#' \item \code{\link{getClassOneDrug}} { for selecting the samples
233233
#' with sensitive and resistant behavior for a
234234
#' specific drug screening.}
235-
#' \item \code{\link{selectOrgWithoutReplicateForOneDrug}} { for selecting
236-
#' the unrelated organoids (only one organoid per patient)
235+
#' \item \code{\link{getClassNoReplicateOneDrug}} { for selecting
236+
#' the unrelated samples (only one sample per patient)
237237
#' with sensitive and resistant behavior for a
238238
#' specific drug screening.}
239239
#' }
@@ -252,7 +252,7 @@ NULL
252252
#'
253253
#' ## Calculate the extreme organoids for the methotrexate drug screening
254254
#' ## using a quantile of 1/3
255-
#' results <- selectOrgWithoutReplicateForOneDrug(drugScreening=drugScreening,
255+
#' results <- getClassNoReplicateOneDrug(drugScreening=drugScreening,
256256
#' drugName="Methotrexate", study="MEGA-TEST", screenType="TEST-01",
257257
#' patientInfo=patientInfo, doseType="Averaged", quantile=1/4)
258258
#'

R/drugScreening-internal.R

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#' @param drugName a single \code{character} string representing the
1616
#' selected drug.
1717
#'
18-
#' @param study a single \code{character} string representing the name of
18+
#' @param study a \code{vector} of \code{character} string representing the
19+
#' name(s) of
1920
#' the study selected for the analyses. The study must be present in the drug
2021
#' screening dataset. The study can be found in the 'study' column of the
2122
#' drug screening dataset.
@@ -52,7 +53,7 @@ filterDrugScreenOneDrug <- function(drugData, drugName, study, screenType,
5253
doseType) {
5354

5455
## Select the specified study
55-
selectedDrug <- drugData[which(tolower(drugData$study) ==
56+
selectedDrug <- drugData[which(tolower(drugData$study) %in%
5657
tolower(study)), ]
5758

5859
## Select the specified screen type
@@ -302,8 +303,9 @@ findOneDrugQuantile <- function(drugData, drugName, doseType="Averaged",
302303
#' @param drugName a single \code{character} string representing the name of
303304
#' the drug selected for the analyses.
304305
#'
305-
#' @param study a single \code{character} string representing the name of
306-
#' the study selected for the analyses.
306+
#' @param study a \code{vector} of \code{character} string representing
307+
#' the name of the study selected for the analyses.
308+
#'
307309
#' @param screenType a \code{vector} of \code{character} string representing
308310
#' the type of
309311
#' screening selected for the analyses.
@@ -380,10 +382,10 @@ validateSelectOrgForOneDrug <- function(drugScreening, drugName, study,
380382

381383

382384
#' @title Validate input parameters for the
383-
#' selectOrgWithoutReplicateForOneDrug() function
385+
#' getClassNoReplicateOneDrug() function
384386
#'
385387
#' @description The function validates the input parameters for the
386-
#' selectOrgWithoutReplicateForOneDrug() function.
388+
#' getClassNoReplicateOneDrug() function.
387389
#'
388390
#' @param drugScreening a single \code{character} string representing the path
389391
#' and name of the drug screening file that contains the information needed
@@ -431,7 +433,7 @@ validateSelectOrgForOneDrug <- function(drugScreening, drugName, study,
431433
#' @importFrom S4Vectors isSingleNumber
432434
#' @encoding UTF-8
433435
#' @keywords internal
434-
validateSelectOrgWithoutReplicateForOneDrug<- function(drugScreening,
436+
validateSelectOrgWithoutReplicateForOneDrug <- function(drugScreening,
435437
drugName, study, screenType, patientInfo, doseType, quantile) {
436438

437439
## Validate all but patientInfo parameter
@@ -452,3 +454,61 @@ validateSelectOrgWithoutReplicateForOneDrug<- function(drugScreening,
452454

453455
return(0L)
454456
}
457+
458+
459+
#' @title Validate input parameters for the
460+
#' selectNoReplicateOrganoids() function
461+
#'
462+
#' @description The function validates the input parameters for the
463+
#' selectNoReplicateOrganoids() function.
464+
#'
465+
#' @param drugScreening a \code{data.frame} containing the drug screening
466+
#' information. The 'organoid_id' column is mandatory.
467+
#'
468+
#' @param patientInfo a \code{data.frame} containing the meta-data information
469+
#' related to the organoids. The mandatory columns are: 'organoid_id'
470+
#' and 'patient_id'.
471+
#'
472+
#' @return the value \code{0L} when successful.
473+
#'
474+
#' @examples
475+
#'
476+
#' ## Load drug screen dataset for 1 drug
477+
#' data(drugScreening)
478+
#'
479+
#' ## Load patient information dataset
480+
#' data(patientInfo)
481+
#'
482+
#' ## Validation should return OL as all parameters are valids
483+
#' OrganoidsToolBox:::validateSelectNoReplicateOrganoids(
484+
#' drugScreening=drugScreening, patientInfo=patientInfo)
485+
#'
486+
#' @author Astrid Deschênes, Pascal Belleau
487+
#' @importFrom S4Vectors isSingleNumber
488+
#' @encoding UTF-8
489+
#' @keywords internal
490+
validateSelectNoReplicateOrganoids <- function(drugScreening,patientInfo) {
491+
492+
if (!is.data.frame(drugScreening)) {
493+
stop("The \'drugScreening\' must be a data.frame.")
494+
}
495+
496+
## Check for mandatory columns in drugScreening
497+
if (!('organoid_id' %in% colnames(drugScreening))) {
498+
stop("The mandatory column \'organoid_id\' is missing.")
499+
}
500+
501+
if (!is.data.frame(patientInfo)) {
502+
stop("The \'patientInfo\' must be a data.frame.")
503+
}
504+
505+
## Check for mandatory columns in patientInfo
506+
if (!all(c('organoid_id', 'patient_id') %in% colnames(patientInfo))) {
507+
stop("Mandatory columns are missing from the patient info ",
508+
"dataset. The mandatory columns are: \'organoid_id\' and ",
509+
"\'patient_id\'.")
510+
}
511+
512+
return(0L)
513+
}
514+

0 commit comments

Comments
 (0)