plot_hexbin_feature: Plot of feature expression of single cells in bivariate...

Description Usage Arguments Details Value Examples

View source: R/plot_hexbin_feature.R

Description

Plot of feature expression of single cells in bivariate hexagon cells.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
plot_hexbin_feature(
  sce,
  mod = "RNA",
  type,
  feature,
  action,
  title = NULL,
  xlab = NULL,
  ylab = NULL,
  lower_cutoff = 0,
  upper_cutoff = 1
)

Arguments

sce

A SingleCellExperiment or Seurat-class object.

mod

A string referring to the name of the modality used for plotting. For RNA modality use "RNA". For other modalities use name of alternative object for the SingleCellExperiment or the name of the assay for the Seurat-class object.

type

A string referring to the type of assay in the SingleCellExperiment object or the data transformation in the Seurat-class object.

feature

A string referring to the name of one feature.

action

A strings pecifying how meta data of observations in binned hexagon cells are to be summarized. Possible actions are prop_0, mode, mean and median (see details).

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.

lower_cutoff

For mode, mean and median actions, remove expression values below this quantile. Expressed as decimal. Default: 0

upper_cutoff

For mode, mean and median actions, remove expression values above this quantile. Expressed as decimal. Default: 1

Details

This function plots the expression of any feature in the hexagon cell representation calculated with make_hexbin. The chosen gene expression is summarized by one of four actions prop_0, mode, mean and median:

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.

To access the data that has been integrated in the Seurat-class object specifiy mod="integrated".

Value

A ggplot2{ggplot} object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# For Seurat object
library(Seurat)
data("pbmc_small")
pbmc_small <- make_hexbin(pbmc_small, 10, dimension_reduction = "PCA")
plot_hexbin_feature(pbmc_small, type="counts", feature="TALDO1", 
   action="median")
plot_hexbin_feature(pbmc_small, type="counts", feature="TALDO1", 
   action="median", lower_cutoff=0.2, upper_cutoff=0.5)
# For SingleCellExperiment object
## Not run: 
library(TENxPBMCData)
library(scater)
tenx_pbmc3k <- TENxPBMCData(dataset = "pbmc3k")
rm_ind <- calcAverage(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_feature(tenx_pbmc3k, type="logcounts",
   feature="ENSG00000135250", action="median")
plot_hexbin_feature(tenx_pbmc3k, type="logcounts",
   feature="ENSG00000135250", action="mode")

## End(Not run)
# For other modalities in Seurat object
library(Seurat)
data("pbmc_small")
pbmc_small <- make_hexbin(pbmc_small, 10, dimension_reduction = "PCA")
protein <- matrix(rnorm(10* ncol(pbmc_small)), ncol=ncol(pbmc_small))
rownames(protein) <- paste0("A", seq(1,10,1))
colnames(protein) <- colnames(pbmc_small)
pbmc_small[["ADT"]] <- CreateAssayObject(counts = protein)
pbmc_small <- make_hexbin(pbmc_small, 10, dimension_reduction = "PCA")
plot_hexbin_feature(pbmc_small, type="counts", mod="ADT",
    feature="A1", action="prop_0")

schex documentation built on Nov. 8, 2020, 5:56 p.m.