Learn R Programming

specmine (version 4.0.0)

ica_analysis_dataset: ICA analysis

Description

Performs Independent Component Analysis (ICA) on a specmine dataset using the FastICA algorithm.

Usage

ica_analysis_dataset(
  dataset,
  n_components = 2,
  alg.typ = "parallel",
  fun = "logcosh",
  maxit = 200,
  tol = 1e-04,
  scale = FALSE,
  seed = 42,
  write.file = FALSE,
  file.out = NULL,
  ...
)

Value

A list containing:

  • embedding: the independent component scores;

  • S: the estimated source matrix;

  • A: the estimated mixing matrix;

  • K: the whitening matrix;

  • W: the estimated unmixing matrix;

  • loadings: the component loadings;

  • params: the analysis parameters.

Arguments

dataset

Dataset to analyse.

n_components

Number of independent components to extract.

alg.typ

Algorithm used by FastICA. Supported values include "parallel" and "deflation".

fun

Contrast function used by FastICA. Supported values include "logcosh" and "exp".

maxit

Maximum number of iterations.

tol

Convergence tolerance.

scale

Logical indicating whether the data should be scaled before ICA.

seed

Random seed used for reproducibility.

write.file

Logical indicating whether the independent components should be written to a CSV file.

file.out

Output file prefix used when write.file = TRUE.

...

Additional arguments passed to fastICA::fastICA().

Examples

Run this code
if (requireNamespace("fastICA", quietly = TRUE)) {
  datamat <- matrix(
    rnorm(240),
    nrow = 8,
    dimnames = list(
      paste0("feature", 1:8),
      paste0("sample", 1:30)
    )
  )

  dataset <- list(
    data = datamat,
    metadata = data.frame(
      class = factor(rep(c("A", "B"), each = 15))
    )
  )

  ica.result <- ica_analysis_dataset(
    dataset,
    n_components = 2,
    maxit = 100,
    seed = 42
  )

  dim(ica.result$embedding)
}

Run the code above in your browser using DataLab