SplitRW: SplitRW

View source: R/SplitRW.R

SplitRWR Documentation

SplitRW

Description

Splits a multi-block into a replicate-wise (RW) structure by expanding each block along its batch dimension. Each batch within each original block becomes a separate block in the output, enabling replicate-wise ComDim analysis.

Usage

SplitRW(
  MB = MB,
  checkSampleCorrespondence = FALSE,
  batchNormalisation = TRUE,
  showSampleCorrespondence = TRUE
)

Arguments

MB

A MultiBlock object built with MultiBlock(). Must contain Batch information; blocks without batch labels are treated as a single batch.

checkSampleCorrespondence

Logical. If FALSE (default), identical sample order and count are assumed across all batches and only the minimum batch size is used. If TRUE, sample names are intersected across all batches and only common samples are retained, which is safer when batches have different sizes or orderings.

batchNormalisation

Logical. If TRUE (default), each replicate block is divided by its Frobenius norm and by the square root of the number of replicates in its original block, to prevent blocks with more replicates from dominating the analysis.

showSampleCorrespondence

Logical. If TRUE (default), the matrix of sample names assigned to each replicate block is printed to the console via print(). Set to FALSE to suppress this output.

Details

Output block names follow the convention <original_block> when the original block has only one batch, or <original_block>_<batch_label> when it has multiple batches. The Metadata slot of each source block is also split and carried over to the corresponding replicate blocks. If the MultiBlock has no Batch information at all, the original object is returned unchanged with a warning.

Value

A MultiBlock object in which each block corresponds to one batch of one original data block (a replicate-wise structure ready for ComDim_PCA or similar).

See Also

MultiBlock, ComDim_PCA, SelectFeaturesRW

Examples

b1 <- matrix(rnorm(1500), 30, 50)
b2 <- matrix(rnorm(2400), 30, 80)
batch_b <- c(rep(1, 10), rep(2, 10), rep(3, 10))
# Generate the multi-block (mb) with 3 batches of 10 samples each
mb <- MultiBlock(
  Data = list(b1 = b1, b2 = b2),
  Batch = list(b1 = batch_b, b2 = batch_b),
  ignore.names = TRUE
)
rw <- SplitRW(mb)

R.ComDim documentation built on May 13, 2026, 9:07 a.m.