plot contrasts
Description
plot contrasts
Value
An R6 class generator.
Public fields
model_name
-
of column with model name
subject_id
-
hierarchy key columns
diff
-
column with fold change differences
contrast
-
column with contrasts names, default "contrast"
group
-
crosstalk group name for linked brushing, default "BB"
volcano_spec
-
volcano plot specification
score_spec
-
score plot specification
histogram_spec
-
plot specification
fcthresh
-
fold change threshold
avg.abundance
-
name of column containing avg abundance values.
Methods
Public 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", xlim = c(0, 1, 0.05)), list(score = "FDR",
xlim = c(0, 1, 0.05))),
score = list(list(score = "statistic", thresh = NULL)),
fcthresh = 1,
modelName = "modelName",
diff = "diff",
contrast = "contrast",
avg.abundance = "avgAbd",
group = "BB"
)
Arguments
contrast_df
-
frame with contrast data
subject_id
-
columns containing subject Identifier
volcano
-
which score to plot and which ablines to add.
histogram
-
which scores to plot and which range (x) should be shown.
score
-
score parameters
fcthresh
-
default 1 (log2 FC threshold)
modelName
-
name of the colour column. Defaults to "modelName";
when left at the default and the contrast carries an estimate_type
column, that column is used for colouring instead (so observed vs
imputed/fallback rows stay distinguishable).
diff
-
fold change (difference) diff column
contrast
-
contrast column
avg.abundance
-
name of column with average abundance
group
-
crosstalk group name for linked brushing, default "BB"
ContrastsPlotter$histogram()
plot histogram of selected scores (e.g. p-value, FDR, t-statistics)
Usage
ContrastsPlotter$histogram()
ContrastsPlotter$histogram_diff()
plot histogram of differences (diff) fold change
Usage
ContrastsPlotter$histogram_diff(binwidth = 0.05)
Arguments
binwidth
-
with of bin in histogram
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
colour
-
column name with color information default modelName
legend
-
default TRUE
scales
-
default fixed facet_wrap, scales argument
min_score
-
optional 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
colour
-
column in contrast matrix with colour coding
legend
-
default TRUE
scales
-
default fixed facet_wrap, scales argument
min_score
-
optional 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.
Returns
list of ggplots
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
)
Arguments
fc
-
fold change abline
colour
-
column in contrast matrix with colour coding
legend
-
enable legend default TRUE
rank
-
default FALSE, if TRUE then rank of avgAbd is used.
Returns
ggplot
ContrastsPlotter$ma_plotly()
ma plotly
Usage
ContrastsPlotter$ma_plotly(
fc = self$fcthresh,
colour = self$model_name,
legend = TRUE,
rank = FALSE
)
Arguments
fc
-
horizontal lines
colour
-
column in contrast matrix with colour coding.
legend
-
enable legend default TRUE
rank
-
default FALSE, if TRUE then rank of avgAbd is used.
Returns
list of ggplots
ContrastsPlotter$score_plot()
plot a score against the log2 fc e.g. t-statistic
Usage
ContrastsPlotter$score_plot(scorespec, colour = self$model_name, legend = TRUE)
Arguments
scorespec
-
list(score="statistics", fcthres = 2, thresh = 5)
colour
-
column with colour coding
legend
-
enable legend default TRUE
Returns
list of ggplots
ContrastsPlotter$barplot_threshold()
shows the number of significant proteins per contrasts
Usage
ContrastsPlotter$barplot_threshold()
Returns
list which contains ggplots and summary tables
ContrastsPlotter$clone()
The objects of this class are cloneable with this method.
Usage
ContrastsPlotter$clone(deep = FALSE)
Arguments
deep
-
Whether to make a deep clone.
See Also
Other modelling:
AnovaExtractor,
Contrasts,
ContrastsDEqMSFacade,
ContrastsDEqMSVoomFacade,
ContrastsFacadeBase,
ContrastsFirth,
ContrastsFirthFacade,
ContrastsFirthNestedFacade,
ContrastsHurdleFacade,
ContrastsHurdleNestedFacade,
ContrastsLMFacade,
ContrastsLMImputeFacade,
ContrastsLimma,
ContrastsLimmaFacade,
ContrastsLimmaImputeFacade,
ContrastsLimmaVoomFacade,
ContrastsLimmaVoomImputeFacade,
ContrastsLimpaFacade,
ContrastsLimpaNestedFacade,
ContrastsLmerNestedFacade,
ContrastsModerated,
ContrastsModeratedDEqMS,
ContrastsRLMFacade,
ContrastsROPECA,
ContrastsROPECANestedFacade,
ContrastsRfitFacade,
ContrastsRfitImputeFacade,
ContrastsTable,
INTERNAL_FUNCTIONS_BY_FAMILY,
LR_test(),
Model,
ModelFirth,
ModelLimma,
StrategyLM,
StrategyLimma,
StrategyLimpa,
StrategyLmer,
StrategyLogistf,
StrategyRLM,
StrategyRfit,
build_contrast_analysis(),
build_model(),
build_model_glm_peptide(),
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(),
build_model_logistf(),
compute_borrowed_variance(),
compute_borrowed_variance_limma(),
compute_contrast(),
compute_lmer_contrast(),
df.residual.rfit_prolfqua(),
get_anova_df(),
get_complete_model_fit(),
get_p_values_pbeta(),
group_label(),
impute_from_model(),
impute_refit_singular(),
linfct_from_model(),
linfct_matrix_contrasts(),
list_facades(),
lookup_facade(),
merge_contrasts_results(),
model_analyse(),
model_summary(),
moderated_p_deqms(),
moderated_p_deqms_long(),
moderated_p_limma(),
new_imputed_model(),
pivot_model_contrasts_to_wide(),
register_facade(),
sigma.rfit_prolfqua(),
sim_build_models_lm(),
sim_build_models_lmer(),
sim_build_models_logistf(),
sim_make_model_lm(),
sim_make_model_lmer(),
strategy_limma(),
strategy_limpa(),
strategy_logistf(),
summary_ROPECA_median_p_scaled(),
vcov.rfit_prolfqua()
Other plotting:
INTERNAL_FUNCTIONS_BY_FAMILY,
missigness_histogram(),
missingness_per_condition(),
missingness_per_condition_cumsum(),
plot_estimate(),
plot_heatmap(),
plot_heatmap_cor(),
plot_hierarchies_boxplot_df(),
plot_hierarchies_line(),
plot_intensity_distribution_violin(),
plot_na_heatmap(),
plot_pca(),
plot_raster(),
plot_sample_correlation(),
upset_interaction_missing_stats(),
upset_missing_stats()
Examples
istar <- sim_lfq_data_peptide_config(Nprot = 20)
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())
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", xlim = c(0,1,0.05)),
list(score = "FDR", xlim = c(0,1,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()))
istar <- sim_lfq_data_peptide_config(Nprot = 20)
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())
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", xlim = c(0,1,0.05)),
list(score = "FDR", xlim = c(0,1,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()))