A set of utility functions designed to facilitate operations with TreeSummarizedExperiment objects

getReducedDimAttribute(x, ...)

# S4 method for class 'SingleCellExperiment'
getReducedDimAttribute(x, dimred = 1L, name = NULL, ...)

Arguments

x

a SummarizedExperiment object.

...

additional arguments, not used currently.

dimred

Character scalar or integer scalar. A name or index of dimension reduction results. (Default: 1L)

name

Character vector. A name of values retrieved from attributes of reducedDim(x, dimred). If NULL, all the values are retrieved. (Default: NULL)

Value

The extracted element from the reducedDim attribute.

Details

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.

See also

Examples

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             9.401622e-04
#> Acidobacteria   3.489370e-02
#> Actinobacteria  1.345863e-01
#> Armatimonadetes 5.063777e-04
#> BRC1            6.804572e-05
#> Bacteroidetes   3.202046e-01