Volcano plots, MA plots, histograms of p-values and fold changes, score plots and threshold bar plots for a
table of contrasts with one row per subject and contrast. Obtained from $get_Plotter() of any contrast object.
See also
Other modelling:
AnovaExtractor,
Contrasts,
ContrastsComparison,
ContrastsDEqMSFacade,
ContrastsDEqMSVoomFacade,
ContrastsFacadeBase,
ContrastsFirth,
ContrastsFirthFacade,
ContrastsHurdleFacade,
ContrastsHurdleNestedFacade,
ContrastsLMFacade,
ContrastsLMImputeFacade,
ContrastsLimma,
ContrastsLimmaFacade,
ContrastsLimmaImputeFacade,
ContrastsLimmaVoomFacade,
ContrastsLimmaVoomImputeFacade,
ContrastsLimpaFacade,
ContrastsLimpaNestedFacade,
ContrastsLmerNestedFacade,
ContrastsModerated,
ContrastsModeratedDEqMS,
ContrastsRLMFacade,
ContrastsROPECA,
ContrastsROPECANestedFacade,
ContrastsROPECAV2,
ContrastsROPECAV2NestedFacade,
ContrastsRfitFacade,
ContrastsRfitImputeFacade,
ContrastsTable,
INTERNAL_FUNCTIONS_BY_FAMILY,
Model,
ModelFirth,
ModelLimma,
StrategyLM,
StrategyLimma,
StrategyLimpa,
StrategyLmer,
StrategyLogistf,
StrategyRLM,
StrategyRfit,
build_contrast_analysis(),
build_model(),
build_model_glm_protein(),
build_model_impute(),
build_model_limma(),
build_model_limma_impute(),
build_model_limma_voom(),
build_model_limma_voom_impute(),
build_model_limpa(),
compute_borrowed_variance(),
compute_borrowed_variance_limma(),
df.residual.rfit_prolfqua(),
group_label(),
impute_from_model(),
impute_refit_singular(),
list_facades(),
lookup_facade(),
lr_test(),
merge_contrasts_results(),
new_imputed_model(),
nobs.rfit_prolfqua(),
pivot_model_contrasts_to_wide(),
prolfqua_analysis_methods,
register_facade(),
sigma.rfit_prolfqua(),
strategy_limma(),
strategy_limpa(),
strategy_logistf(),
vcov.rfit_prolfqua()
Other plotting:
INTERNAL_FUNCTIONS_BY_FAMILY,
theme_prolfqua(),
upset_interaction_missing_stats()
Public fields
model_nameof column with model name
subject_idhierarchy key columns
diffcolumn with fold change differences
contrastcolumn with contrasts names, default "contrast"
groupcrosstalk group name for linked brushing, default "BB"
volcano_specvolcano plot specification
score_specscore plot specification
histogram_specplot specification
fcthreshfold change threshold
avg.abundancename of column containing avg abundance values.
Methods
ContrastsPlotter$new()
create ContrastsPlotter
Usage
ContrastsPlotter$new(
contrast_df,
subject_id,
volcano = list(list(score = "FDR", thresh = 0.1)),
histogram = list(list(score = "p.value", breaks = seq(0, 1, by = 0.05)), list(score =
"FDR", breaks = seq(0, 1, by = 0.05))),
score = list(list(score = "statistic", thresh = NULL)),
fcthresh = 1,
modelName = "modelName",
diff = "diff",
contrast = "contrast",
avg.abundance = "avgAbd",
group = "BB"
)Arguments
contrast_dfframe with contrast data
subject_idcolumns containing subject Identifier
volcanowhich score to plot and which ablines to add.
histogramwhich scores to plot, each
list(score = , breaks = );breaksare the bin boundaries passed toggplot2::geom_histogram(), e.g.seq(0, 1, by = 0.05)scorescore parameters
fcthreshdefault 1 (log2 FC threshold)
modelNamename of the colour column. Defaults to
"modelName"; when left at the default and the contrast carries anestimate_typecolumn, that column is used for colouring instead (so observed vs imputed/fallback rows stay distinguishable).difffold change (difference) diff column
contrastcontrast column
avg.abundancename of column with average abundance
groupcrosstalk group name for linked brushing, default "BB"
ContrastsPlotter$volcano()
volcano plots (fold change vs FDR)
Usage
ContrastsPlotter$volcano(
colour = self$model_name,
legend = TRUE,
scales = c("fixed", "free", "free_x", "free_y"),
min_score = NULL
)Arguments
colourcolumn name with color information default modelName
legenddefault TRUE
scalesdefault fixed
facet_wrap, scales argumentmin_scoreoptional lower bound for p-values or FDR values. If NULL, only exact zero and negative values are replaced with the smallest positive observed value in the same score column.
ContrastsPlotter$volcano_plotly()
plotly volcano plots
Usage
ContrastsPlotter$volcano_plotly(
colour = self$model_name,
legend = TRUE,
scales = c("fixed", "free", "free_x", "free_y"),
min_score = NULL
)Arguments
colourcolumn in contrast matrix with colour coding
legenddefault TRUE
scalesdefault fixed
facet_wrap, scales argumentmin_scoreoptional lower bound for p-values or FDR values. If NULL, only exact zero and negative values are replaced with the smallest positive observed value in the same score column.
ContrastsPlotter$ma_plot()
ma plot
MA plot displays the effect size estimate as a function of the mean protein intensity across groups. Each dot represents an observed protein. Red horizontal lines represent the fold-change threshold.
Sometimes measured effects sizes (differences between samples groups) are biased by the signal intensity (here protein abundance). Such systematic effects can be explored using MA-plots.
Usage
ContrastsPlotter$ma_plot(
fc = self$fcthresh,
colour = self$model_name,
legend = TRUE,
rank = TRUE
)ContrastsPlotter$ma_plotly()
ma plotly
Usage
ContrastsPlotter$ma_plotly(
fc = self$fcthresh,
colour = self$model_name,
legend = TRUE,
rank = FALSE
)ContrastsPlotter$score_plot()
plot a score against the log2 fc e.g. t-statistic
Examples
istar <- sim_lfq_data_peptide_config(n_proteins = 20)
#> `protein_Id`: columns `proteinID`, `idtype2` united with separator '~'.
#> creating sampleName from file_name column
#> setup_analysis: dropped 6 unconfigured columns: average_prot_abundance, sd, mean, N, avg_peptide_abd, Replicate.
#> setup_analysis: added 110 rows with NA response for feature and sample combinations absent from the input.
model_name <- "Model"
modelFunction <-
strategy_lmer("abundance ~ group_ + (1 | peptide_Id) + (1|sample)",
model_name = model_name)
pepIntensity <- istar$data
config <- istar$config
mod <- build_model(
pepIntensity,
modelFunction,
model_name = model_name,
subject_id = config$hierarchy_keys_depth())
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> Warning: fit (Model): 7 fits failed (e.g. 0EfVhX~5954, 7cbcrd~8305, CGzoYe~2857, Fl4JiV~7526, JV3Z7t~2956, ...): Error: grouping factors must have > 1 sampled level
#> See $provenance().
#> fit (Model): 13 singular fits (e.g. 0m5WN4~1448, 9VUkAq~4562, At886V~3296, BEJI92~9143, CtOJ9t~2837, ...): coefficients not estimable or fewer than 2 residual df
#> fit (Model): 102 missing responses dropped (e.g. 0m5WN4~1448, 9VUkAq~4562, At886V~3296, BEJI92~9143, CtOJ9t~2837, ...): NA response (missing observation) left out of the fit
#> See $provenance().
Contr <- c("group_A_vs_Ctrl" = "group_A - group_Ctrl",
"group_B_vs_Ctrl" = "group_B - group_Ctrl"
)
contrast <- prolfqua::Contrasts$new(mod,
Contr)
contr <- contrast$get_contrasts()
cp <- ContrastsPlotter$new(contr,
contrast$subject_id,
volcano = list(list(score = "FDR", thresh = 0.1)),
histogram = list(list(score = "p.value", breaks = seq(0, 1, by = 0.05)),
list(score = "FDR", breaks = seq(0, 1, by = 0.05))),
score =list(list(score = "statistic", thresh = 5))
)
stopifnot("plotly" %in% class(cp$volcano_plotly()$FDR))
stopifnot("ggplot" %in% class(cp$score_plot(legend=FALSE)$statistic))
p <- cp$histogram()
stopifnot("ggplot" %in% class(p$FDR))
stopifnot("ggplot" %in% class(p$p.value))
res <- cp$volcano()
stopifnot("ggplot" %in% class(res$FDR))
res_plotly <- cp$volcano_plotly()
stopifnot("plotly" %in% class(res_plotly$FDR))
stopifnot("ggplot" %in% class(cp$ma_plot()))
stopifnot("plotly" %in% class(cp$ma_plotly(rank=TRUE)))
res <- cp$barplot_threshold()
stopifnot("ggplot" %in% class(res$FDR$plot))
stopifnot("ggplot" %in% class(cp$histogram_diff()))