ScreenUpset - Visualize cell type intersections from screened Seurat object
Source:R/31-ScreenUpset.R
ScreenUpset.Rd
This function creates an UpSet plot to visualize intersections between different screening methods (e.g., scissor, scAB, scPAS, scPP) in a Seurat object metadata. It calculates all possible combinations of screening types and displays the number of cells positive for each combination.
Usage
ScreenUpset(
screened_seurat,
screen_type = NULL,
show_plot = TRUE,
n_intersections = 20,
x_lab = "Screen Set Intersections",
y_lab = "Number of Cells",
title = "Cell Counts Across Screen Set Intersections",
bar_color = "#4E79A7",
combmatrix_point_color = "black",
...
)
Arguments
- screened_seurat
A Seurat object containing screening results in metadata. Must contain columns with screening types marked as "Positive".
- screen_type
Character vector of screening types to analyze. Default: NULL, indicating that a self-search pattern will be used.
- show_plot
Whether to show the upset plot. Default: TRUE.
- n_intersections
Number of intersections to display in the plot. Default: 20.
- x_lab
Label for the x-axis. Default: "Screen Set Intersections".
- y_lab
Label for the y-axis. Default: "Number of Cells".
- title
Plot title. Default: "Cell Counts Across Screen Set Intersections".
- bar_color
Color for the bars in the plot. Default: "#4E79A7".
- combmatrix_point_color
Color for points in the combination matrix. Default: "black".
- ...
Additional arguments passed to
ggplot2::theme()
for customizing the plot appearance.
Value
A list containing two elements:
plot
: A ggplot object displaying the UpSet plotstats
: A data frame with intersection statistics including:intersection
: Name of the intersectionsets
: List of screening types in the intersectioncount
: Number of cells positive for all screening types in the intersection
Details
The function performs the following steps:
Validates input parameters and checks if specified screening types exist in metadata
Generates all possible combinations of screening types (from 1 to the total number of types)
Creates a logical matrix of positive cells for efficient computation
Calculates cell counts for each intersection using vectorized operations
Creates an UpSet plot visualization with customizable appearance
Examples
if (FALSE) { # \dontrun{
# Basic usage with default parameters
result <- ScreenUpset(screened_seurat = my_seurat_obj)
print(result$plot)
# Customize screening types and appearance
result <- ScreenUpset(
screened_seurat = my_seurat_obj,
screen_type = c("scissor", "scAB"),
n_intersections = 15,
title = "Custom Title",
bar_color = "darkred"
)
} # }