Construct_con: Construct Contrast Matrix

View source: R/generateRef_limma.R

Construct_conR Documentation

Construct Contrast Matrix

Description

This function creates a contrast matrix for differential analysis, where each phenotype level is contrasted against all other levels combined. This is particularly useful in linear models for comparing multiple groups.

Usage

Construct_con(pheno, mode)

Arguments

pheno

A factor variable with different levels representing groups or conditions to contrast.

mode

Currently unused but reserved for future extensions where different modes of contrast might be implemented.

Value

A square matrix with dimensions equal to the number of levels in 'pheno'. Each row represents a contrast where the corresponding level is compared against the average of others. The matrix elements are set to -1 for non-diagonal cells (indicating comparison groups) and 1 for diagonal cells (indicating the group of interest).

Examples

# Example usage:
pheno <- factor(c("A", "B", "C", "D"))
contrast_matrix <- Construct_con(pheno, mode = NULL)
print(contrast_matrix)

IOBR/IOBR documentation built on Nov. 27, 2024, 6:44 p.m.