Plot a scatter of the principal coordinates from an object generated by perform.PCoA.

# S3 method for class 'PCoA.scatter'
plot(
  DEprot.PCoA.object,
  PCo.x = 2,
  PCo.y = 1,
  color.column = "column.id",
  shape.column = NULL,
  label.column = NULL,
  plot.zero.line.x = TRUE,
  plot.zero.line.y = TRUE
)

Arguments

DEprot.PCoA.object

An object of class DEprot.PCoA, as generated by perform.PCoA.

PCo.x

Number indicating which Principal Coordinate (PCo) to display on the x-axis. Default: 2 (PCo2).

PCo.y

Number indicating which Principal Coordinate (PCo) to display on the y-axis. Default: 1 (PCo1).

color.column

String indicating the name of the column in the metadata to use as factor for the dot colors. Default: "column.id" (each sample a color).

shape.column

String indicating the name of the column in the metadata to use as factor for the dot shapes. Default: NULL (all dots).

label.column

String indicating the name of the column in the metadata to use as label of the dots. Default: NULL (no labeling).

plot.zero.line.x

Logical value to indicate whether to plot a gray dashed line in correspondence of x=0. Default: TRUE.

plot.zero.line.y

Logical value to indicate whether to plot a gray dashed line in correspondence of y=0. Default: TRUE.

Value

A ggplot object.

Details

The axis labels report the proportion of variance of each principal coordinate, computed using only the positive eigenvalues as denominator (see perform.PCoA). Axes corresponding to a negative eigenvalue have no real representation and raise an error.

Author

Sebastian Gregoricchio

Examples

# Compute the sample correlations and the PCoA
correlation <- plot.correlation.heatmap(DEprot.object = DEprot::test.toolbox$dpo.imp,
                                        correlation.method = "spearman")

pcoa <- perform.PCoA(DEprot.correlation.object = correlation)
#> Only 7 of the 11 principal coordinates requested correspond to a positive eigenvalue and could be computed.
#> The dissimilarities are not euclidean-embeddable: 4 negative eigenvalue(s) detected (largest relative magnitude = 0.083).
#>        The negative eigenvalues are non-negligible. Consider using 'distance.transformation = "sqrt"' or 'correction = "cailliez"'/'correction = "lingoes"'.
#>        The proportions of variance are computed using only the positive eigenvalues as denominator.

# Plot the PCo1-vs-PCo2 scatter
plot.PCoA.scatter(DEprot.PCoA.object = pcoa,
                  PCo.x = 1,
                  PCo.y = 2,
                  color.column = "condition",
                  shape.column = "replicate",
                  label.column = "replicate")