embed: dispatches the different methods for dimensionality reduction

embedR Documentation

dispatches the different methods for dimensionality reduction

Description

wraps around all dimensionality reduction functions.

Usage

embed(.data, ...)

## S4 method for signature 'formula'
embed(
  .formula,
  .data,
  .method = dimRedMethodList(),
  .mute = character(0),
  .keep.org.data = TRUE,
  ...
)

## S4 method for signature 'ANY'
embed(
  .data,
  .method = dimRedMethodList(),
  .mute = character(0),
  .keep.org.data = TRUE,
  ...
)

## S4 method for signature 'dimRedData'
embed(
  .data,
  .method = dimRedMethodList(),
  .mute = character(0),
  .keep.org.data = TRUE,
  ...
)

Arguments

.data

object of class dimRedData, will be converted to be of class dimRedData if necessary; see examples for details.

...

the parameters, internally passed as a list to the dimensionality reduction method as pars = list(...)

.formula

a formula, see as.dimRedData.

.method

character vector naming one of the dimensionality reduction techniques.

.mute

a character vector containing the elements you want to mute (c("message", "output")), defaults to character(0).

.keep.org.data

TRUE/FALSE keep the original data.

Details

Method must be one of dimRedMethodList(), partial matching is performed. All parameters start with a dot, to avoid clashes with partial argument matching (see the R manual section 4.3.2), if there should ever occur any clashes in the arguments, call the function with all arguments named, e.g. embed(.data = dat, .method = "mymethod", .d = "some parameter").

Value

an object of class dimRedResult

Methods (by class)

  • embed(formula): embed a data.frame using a formula.

  • embed(ANY): Embed anything as long as it can be coerced to dimRedData.

  • embed(dimRedData): Embed a dimRedData object

Examples

## embed a data.frame using a formula:
as.data.frame(
  embed(Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width,
        iris, "PCA")
)

## embed a data.frame and return a data.frame
as.data.frame(embed(iris[, 1:4], "PCA"))

## embed a matrix and return a data.frame
as.data.frame(embed(as.matrix(iris[, 1:4]), "PCA"))

## Not run: 
## embed dimRedData objects
embed_methods <- dimRedMethodList()
quality_methods <- dimRedQualityList()
dataset <- loadDataSet("Iris")

quality_results <- matrix(NA, length(embed_methods), length(quality_methods),
                              dimnames = list(embed_methods, quality_methods))
embedded_data <- list()

for (e in embed_methods) {
  message("embedding: ", e)
  embedded_data[[e]] <- embed(dataset, e, .mute = c("message", "output"))
  for (q in quality_methods) {
    message("  quality: ", q)
    quality_results[e, q] <- tryCatch(
      quality(embedded_data[[e]], q),
      error = function(e) NA
    )
  }
}

print(quality_results)

## End(Not run)

gdkrmr/dimRed documentation built on March 23, 2023, 5:44 a.m.