estimate_uncertainty {baldur} | R Documentation |
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}
.
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)
reg |
A |
data |
A |
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 |
A matrix with the uncertainty
# 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)