Skip to contents

This function creates a structured result object (Res) for storing residual model information extracted from spectral flow scc file. It validates the input raw signal matrix R and the unmixing matrix A, ensuring that their dimensions and identifiers are compatible. If valid, it returns a list containing initialized fields for further analysis.

Usage

CreateRes(id, R, A_Target, A_AF)

Arguments

id

A character string representing the identifier for the result object. If missing, defaults to "x".

R

A numeric matrix of raw signal data (cells × detectors), typically extracted from an FCS file.

A

A numeric unmixing matrix (detectors × fluors), typically extracted from a single-stained control (SCC) FCS file.

Value

A named list representing the initialized residual modeling object (Res) with the following components:

id

Character string identifier for the residual object. Defaults to "x" if not provided.

R

Numeric matrix of raw signal data (cells × detectors), subset to match A's rownames.

A

Numeric unmixing matrix (detectors × fluors), with validated row and column names. For one fluorescence, here is the signature of it.

detectors

Character vector of detector names, extracted from rownames(A).

fluors

Character vector of fluor names, extracted from colnames(A) or auto-assigned.

par

List of analysis parameters, including:

bin_num

Number of bins used in residual modeling (default NA).

bin_method

Binning method used (e.g., "equal-width", "quantile"; default NA).

count_thre

Threshold for minimum bin count (default NA).

bin_mids

Numeric vector of bin midpoints (default NA).

bin_counts

Numeric vector of bin counts (default NA).

cov_matrices

List of covariance matrices per bin (default NA).

interceptMtx

Matrix of intercepts from bin-wise regression (default NA).

slopMtx

Matrix of slopes from bin-wise regression (default NA).

The CreateRes function is used together with SlopEstimation function to fill in most contents in the ResObj. See SlopEstimation for more detail.

Examples

if (FALSE) { # \dontrun{
R <- matrix(runif(100), nrow = 10, ncol = 5)
colnames(R) <- paste0("D", 1:5)
A <- matrix(runif(25), nrow = 5, ncol = 5)
rownames(A) <- paste0("D", 1:5)
colnames(A) <- paste0("F", 1:5)
Res <- CreateRes("Sample1", R, A)
} # }