Skip to content

Commit cc750ad

Browse files
committed
Adding new data examples
1 parent aecc74a commit cc750ad

8 files changed

+346
-13
lines changed

R/OrganoidsToolBox.R

Lines changed: 156 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,90 @@ NULL
210210
NULL
211211

212212

213+
214+
215+
#' Simple demo drug screening for one drug (Methotrexate). The results have
216+
#' been generated for demonstration purpose. There is two studies present in
217+
#' the dataset. There is also only two types of screening in the dataset. Some
218+
#' entries have a value for a second drug. There is not entry for a third
219+
#' drug. There is no background drug. At last, there is two types of dosage.
220+
#'
221+
#' @name drugScreeningMethoSet
222+
#'
223+
#' @docType data
224+
#'
225+
#' @aliases drugScreeningMethoSet
226+
#'
227+
#' @format a \code{data.frame} with the following columns:
228+
#' \itemize{
229+
#' \item \code{organoid_id} { a \code{character} string representing the
230+
#' organoid identifier. }
231+
#' \item \code{timestamp} { a \code{character} string representing the date
232+
#' when the screening was done. }
233+
#' \item \code{study} { a \code{character} string representing the study. }
234+
#' \item \code{screen_type} { a \code{character} string representing the
235+
#' screen type. }
236+
#' \item \code{drug_a} { a \code{character} string representing the name of
237+
#' the first drug used for the drug screen. There is at least one drug used
238+
#' in a drug screening.}
239+
#' \item \code{drug_b} { a \code{character} string representing the name of
240+
#' the second drug used for the drug screen. When no second drug has been
241+
#' used, the value is \code{'N/A'}. }
242+
#' \item \code{drug_c} { a \code{character} string representing the name of
243+
#' the third drug used for the drug screen. When no third drug has been
244+
#' used, the value is \code{'N/A'}. }
245+
#' \item \code{drug_background} { a \code{character} string representing the
246+
#' name of
247+
#' the drug used as background for the drug screen. When no drug has been used
248+
#' as background, the value is \code{'N/A'}. }
249+
#' \item \code{dosage_type} { a \code{character} string representing the type
250+
#' of dosage. }
251+
#' \item \code{relative_auc} { a \code{numeric}
252+
#' representing the relative AUC (area under the curve) for the specified
253+
#' organoids under specific conditions. The AUC is calculated using the
254+
#' percentage of viability under different drug concentrations. So, the same
255+
#' relative AUC is repeated on multiple lines.}
256+
#' }
257+
#'
258+
#' @seealso
259+
#' \itemize{
260+
#' \item \code{\link{getClassOneDrug}} { for selecting the organoids
261+
#' with sensitive and resistant behavior for a
262+
#' specific drug screening.}
263+
#' }
264+
#'
265+
#' @usage data(drugScreeningMethoSet)
266+
#'
267+
#' @keywords datasets
268+
#'
269+
#' @examples
270+
#'
271+
#' ## Load drug screen dataset and patient information for methotrexate
272+
#' data(drugScreeningMethoSet)
273+
#' data(patientInfoMethoSet)
274+
#'
275+
#' ## Retain unreplicated samples
276+
#' cleanData <- selectNoReplicateOrganoids(drugScreening=drugScreeningMethoSet,
277+
#' patientInfo=patientInfoMethoSet)
278+
#'
279+
#' ## Calculate the extreme organoids for the methotrexate drug screening
280+
#' ## using a quantile of 1/3
281+
#' results <- getClassOneDrug(drugScreening=cleanData,
282+
#' drugName="Methotrexate", study="MEGA-TEST", screenType="TEST-01",
283+
#' doseType="Averaged", quantile=1/3)
284+
#'
285+
#' ## The information of the extreme organoids is found it the 'extreme' entry
286+
#' head(results$extreme)
287+
#'
288+
#' ## Fisher test on ancestry
289+
#' fisherT <- fisherCategoricalVariable(drugQuantile=results,
290+
#' category="ancestry")
291+
#'
292+
#' fisherT
293+
#'
294+
NULL
295+
296+
213297
#' Simple demo patient information dataset. The information is related to the
214298
#' organoids present in the 'drugScreening' dataset.
215299
#'
@@ -235,9 +319,12 @@ NULL
235319
#' \item \code{\link{selectNoReplicateOrganoids}} { for selecting
236320
#' the unrelated samples (only one sample per patient) from a drug screening
237321
#' dataset.}
322+
#' \item \code{\link{fisherCategoricalVariable}} { for running Fisher tests
323+
#' in the sensitive and resistant groups using a categorical value
324+
#' from a drug screening dataset.}
238325
#' }
239326
#'
240-
#' @usage data(drugScreening)
327+
#' @usage data(patientInfo)
241328
#'
242329
#' @keywords datasets
243330
#'
@@ -258,3 +345,71 @@ NULL
258345
#'
259346
#'
260347
NULL
348+
349+
350+
#' Simple demo patient information dataset. The information is related to the
351+
#' organoids present in the 'drugScreening' dataset.
352+
#'
353+
#' @name patientInfoMethoSet
354+
#'
355+
#' @docType data
356+
#'
357+
#' @aliases patientInfoMethoSet
358+
#'
359+
#' @format a \code{data.frame} with the following columns:
360+
#' \itemize{
361+
#' \item \code{organoid_id} { a \code{character} string representing the
362+
#' organoid identifier. }
363+
#' \item \code{patient_id} { a \code{character} string representing the patient
364+
#' identifier. }
365+
#' \item \code{ancestry} { a \code{character} string representing the patient
366+
#' genetic ancestry. }
367+
#' \item \code{BMI} { a \code{character} string representing the patient
368+
#' BMI class. }
369+
#' }
370+
#'
371+
#' @seealso
372+
#' \itemize{
373+
#' \item \code{\link{getClassOneDrug}} { for selecting the samples
374+
#' with sensitive and resistant behavior for a
375+
#' specific drug screening dataset.}
376+
#' \item \code{\link{selectNoReplicateOrganoids}} { for selecting
377+
#' the unrelated samples (only one sample per patient) from a drug screening
378+
#' dataset.}
379+
#' \item \code{\link{fisherCategoricalVariable}} { for running Fisher tests
380+
#' in the sensitive and resistant groups using a categorical value
381+
#' from a drug screening dataset.}
382+
#' }
383+
#'
384+
#' @usage data(patientInfoMethoSet)
385+
#'
386+
#' @keywords datasets
387+
#'
388+
#' @examples
389+
#'
390+
#' ## Load drug screen dataset for methotrexate dataset
391+
#' data(drugScreening)
392+
#'
393+
#' ## Load patient information dataset for methotrexate dataset
394+
#' data(patientInfoMethoSet)
395+
#'
396+
#' ## Retain unreplicated samples
397+
#' cleanData <- selectNoReplicateOrganoids(drugScreening=drugScreeningMethoSet,
398+
#' patientInfo=patientInfoMethoSet)
399+
#'
400+
#' ## Calculate the extreme organoids for the methotrexate drug screening
401+
#' ## using a quantile of 1/3
402+
#' results <- getClassOneDrug(drugScreening=cleanData,
403+
#' drugName="Methotrexate", study="MEGA-TEST", screenType="TEST-01",
404+
#' doseType="Averaged", quantile=1/4)
405+
#'
406+
#' ## The information of the extreme organoids is found it the 'extreme' entry
407+
#' head(results$extreme)
408+
#'
409+
#' ## Fisher test on BMI
410+
#' fisherT <- fisherCategoricalVariable(drugQuantile=results, category="BMI")
411+
#'
412+
#' fisherT
413+
#'
414+
#'
415+
NULL

