TreeSummarizedExperiment objectsR/AllGenerics.R, R/utilization_functions.R
utilization_functions.RdA set of utility functions designed to facilitate operations with
TreeSummarizedExperiment objects
getReducedDimAttribute(x, ...)
convertToMAE(x, ...)
convertToTreeSE(x, ...)
# S4 method for class 'SingleCellExperiment'
getReducedDimAttribute(x, dimred = 1L, name = NULL, ...)
# S4 method for class 'SingleCellExperiment'
convertToMAE(x, ...)
# S4 method for class 'MultiAssayExperiment'
convertToTreeSE(x, ...)a SummarizedExperiment object.
additional arguments, not used currently.
Character scalar or integer scalar. A name or
index of dimension reduction results. (Default: 1L)
Character vector. A name of values retrieved from
attributes of reducedDim(x, dimred). If NULL, all the values
are retrieved. (Default: NULL)
The extracted element from the reducedDim attribute.
getReducedDimAttribute is a utility function that retrieves specific
elements from the attributes of reducedDim in a
TreeSummarizedExperiment object. These attributes may contain
loadings, statistical test results, or other metadata, depending on the
methods used to generate the results.
data(GlobalPatterns)
tse <- GlobalPatterns
# Reduce the number of features
tse <- agglomerateByPrevalence(tse, rank = "Phylum")
# Run NMF and add the result to reducedDim(tse, "NMF").
tse <- addNMF(tse, k = 1, name = "NMF")
#> NMF - BioConductor layer [OK] | Shared memory capabilities [NO: bigmemory] | Cores 2/2
#> To enable shared memory capabilities, try: install.extras('
#> NMF
#> ')
#>
#> Attaching package: ‘NMF’
#> The following object is masked from ‘package:S4Vectors’:
#>
#> nrun
#> The following object is masked from ‘package:generics’:
#>
#> fit
# Extract feature loadings
res <- getReducedDimAttribute(tse, dimred = "NMF", name = "loadings")
res |> head()
#> [,1]
#> AD3 8.402178e-04
#> Acidobacteria 3.118431e-02
#> Actinobacteria 1.202791e-01
#> Armatimonadetes 4.525469e-04
#> BRC1 6.081208e-05
#> Bacteroidetes 2.861651e-01
# Convert MultiAssayExperiment to TreeSE
data(HintikkaXOData)
convertToTreeSE(HintikkaXOData)
#> class: TreeSummarizedExperiment
#> dim: 12706 40
#> metadata(0):
#> assays(1): counts
#> rownames(12706): GAYR01026362.62.2014 CVJT01000011.50.2173 ...
#> JRJTB:03787:02429 JRJTB:03787:02478
#> rowData names(7): Phylum Class ... Species OTU
#> colnames(40): C1 C2 ... C39 C40
#> colData names(6): Sample Rat ... Fat XOS
#> reducedDimNames(0):
#> mainExpName: microbiota
#> altExpNames(2): metabolites biomarkers
#> rowLinks: NULL
#> rowTree: NULL
#> colLinks: NULL
#> colTree: NULL