AddMetadata: AddMetadata

View source: R/AddMetadata.R

AddMetadataR Documentation

AddMetadata

Description

Adds or overwrites batch and/or metadata information for one or more blocks of an existing MultiBlock object.

Usage

AddMetadata(MB, block = NULL, batches = NULL, metadata = NULL)

Arguments

MB

A MultiBlock object.

block

The name of the block to modify (character). If NULL and the MultiBlock contains a single block, that block is used automatically. To modify several blocks at once, pass a character vector of block names.

batches

A numeric vector of batch labels, one per sample in the target block. Replaces any existing Batch entry for that block.

metadata

A data.frame with one row per sample in the target block. Replaces any existing Metadata entry for that block.

Value

The updated MultiBlock.

See Also

MultiBlock, FilterSamplesMultiBlock

Examples

b1 <- matrix(rnorm(500), 10, 50) # 10 samples, 50 variables
b2 <- matrix(rnorm(800), 10, 80) # 10 samples, 80 variables
batch_b1 <- rep(1, 10)
meta_b1 <- data.frame(condition = rep(c("A", "B"), 5))
mb <- MultiBlock(Data = list(b1 = b1, b2 = b2))
# Add batch information to block 'b1':
mb <- AddMetadata(mb, block = "b1", batches = batch_b1)
# Add (or overwrite) metadata for block 'b1':
mb <- AddMetadata(mb, block = "b1", metadata = meta_b1)

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