Plotting mean-variance fit for precision weights estimation
Source:R/plot_weights.R
plot_weights.Rd
Display the variability with respect to the level of expression and the associated smoothed estimation of precision weights accounting for heteroscedasticity.
Arguments
- x
a list (such as outputed by the functions
sp_weights
orvoom_weights
) containing the following components:weights
: a matrixn x G
containing the estimated precision weightsplot_utilities
: a list containing the following elements:reverse_trans
: a function encoding the reverse function used for smoothing the observations before computing the weightsmethod
: the weight computation method (either"voom"
or"loclin"
)smth
: the vector of the smoothed values computedgene_based
: a logical indicating whether the computed weights are based on average at the gene level or on individual observationsmu
: the transformed observed counts or averagesv
: the observed variability estimates
Value
a ggplot
object
Examples
G <- 10000
n <- 12
p <- 2
y <- sapply(1:n, FUN = function(x){rnbinom(n = G, size = 0.07, mu = 200)})
x <- sapply(1:p, FUN = function(x){rnorm(n = n, mean = n, sd = 1)})
if(interactive()){
w <- sp_weights(y, x, use_phi=FALSE, na.rm = TRUE, gene_based=TRUE)
plot_weights(w)
vw <- voom_weights(y, x)
plot_weights(vw)
}