estimate_uncertainty {baldur}R Documentation

Estimate measurement uncertainty

Description

[Experimental]

Estimates the measurement uncertainty for each data point using a Gamma regression. Calculated as the expected standard deviation for each measurement:

\text{E}[s_i|\omega,y_{ij}]=\exp({f(y_{ij},\omega)})

where \omega are the regression parameters and f is a function describing the mean relationship between s_i and y_{ij}.

Usage

estimate_uncertainty(reg, data, id_col, design_matrix)

## S3 method for class 'glm'
estimate_uncertainty(reg, data, id_col, design_matrix)

## S3 method for class 'lgmr'
estimate_uncertainty(reg, data, id_col, design_matrix)

Arguments

reg

A glm gamma regression or lgmr object

data

A tibble or data.frame

id_col

A character for the name of the column containing the name of the features in data (e.g., peptides, proteins, etc.)

design_matrix

Cell mean design matrix for the data

Value

A matrix with the uncertainty

Examples

# Setup model matrix
design <- model.matrix(~ 0 + factor(rep(1:2, each = 3)))
colnames(design) <- paste0("ng", c(50, 100))

yeast_norm <- yeast %>%
  # Remove missing data
  tidyr::drop_na() %>%
  # Normalize data
  psrn("identifier") %>%
  # Add mean-variance trends
  calculate_mean_sd_trends(design)
# Fit the gamma regression
gam <- fit_gamma_regression(yeast_norm, sd ~ mean)
# Estimate each data point's uncertainty
estimate_uncertainty(gam, yeast_norm, 'identifier', design)

[Package baldur version 0.0.3 Index]