Plots a boxplot of the expression of a specific protein. Samples can be groups depending on a metadata column. Optionally, the p-values of all the pairwise (2-by-2) comparisons between groups can be added on top of the plot.

expression.boxplot(
  DEprot.object,
  protein.id,
  which.data = "imputed",
  sample.subset = NULL,
  shape.column = NULL,
  group.by.metadata.column = "column.id",
  group.levels = NULL,
  scale.expression = FALSE,
  x.label.angle = 30,
  pairwise.comparisons = FALSE,
  pairwise.test.type = "wilcox.test",
  pairwise.include.ns = TRUE,
  pairwise.p.label = "p.signif",
  pairwise.p.decimals = 2
)

Arguments

DEprot.object

An object of class DEprot or DEprot.analyses.

protein.id

String indicating a protein for which plot the expression. The identifier must correspond to the full row.name of the counts table (equivalent to the prot.id column of the fold change table of DEprot.analyses object).

which.data

String indicating which type of counts should be used. One among: 'raw', 'normalized', 'norm', 'imputed', 'randomized', 'random', 'imp'. Default: "imputed".

sample.subset

Character vector indicating a subset of samples to display. The identifiers must correspond to a IDs in the column.id column of the object's metadata. Default: NULL (all samples are shown).

shape.column

String indicating a column from the metadata table. This column will be used as factor for the shape of the points on the boxplot. Default: NULL: no different shapes.

group.by.metadata.column

String indicating a column from the metadata table. This column will be used to define sample groups, and for each group it will be computed a mean of the counts. Default: "column.id" (no groups).

group.levels

Ordered string vector indicating the order to use for the groups. Default: NULL, counts table order will be applied

scale.expression

Logic value indicating whether Z-scores should be computed. Default: FALSE (no scaling).

x.label.angle

Numeric value indicating the rotation angle to use for the x-axis labels. Default: 30.

pairwise.comparisons

Logical value indicating whether the p-values of all the pairwise (2-by-2) comparisons between the groups should be added on top of the boxplot using ggpubr. When TRUE, a comparison is computed for each possible pair of groups defined by group.by.metadata.column. Default: FALSE.

pairwise.test.type

String indicating the statistical test to use for the pairwise comparisons. Any of the ggpubr-supported tests is accepted and the value is case/format-insensitive: capitalization, dots, spaces and hyphens are ignored (e.g. "wilcox.test", "Wilcoxon", "WILCOX", "mann-whitney" are all equivalent). Supported families: "t.test" (Student's/Welch t-test), "wilcox.test" (Wilcoxon/Mann-Whitney), "anova" and "kruskal.test". Since the comparisons are performed 2-by-2, the two latter are applied through their exact two-sample equivalents ("anova" -> pooled t-test, "kruskal.test" -> Wilcoxon rank-sum). Default: "wilcox.test".

pairwise.include.ns

Logical value indicating whether the non-significant comparisons (p > 0.05) should be displayed. If FALSE, only the significant comparisons are shown. Default: TRUE.

pairwise.p.label

String indicating how the pairwise p-values should be displayed (case/format-insensitive). Use "p.signif" (aliases: "stars", "significance", "symbol") to show the significance symbols (ns, *, **, ***, ****) drawn directly by ggpubr::stat_compare_means, or "p.value" (aliases: "number", "numeric", "exact") to show the numeric p-value. Default: "p.signif".

pairwise.p.decimals

Numeric value indicating the number of decimals used to approximate the numeric p-values (used only when pairwise.p.label shows the numeric value). Values below 0.1 are rendered in scientific notation with a superscript exponent, e.g. 3.20×10-2. The actual (real) p-value is always displayed, so the uninformative p < 2.2e-16 is never shown. Default: 2.

Value

A boxplot of class ggplot2.

Author

Sebastian Gregoricchio

Examples

# Expression for all samples of protein 'protein.44'
expression.boxplot(DEprot.object = DEprot::test.toolbox$dpo.imp,
                   protein.id = "protein.44",
                   shape.column = "replicate")



# Expression of protein 'protein.44' grouped by condition (combined.id)
expression.boxplot(DEprot.object = DEprot::test.toolbox$dpo.imp,
                   protein.id = "protein.44",
                   group.by.metadata.column = "combined.id")



# Expression of protein 'protein.44' grouped by condition (combined.id) and Z-scored
expression.boxplot(DEprot.object = DEprot::test.toolbox$dpo.imp,
                   protein.id = "protein.44",
                   group.by.metadata.column = "combined.id",
                   scale.expression = TRUE)



# Pairwise comparisons between conditions (significance symbols, Wilcoxon test)
expression.boxplot(DEprot.object = DEprot::test.toolbox$dpo.imp,
                   protein.id = "protein.44",
                   group.by.metadata.column = "combined.id",
                   pairwise.comparisons = TRUE)
#> `stat_compare_means()` with `comparisons` displays *unadjusted* p-values (no correction for multiple comparisons).
#>  For p-values adjusted for multiple comparisons, use `geom_pwc()`, or `stat_pvalue_manual()` together with `compare_means(..., p.adjust.method = )`.
#> This message is displayed once per session.



# Pairwise comparisons showing the exact numeric p-value
expression.boxplot(DEprot.object = DEprot::test.toolbox$dpo.imp,
                   protein.id = "protein.44",
                   group.by.metadata.column = "combined.id",
                   pairwise.comparisons = TRUE,
                   pairwise.test.type = "t.test",
                   pairwise.p.label = "stars",
                   pairwise.p.decimals = 3,
                   pairwise.include.ns = FALSE)