FracFixR: FracFixR: Main Function for Fraction Correction

View source: R/fracfixr.r

FracFixRR Documentation

FracFixR: Main Function for Fraction Correction

Description

This is the core function that implements the FracFixR framework. It takes raw count data from total and fractionated samples and reconstructs the original fraction proportions through compositional modeling.

Usage

FracFixR(MatrixCounts, Annotation, st1 = 0.6, st2 = 0.999, parallel = TRUE)

Arguments

MatrixCounts

A numeric matrix of raw transcript/gene counts with:

  • Rows: transcripts/genes (must have rownames)

  • Columns: samples (must have colnames matching Annotation$Sample)

Annotation

A data.frame with required columns:

  • Sample: sample identifiers matching column names in MatrixCounts

  • Condition: experimental condition (e.g., "Control", "Treatment")

  • Type: fraction type (must include at least one "Total")

  • Replicate: replicate identifier

parallel

A boolean indicating whether to use parallel processing of the transcripts (default=TRUE).

st1

Lower quantile threshold (between 0 and 1) for selecting informative transcripts for the NNLS regression fit (default = 0.6). Transcripts below this quantile of Total abundance are considered too noisy for reliable regression.

st2

Upper quantile threshold (between 0 and 1) for selecting informative transcripts for the NNLS regression fit (default = 0.999). Transcripts above this quantile are potential outliers and are excluded from the regression.

Details

The function works by:

  1. Filtering transcripts based on presence in Total samples

  2. For each condition and replicate, fitting NNLS regression

  3. Estimating global fraction weights and individual transcript proportions

  4. Calculating the "lost" unrecoverable fraction

Value

A list containing:

  • OriginalData: filtered input count matrix

  • Annotation: input annotation data

  • Propestimates: matrix of proportion estimates (values between 0 and 1)

  • NewData: corrected count matrix (proportions multiplied by predicted total, rounded)

  • Coefficients: data.frame of regression coefficients

  • Fractions: data.frame of estimated fraction proportions

  • plots: list of diagnostic plots

References

Cleynen et al. FracFixR: A compositional statistical framework for absolute proportion estimation between fractions in RNA sequencing data.

Examples

# Load example data
data(example_counts)
data(example_annotation)

# Run FracFixR
results <- FracFixR(example_counts, example_annotation, parallel=FALSE)

# View fraction proportions
print(results$Fractions)


FracFixR documentation built on May 11, 2026, 9:09 a.m.