plot_hexbin_meta {schex} | R Documentation

## Plot of meta data of single cell data in bivariate hexagon cells.

### Description

Plot of meta data of single cell data in bivariate hexagon cells.

### Usage

    plot_hexbin_meta(
      sce,
      col,
      action,
      no = 1,
      colors = NULL,
      title = NULL,
      xlab = NULL,
      ylab = NULL,
      na.rm = FALSE
    )

### Arguments

`sce` | A `SingleCellExperiment` or `Seurat-class` object.
`col` | A string referring to the name of one column in the meta data of sce by which to colour the hexagons.
`action` | A string specifying how meta data of observations in binned hexagon cells are to be summarized. Possible actions are `majority`, `prop`, `prop_0`, `mode`, `mean` and `median` (see details).
`no` | An integer specifying which level to plot of the column. Only in effect when `action=prop`.
`colors` | A vector of strings specifying which colors to use for plotting the different levels in the selected column of the meta data. Only in effect when the selected `action="majority"`.
`title` | A string containing the title of the plot.
`xlab` | A string containing the title of the x axis.
`ylab` | A string containing the title of the y axis.
`na.rm` | Logical indicating whether NA values should be removed.

### Details

This function plots any column of the meta data in the hexagon cell representation calculated with `make_hexbin`. The chosen meta data column is summarized by one of six actions `majority`, `prop`, `prop_0`, `mode`, `mean` and `median`:

`majority`

  Returns the value of the majority of observations in the bin. The associated meta data column needs to be a factor or character.

`prop`

  Returns the proportion of each level or unique character in the bin. The associated meta data column needs to be a factor or character.

`prop_0`

  Returns the proportion of observations in the bin greater than 0. The associated meta data column needs to be numeric.

`mode`

  Returns the mode of the observations in the bin. The associated meta data column needs to be numeric.

`mean`

  Returns the mean of the observations in the bin. The associated meta data column needs to be numeric.

`median`

  Returns the median of the observations in the bin. The associated meta data column needs to be numeric.

### Value

A `ggplot2{ggplot}` object.

### Examples

    #' # For Seurat object
    library(Seurat)
    data("pbmc_small")
    pbmc_small <- make_hexbin(pbmc_small, 10, dimension_reduction = "PCA")
    plot_hexbin_meta(pbmc_small, col="RNA_snn_res.1", action="prop", no=1)
    # For SingleCellExperiment object
    ## Not run:
    library(TENxPBMCData)
    library(scater)
    tenx_pbmc3k <- TENxPBMCData(dataset = "pbmc3k")
    rm_ind <- calculateAverage(tenx_pbmc3k) < 0.1
    tenx_pbmc3k <- tenx_pbmc3k[-rm_ind, ]
    colData(tenx_pbmc3k) <- cbind(
      colData(tenx_pbmc3k),
      perCellQCMetrics(tenx_pbmc3k)
    )
    tenx_pbmc3k <- logNormCounts(tenx_pbmc3k)
    tenx_pbmc3k <- runPCA(tenx_pbmc3k)
    tenx_pbmc3k <- make_hexbin(tenx_pbmc3k, 20, dimension_reduction = "PCA")
    plot_hexbin_meta(tenx_pbmc3k, col = "total", action = "median")

    ## End(Not run)

[Package schex version 1.6.3 Index]