R/enrichment.R

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,23 @@
1919
#'
2020
#' @examples
2121
#'
22-
#' ## Load drug screen dataset for 1 drug
23-
#' data(drugScreening)
22+
#' ## Load drug screen dataset and patient information for methotrexate
23+
#' data(drugScreeningMethoSet)
24+
#' data(patientInfoMethoSet)
25+
#'
26+
#' ## Retain unreplicated samples
27+
#' cleanData <- selectNoReplicateOrganoids(drugScreening=drugScreeningMethoSet,
28+
#' patientInfo=patientInfoMethoSet)
2429
#'
2530
#' ## Calculate the extreme organoids for the methotrexate drug screening
2631
#' ## using a quantile of 1/3
27-
#' results <- getClassOneDrug(drugScreening=drugScreening,
32+
#' results <- getClassOneDrug(drugScreening=cleanData,
2833
#' drugName="Methotrexate", study="MEGA-TEST", screenType="TEST-01",
2934
#' doseType="Averaged", quantile=1/3)
3035
#'
31-
#' ## TODO
32-
#' results$extreme
36+
#' ## Fisher test on ancestry
37+
#' fisherT <- fisherCategoricalVariable(drugQuantile=results,
38+
#' category="ancestry")
3339
#'
3440
#' @author Astrid Deschênes, Pascal Belleau
3541
#' @importFrom stats fisher.test
@@ -48,13 +54,20 @@ fisherCategoricalVariable <- function(drugQuantile, category) {
4854
}
4955

5056
## The drug must be present in the drug dataset
51-
if (!(category %in% colnames(drugQuantile$extreme))) {
57+
if (!(category %in% colnames(drugQuantile$extreme) ||
58+
category %in% colnames(drugQuantile$dataset))) {
5259
stop("The category \'", category, "\' must be one of the columns in ",
5360
"the \'DrugAUCQuantile\' dataset.")
5461
}
5562

5663
results <- drugQuantile$extreme
5764

65+
if (!(category %in% colnames(drugQuantile$extreme))) {
66+
results <- merge(results, drugQuantile$dataset[,
67+
c("organoid_id", category)],
68+
by="organoid_id", all.x=TRUE, all.y=FALSE)
69+
}
70+
5871
sensitive <- results[results$group == "SENSITIVE",]
5972
resistant <- results[results$group == "RESISTANT",]
6073

@@ -75,6 +88,7 @@ fisherCategoricalVariable <- function(drugQuantile, category) {
7588
result <- list()
7689
result[["Fisher"]] <- fisherResult
7790
result[["table"]] <- allTable
91+
result[["category"]] <- category
7892

7993
return(result)
8094
}

data/drugScreeningMethoSet.RData

2.23 KB
Binary file not shown.

data/patientInfoMethoSet.RData

1.23 KB
Binary file not shown.

man/drugScreeningMethoSet.Rd

Lines changed: 86 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/fisherCategoricalVariable.Rd

Lines changed: 11 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/patientInfo.Rd

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)