ProcessMultiBlock: ProcessMultiBlock

View source: R/ProcessMultiBlock.R

ProcessMultiBlockR Documentation

ProcessMultiBlock

Description

Apply a custom function to Process the MultiBlocks and/or to select some blocks. If multiple functions are used, the order followed is FUN, FUN.SelectVars, and FUN.SelecBlocks.

Usage

ProcessMultiBlock(
  MB = MB,
  blocks = NULL,
  vars = NULL,
  FUN = NULL,
  FUN.SelectVars = NULL,
  FUN.SelectBlocks = NULL
)

Arguments

MB

The MultiBlocks structure.

blocks

The blocks to apply the processing. It can be a vector of integers or a vector with the block names. Facultative.

vars

The variables to kept. It is a list object with the same length as 'blocks'. Each element in the list contains the position of the variables in the nth block.

FUN

The function used for data processing.

FUN.SelectVars

The function used to select variables. If applied to a numeric data matrix, it should return a vector of TRUE/FALSE with the same length as ncol.

FUN.SelectBlocks

The function used to select blocks. If applied to a numeric data matrix, it should return TRUE/FALSE.

Value

The MultiBlock

Examples

b1 = matrix(rnorm(500),10,50)
b2 = matrix(rnorm(800),10,80)
# Build MultiBlock by adding one data block at a time:0))
mb <- BuildMultiBlock(b1, newSamples = paste0('sample_',1:1
mb <- BuildMultiBlock(b2, growingMB = mb)
# Prepare custom functions
BY100 <- function(x) { 100*(x/max(x)) } # Normalize each block to 100%
norm100000 <- function(x){norm(x)>100000} # Keep blocks with a norm higher than 100000.
thr5 <- function(x) {x > max(x, na.rm = TRUE) * 0.05} # Keep variables larger than 5% in the block.
mb <- ProcessMultiBlock(MB, FUN = BY100, FUN.SelectBlocks = norm100000, FUN.SelectVars = thr5)

f-puig/R.ComDim documentation built on Feb. 20, 2024, 6:49 a.m.