composition_plot: This function returns a list where the 1st element is plot...

View source: R/composition_plot.R

composition_plotR Documentation

This function returns a list where the 1st element is plot composition representing the absolute number and proportion of a variable grouped by a feature of interest and the 2nd are the individual plots..

Description

This function returns a list where the 1st element is plot composition representing the absolute number and proportion of a variable grouped by a feature of interest and the 2nd are the individual plots..

Usage

composition_plot(
  metadata,
  x,
  grouping_vr,
  gradient_col = c("#7ab2ff", "#ffc157", "#fa5e25"),
  col_df = NULL,
  x_order = NULL,
  grouping_order = NULL,
  title = "",
  label = FALSE
)

Arguments

metadata

metadata from the Seurat object - se_obj\@meta.data

x

character string indicating the X axis - cell type annotation

grouping_vr

character string specifying the feature to group the data by - condition

gradient_col

vector of n colors indicating the color gradient to use in the proportion tile plot

col_df

data frame with variables name and color containing the name - color pair

x_order

character string vector containing the x names in the desired order

grouping_order

character string vector containing the grouping names in the desired order

title

character string indicating the plot title, by default and empty string ""

label

Logical vector indicating if we want to show proportion labels in the tile plot. By default FALSE.

Value

Composition plot

Examples

## Not run: 
library(Seurat)
library(SeuratData)
# SeuratData::InstallData(ds = "pbmcsca")
se_obj <- SeuratData::LoadData(ds = "pbmcsca")

col_df <- data.frame(
  "name" = unique(se_obj@meta.data$CellType),
  "color" = terrain.colors(10)
)

grouping_order <- c("Cytotoxic T cell", "CD4+ T cell", "CD14+ monocyte", "B cell",
             "Megakaryocyte", "CD16+ monocyte", "Natural killer cell",
             "Dendritic cell", "Plasmacytoid dendritic cell", "Unassigned")
SCrafty::composition_plot(
  metadata = se_obj@meta.data,
  x = "Method",
  grouping_vr = "CellType",
  gradient_col = rainbow(5),
  col_df = col_df,
  x_order = unique(se_obj@meta.data$Method),
  grouping_order = grouping_order,
  title = "Distribution of cells over methods",
  label = TRUE
)


## End(Not run)


Single-Cell-Genomics-Group-CNAG-CRG/SCrafty-package documentation built on Aug. 20, 2022, 9:29 a.m.