This is a very flexible method of calibrating weights. It should be especially useful if your existing weights account for technical variation, but there is also biological variation. In this case large weights will tend to be overly optimistic, and a non-linear transformation of weights is needed.
1 2 3 4 5 6 7 8
A weitrix object, or an object that can be converted to a weitrix
A formula in terms of
A formula specification for predicting squared residuals. See below. If absent, metadata(weitrix)$weitrix$calibrate_all_formula is used.
When fitting the GLM, omit observations where the estimated mu is less than this value. When calculating weights from the fitted GLM, clip mu to be at least this value.
When fitting the GLM, omit observations where the estimated mu is greater than this value. When calculating weights from the fitted GLM, clip mu to be at most this value.
Keep glm fit and the data used to create it. This can be large!
If TRUE, these will be stored in
Residuals are found relative to a fitted model. A trend model is then fitted to the squared residuals using a gamma GLM with log link function. Weitrix weights are set based on the inverse of the fitted trend.
Residuals from a fitted model are generally smaller than residuals from the true model. A simple adjustment to the weights is made to account for this. Weights are reduced by a factor of (n-ncol(design)*nrow(weitrix))/n where n is the number of non-missing values in the weitrix.
trend_formula may reference any row or column variables,
mu for the predicted value,
weight for the existing weights,
or special factors
Keep in mind also that a log link function is used.
existing weights must be explicitly included in the formula
if they are to be retained (see examples).
This function is currently not memory efficient,
it should be fine for bulk experiments but may struggle for single cell.
To reduce memory usage somewhat,
when constructing the data frame on which to fit the glm,
only columns referenced in
trend_formula are included.
Apply a global scaling, otherwise keeping weights the same.
Moderate weights by raising them to some power
and applying some overall scaling factor.
This will allow for biological variation.
Apply a more complex quadratic curve-based moderation of weights.
Calibrate each sample's weights by a scaling factor.
Note that due to the simplistic adjustment for using a fitted model rather
than the true model, this may give misleading results when
the design is unbalanced and there are few samples,
i.e. when there are some samples with much higher leverage than others.
Quadratic curve moderation of weights, applied to each sample individually.
A SummarizedExperiment object with metadata fields marking it as a weitrix.
metadata(weitrix)$weitrix will contain the fitted trend model,
and if requested the data frame used to fit the model.
1 2 3
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.