Given a SummarizedExperiment
input with a counts or CPM assay, this
function creates additional assays for by computing the CPM, log, or both
of the input assay to be used in further analysis.
Usage
mkAssay(
SE_obj,
input_name = "counts",
output_name = NULL,
log = FALSE,
counts_to_CPM = TRUE,
prior_counts = 3
)
Arguments
- SE_obj
a
SummarizedExperiment
object containing count or CPM data. Required.- input_name
a character string specifying the name of the assay to be referenced for creating additional assays. Default is
"counts"
.- output_name
a character string to use in place of the
input_name
. IfNULL
, theninput_name
will be substituted. Default isNULL
. See Return details for how names are altered.- log
logical. Indicate whether an assay returned should be the log of whichever assay is specified in
"output_name"
. Ifcounts_to_CPM = TRUE
as well, then a log CPM assay will also be created. Default isFALSE
.- counts_to_CPM
logical. This argument only applies if the
input_type
is a counts assay. IfTRUE
, then the output assays will include a normalized CPM assay. Iflog = TRUE
as well, then a log CPM assay will also be created. Default isTRUE
.- prior_counts
a small integer specifying the average count to be added to each observation to avoid taking the log of zero. Used only if
log = TRUE
. The default is3
.
Value
This function returns a SummarizedExperiment
object with up
to 3 additional assay types attached to the original inputted object.
output_name
_cpmCounts per million
- log_
output_name
_cpm Log counts per million
- log_
output_name
Log of original input assay.
Examples
# Create a log assay of the original assay input
# TB_hiv dataset already has counts data
log_only <- mkAssay(TB_hiv, log = TRUE, counts_to_CPM = FALSE)
log_only
#> class: SummarizedExperiment
#> dim: 25369 31
#> metadata(0):
#> assays(2): counts log_counts
#> rownames(25369): DDX11L1 WASH7P ... GOLGA2P3Y GOLGA2P2Y
#> rowData names(0):
#> colnames(31): R01_1 R01_10 ... R02_30 R02_31
#> colData names(2): Sample Disease
# Create a CPM assay
CPM_only <- mkAssay(TB_hiv)
CPM_only
#> class: SummarizedExperiment
#> dim: 25369 31
#> metadata(0):
#> assays(2): counts counts_cpm
#> rownames(25369): DDX11L1 WASH7P ... GOLGA2P3Y GOLGA2P2Y
#> rowData names(0):
#> colnames(31): R01_1 R01_10 ... R02_30 R02_31
#> colData names(2): Sample Disease
# Create a logCPM, logcounts, and CPM assay
all_assays <- mkAssay(TB_hiv, log = TRUE)
all_assays
#> class: SummarizedExperiment
#> dim: 25369 31
#> metadata(0):
#> assays(4): counts log_counts counts_cpm log_counts_cpm
#> rownames(25369): DDX11L1 WASH7P ... GOLGA2P3Y GOLGA2P2Y
#> rowData names(0):
#> colnames(31): R01_1 R01_10 ... R02_30 R02_31
#> colData names(2): Sample Disease