Skip to contents

Method for getting and setting loadings for a ReducedExperiment object.

Usage

# S4 method for class 'FactorisedExperiment'
loadings(
  object,
  scale_loadings = FALSE,
  center_loadings = FALSE,
  abs_loadings = FALSE
)

# S4 method for class 'FactorisedExperiment'
loadings(object) <- value

# S4 method for class 'ModularExperiment'
loadings(
  object,
  scale_loadings = FALSE,
  center_loadings = FALSE,
  abs_loadings = FALSE
)

# S4 method for class 'ModularExperiment'
loadings(object) <- value

Arguments

object

ReducedExperiment object or an object that inherits from this class.

scale_loadings

If TRUE, loadings will be scaled to have a standard deviation of 0. If the loadings are a matrix, this operation is performed column-wise.

center_loadings

If TRUE, loadings will be centered to have a mean of 0. If the loadings are a matrix, this operation is performed column-wise.

abs_loadings

If TRUE, the absolute values of the loadings will be returned.

value

New value to replace existing loadings.

Value

If object is a FactorisedExperiment, the loadings matrix will be returned, with features as rows and reduced components as columns. If object is a ModularExperiment, the loadings will be returned as a vector, with a value for each feature (usually genes).

Details

When available, the module loadings provide the values of the rotation matrix (usually generated by prcomp) used to calculate the sample-level module vectors available in the reduced slot. Normally, these loadings are calculated for each module separately, so their values are not comparable across modules.

Author

Jack Gisby

Examples

# Create ModularExperiment with random data (100 features, 50 samples,
# 10 modules)
me <- ReducedExperiment:::.createRandomisedModularExperiment(100, 50, 10)
me
#> class: ModularExperiment 
#> dim: 100 50 10 
#> metadata(0):
#> assays(1): normal
#> rownames(100): gene_1 gene_2 ... gene_99 gene_100
#> rowData names(0):
#> colnames(50): sample_1 sample_2 ... sample_49 sample_50
#> colData names(0):
#> 10 components

# Retrieve the loadings
loadings(me)[1:10]
#>     gene_1     gene_2     gene_3     gene_4     gene_5     gene_6     gene_7 
#>  0.5476249  0.1934835 -1.5541655  0.0636397  0.1958725 -1.0233546 -0.2377076 
#>     gene_8     gene_9    gene_10 
#> -0.2706039 -2.1030913  1.1520160 

# Change a loading
loadings(me)[9] <- 8
loadings(me)[1:10]
#>     gene_1     gene_2     gene_3     gene_4     gene_5     gene_6     gene_7 
#>  0.5476249  0.1934835 -1.5541655  0.0636397  0.1958725 -1.0233546 -0.2377076 
#>     gene_8     gene_9    gene_10 
#> -0.2706039  8.0000000  1.1520160