plotColData {scater} | R Documentation

## Plot column metadata

### Description

Plot column-level (i.e., cell) metadata in an SingleCellExperiment object.

### Usage

    plotColData(
      object,
      y,
      x = NULL,
      colour_by = NULL,
      shape_by = NULL,
      size_by = NULL,
      by_exprs_values = "logcounts",
      other_fields = list(),
      ...
    )

### Arguments

`object` | A SingleCellExperiment object containing expression values and experimental information.
`y` | String specifying the column-level metadata field to show on the y-axis. Alternatively, an AsIs vector or data.frame, see `?retrieveCellInfo`.
`x` | String specifying the column-level metadata to show on the x-axis. Alternatively, an AsIs vector or data.frame, see `?retrieveCellInfo`. If `NULL`, nothing is shown on the x-axis.
`colour_by` | Specification of a column metadata field or a feature to colour by, see the `by` argument in `?retrieveCellInfo` for possible values.
`shape_by` | Specification of a column metadata field or a feature to shape by, see the `by` argument in `?retrieveCellInfo` for possible values.
`size_by` | Specification of a column metadata field or a feature to size by, see the `by` argument in `?retrieveCellInfo` for possible values.
`by_exprs_values` | A string or integer scalar specifying which assay to obtain expression values from, for use in point aesthetics - see `?retrieveCellInfo` for details.
`other_fields` | Additional cell-based fields to include in the data.frame, see `?"scater-plot-args"` for details.
`...` | Additional arguments for visualization, see `?"scater-plot-args"` for details.

### Details

If `y` is continuous and `x=NULL`, a violin plot is generated. If `x` is categorical, a grouped violin plot will be generated, with one violin for each level of `x`. If `x` is continuous, a scatter plot will be generated.

If `y` is categorical and `x` is continuous, horizontal violin plots will be generated. If `x` is missing or categorical, rectangule plots will be generated where the area of a rectangle is proportional to the number of points for a combination of factors.

### Value

A ggplot object.

### Author(s)

Davis McCarthy, with modifications by Aaron Lun

### Examples

    example_sce <- mockSCE()
    example_sce <- logNormCounts(example_sce)
    colData(example_sce) <- cbind(colData(example_sce),
        perCellQCMetrics(example_sce))

    plotColData(example_sce, y = "detected", x = "sum",
       colour_by = "Mutation_Status") + scale_x_log10()

    plotColData(example_sce, y = "detected", x = "sum",
       colour_by = "Mutation_Status", size_by = "Gene_0001",
       shape_by = "Treatment") + scale_x_log10()

    plotColData(example_sce, y = "Treatment", x = "sum",
       colour_by = "Mutation_Status") + scale_y_log10() # flipped violin.

    plotColData(example_sce, y = "detected",
       x = "Cell_Cycle", colour_by = "Mutation_Status")

[Package scater version 1.16.2 Index]