|
a |
|
b/R/rnaseq.R |
|
|
1 |
#' Utility for using voom transformation with TMLE for biomarker discovery |
|
|
2 |
#' |
|
|
3 |
#' This function prepares next-generation sequencing data (counts) for use with |
|
|
4 |
#' the biomarker TMLE procedure by invoking the voom transform of \code{limma}. |
|
|
5 |
#' |
|
|
6 |
#' @param biotmle A \code{bioTMLE} object containing next-generation sequencing |
|
|
7 |
#' count data in its "assays" slot. |
|
|
8 |
#' @param weights A \code{logical} indicating whether to return quality weights |
|
|
9 |
#' of samples in the output object. |
|
|
10 |
#' @param ... Other arguments to be passed to \code{\link[limma]{voom}} or |
|
|
11 |
#' \code{\link[limma]{voomWithQualityWeights}} as appropriate. |
|
|
12 |
#' |
|
|
13 |
#' @importFrom tibble as_tibble |
|
|
14 |
#' @importFrom limma voom voomWithQualityWeights |
|
|
15 |
#' @importFrom SummarizedExperiment assay |
|
|
16 |
#' @importFrom assertthat assert_that |
|
|
17 |
#' @importFrom methods is |
|
|
18 |
#' |
|
|
19 |
#' @export rnaseq_ic |
|
|
20 |
#' |
|
|
21 |
#' @return \code{EList} object containing voom-transformed expression measures |
|
|
22 |
#' of count data (actually, the mean-variance trend) in the "E" slot, to be |
|
|
23 |
#' passed into the biomarker TMLE procedure. |
|
|
24 |
rnaseq_ic <- function(biotmle, weights = TRUE, ...) { |
|
|
25 |
# check arguments |
|
|
26 |
assertthat::assert_that(is(biotmle, "bioTMLE")) |
|
|
27 |
assertthat::assert_that(is.logical(weights)) |
|
|
28 |
|
|
|
29 |
# extract count data from appropriate slot of SummarizedExperiment object |
|
|
30 |
ngs_data <- tibble::as_tibble(assay(biotmle)) |
|
|
31 |
|
|
|
32 |
# invoke the "voom" transform from LIMMA |
|
|
33 |
if (weights) { |
|
|
34 |
voom_data <- limma::voomWithQualityWeights(ngs_data, |
|
|
35 |
normalize.method = "scale", |
|
|
36 |
... |
|
|
37 |
) |
|
|
38 |
} else { |
|
|
39 |
voom_data <- limma::voom(ngs_data, |
|
|
40 |
normalize.method = "scale", |
|
|
41 |
... |
|
|
42 |
) |
|
|
43 |
} |
|
|
44 |
return(voom_data) |
|
|
45 |
} |