Skip to contents

Performs independent component analysis (ICA) and packages both the input data and subsequent results into a FactorisedExperiment container. Calls runICA to perform the analysis; see its documentation page for more information on the ICA method, parameters and outputs.

Usage

estimateFactors(
  X,
  nc,
  center_X = TRUE,
  scale_X = FALSE,
  assay_name = "normal",
  ...
)

Arguments

X

Either a SummarizedExperiment object or a matrix containing data to be subject to ICA. X should have rows as features and columns as samples.

nc

The number of components to be identified. See estimateStability for a method to estimate the optimal number of components.

center_X

If TRUE, X is centered (i.e., features / rows are transformed to have a mean of 0) prior to ICA. Generally recommended.

scale_X

If TRUE, X is scaled (i.e., features / rows are transformed to have a standard deviation of 1) before ICA.

assay_name

If X is a SummarizedExperiment, then this should be the name of the assay to be subject to ICA.

...

Additional arguments to be passed to runICA.

Value

A FactorisedExperiment is returned containing the input data (i.e., the original data matrix in addition to other slots if a SummarizedExperiment was used as input). Additionally contains the results of factor analysis, stored in the reduced and loadings slots. The center_X, scale_X and stability slots may also be filled depending on the arguments given to estimateFactors.

See also

Author

Jack Gisby

Examples

# Get a random matrix with rnorm, with 100 rows (features)
# and 20 columns (observations)
X <- ReducedExperiment:::.makeRandomData(100, 20, "feature", "obs")

# Estimate 5 factors based on the data matrix
set.seed(1)
fe_1 <- estimateFactors(X, nc = 5)
fe_1
#> class: FactorisedExperiment 
#> dim: 100 20 5 
#> metadata(0):
#> assays(2): normal transformed
#> rownames(100): feature_1 feature_2 ... feature_99 feature_100
#> rowData names(0):
#> colnames(20): obs_1 obs_2 ... obs_19 obs_20
#> colData names(0):
#> 5 components

# Convert the data matrix to a SummarizedExperiment, then estimate 5 factors
se <- SummarizedExperiment(assays = list("normal" = X))
set.seed(1)
fe_2 <- estimateFactors(se, nc = 5)
fe_2
#> class: FactorisedExperiment 
#> dim: 100 20 5 
#> metadata(0):
#> assays(2): normal transformed
#> rownames(100): feature_1 feature_2 ... feature_99 feature_100
#> rowData names(0):
#> colnames(20): obs_1 obs_2 ... obs_19 obs_20
#> colData names(0):
#> 5 components