pbMDS: Pseudobulk-level MDS plot

View source: R/pbMDS.R

pbMDSR Documentation

Pseudobulk-level MDS plot

Description

Pseudobulk-level Multi-Dimensional Scaling (MDS) plot computed on median marker expressions in each sample.

Usage

pbMDS(
  x,
  by = c("sample_id", "cluster_id", "both"),
  k = "meta20",
  dims = c(1, 2),
  features = NULL,
  assay = "exprs",
  fun = c("median", "mean", "sum"),
  color_by = switch(by, sample_id = "condition", "cluster_id"),
  label_by = if (by == "sample_id") "sample_id" else NULL,
  shape_by = NULL,
  size_by = is.null(shape_by),
  pal = if (color_by == "cluster_id") .cluster_cols else NULL
)

Arguments

x

a SingleCellExperiment.

by

character string specifying whether to aggregate by sample_id, cluster_id or both.

k

character string specifying which clustering to use when by != "sample_id"; valid values are names(cluster_codes(x)).

dims

two numeric scalars indicating which dimensions to plot.

features

character string specifying which features to include for computation of reduced dimensions; valid values are "type"/"state" for type/state_markers(x) if rowData(x)$marker_class have been specified; a subset of rownames(x); NULL to use all features.

assay

character string specifying which assay data to use; valid values are assayNames(x).

fun

character string specifying which summary statistic to use.

color_by

character string specifying a non-numeric cell metadata column to color by; valid values are names(colData(x)).

label_by

character string specifying a non-numeric cell metadata column to label by; valid values are names(colData(x)).

shape_by

character string specifying a non-numeric cell metadata column to shape by; valid values are names(colData(x)).

size_by

logical specifying whether points should be sized by the number of cells that went into aggregation; i.e., the size of a give sample, cluster or cluster-sample instance.

pal

character vector of colors to use; NULL for default ggplot2 colors.

Value

a ggplot object.

Author(s)

Helena L Crowell helena.crowell@uzh.ch

References

Nowicka M, Krieg C, Crowell HL, Weber LM et al. CyTOF workflow: Differential discovery in high-throughput high-dimensional cytometry datasets. F1000Research 2017, 6:748 (doi: 10.12688/f1000research.11622.1)

Examples

data(PBMC_fs, PBMC_panel, PBMC_md)
sce <- prepData(PBMC_fs, PBMC_panel, PBMC_md)
sce <- cluster(sce)

# sample-level pseudobulks
# including state-markers only
pbMDS(sce, by = "sample_id", features = "state")

# cluster-level pseudobulks
# including type-features only
pbMDS(sce, by = "cluster_id", features = "type")

# pseudobulks by cluster-sample 
# including all features
pbMDS(sce, by = "both", k = "meta12", 
  shape_by = "condition", size_by = TRUE)


HelenaLC/CATALYST documentation built on Nov. 30, 2024, 4:04 a.m.