Skip to contents

Computes and visualizes cell composition changes from a Seurat object using Scanpro. Integrates R and Python via reticulate to convert Seurat to AnnData and run Scanpro. Generates customizable plots with options for transformation, grouping, and bootstrapping. Returns a ggplot object or a list containing plot data and visualization.

Usage

DO.CellComposition(
  Seu_object,
  assay_normalized = "RNA",
  cluster_column = "seurat_clusters",
  sample_column = "orig.ident",
  condition_column = "condition",
  transform_method = "logit",
  sort_x = NULL,
  sub_ident = NULL,
  sort_fill = NULL,
  scanpro_plots = F,
  scanpro_group = NULL,
  outputFolder = NULL,
  return_df = FALSE,
  bar_colors = NULL,
  n_reps = NULL,
  legend.pos.x = 0.48,
  legend.pos.y = 0,
  cowplot_width = 0.9,
  cowlegend_width = 0.9,
  ...
)

Arguments

Seu_object

The seurat object

assay_normalized

Assay with raw counts

cluster_column

Column in meta data which will be used to segment the bar plot

sample_column

Column in meta data containing individual sample names

condition_column

Column in meta data plotted on the xaxis

transform_method

Method of transformation of proporties, default: "logit"

sort_x

Vector sorting the xaxis

sub_ident

vector to subset the whole plot by

sort_fill

Vector sorting the bar segments

scanpro_plots

Boolean, will create plots provided in scanpro package, default: FALSE

scanpro_group

Defines the clusters showed in scanpro plots

outputFolder

Scanpro plots will be saved in this directory, defaults to current working directory

return_df

Boolean, makes a list with first entry beeaing the dataframe used to create the ggplot and second entry is the plot

bar_colors

(named) vector of colors used for plotting, the names will be sued to factorize the segments

n_reps

Number of replicates generated by scanpro

legend.pos.x

adjusts the position of the legend in horizontal

legend.pos.y

adjusts the position of the legend in vertical

cowplot_width

Changes the width on the plotting device for plot

cowlegend_width

Changes the width on the plotting device for legend, useful for adjusting the legend position in combination with legend.pos.x and y

...

Further arguments passed to scanpro plotting functions

Value

ggplot object or list

Author

Mariano Ruz Jurado

Examples

if (FALSE) { # \dontrun{


DO.CellComposition(
  Seu_object = Seurat,
  cluster_column="cell_type",
  condition_column="condition",
  scanpro_plots=T,
  bar_colors=c("#ff7f0e","tomato2", "darkgoldenrod2","#aec7e8"), # can also be a named vector
  n_reps=5)



} # }