weitrix_calibrate_trend {weitrix} | R Documentation |
Dispersions are estimated using weitrix_dispersions
.
A trend line is then fitted to the dispersions using a gamma GLM
with log link function.
Weitrix weights are calibrated based on this trend line.
weitrix_calibrate_trend(weitrix, design = ~1, trend_formula = NULL)
weitrix |
A weitrix object, or an object that can be converted to a weitrix
with |
design |
A formula in terms of |
trend_formula |
A formula specification for predicting log dispersion from columns of rowData(weitrix). If absent, metadata(weitrix)$weitrix$calibrate_trend_formula is used. |
A SummarizedExperiment object with metadata fields marking it as a weitrix.
Several columns are added to the rowData
:
deg_free Degrees of freedom for dispersion calculation.
dispersion_before Dispersion before calibration.
dispersion_trend Fitted dispersion trend.
dispersion_after Dispersion for these new weights.
rowData(simwei)$total_weight <- rowSums(weitrix_weights(simwei)) # To estimate dispersions, use a simple model containing only an intercept # term. Model log dispersion as a straight line relationship with log total # weight and adjust weights to remove any trend. cal <- weitrix_calibrate_trend(simwei,~1,trend_formula=~log(total_weight)) # This dataset has few rows, so calibration like this is dubious. # Predictors in the fitted model are not significant. summary( metadata(cal)$weitrix$trend_fit ) # Information about the calibration is added to rowData rowData(cal) # A Components object may also be used as the design argument. comp <- weitrix_components(simwei, p=1, verbose=FALSE) cal2 <- weitrix_calibrate_trend(simwei,comp,trend_formula=~log(total_weight)) rowData(cal2)