plot_sa {baldur}R Documentation

Plot the trend between the log fold-change and sigma, coloring significant hits

Description

[Experimental]

plot_sa returns a ggplot with a graphical representation between the log fold-change and sigma.

Usage

plot_sa(results, alpha = 0.05, lfc = NULL)

Arguments

results

Output generated by baldur::infer_data_and_decision_model

alpha

Significance cut-off; used to draw a line indicating where significance starts

lfc

LFC cut-off; used to draw lines for abs(lfc), if NULL no lines are drawn

Value

plot_sa returns a ggplot object

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
unc <- estimate_uncertainty(gam, yeast_norm, "identifier", design)
yeast_norm <- gam %>%
   # Add hyper-priors for sigma
   estimate_gamma_hyperparameters(yeast_norm)
# Setup contrast matrix
contrast <- matrix(c(-1, 1), 2)

results <- yeast_norm %>%
  head() %>% # Just run a few for the example
  infer_data_and_decision_model(
    'identifier',
    design,
    contrast,
    unc,
    clusters = 1 # I highly recommend increasing the number of parallel workers/clusters
                 # this will greatly reduce the speed of running baldur
  )
  # Plot with alpha = 0.05
  plot_sa(results, alpha = 0.05)
  # Plot with alpha = 0.01 and show LFC = 1
  plot_sa(results, alpha = 0.01, 1)


[Package baldur version 0.0.3 Index]