| Title: | Interactive Cluster Selector for Cytometry Data |
|---|---|
| Description: | Provides an interactive Shiny application for selecting and visualizing clusters from flow cytometry data stored in SingleCellExperiment objects. |
| Authors: | Bernd Jagla [aut, cre]
|
| Maintainer: | Bernd Jagla <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.99.7 |
| Built: | 2026-06-21 09:49:23 UTC |
| Source: | https://github.com/BiocStaging/CySA |
Creates an interactive Shiny dashboard for selecting and visualizing clusters from a SingleCellExperiment object.
clusterSelector( sce, sce_subsampled, outputList = list(), colTree = NULL, dList, dend, dendTable, clusterPatientTable, somCodesName = "SOM_codes", nPlots = 6, somRasterData, somRasterObj, env = environment() )clusterSelector( sce, sce_subsampled, outputList = list(), colTree = NULL, dList, dend, dendTable, clusterPatientTable, somCodesName = "SOM_codes", nPlots = 6, somRasterData, somRasterObj, env = environment() )
sce |
A |
sce_subsampled |
A subsampled |
outputList |
A named list of cluster groupings. |
colTree |
Optional collapsible tree object. |
dList |
List of marker pairs for 2D plots. |
dend |
Dendrogram object. |
dendTable |
Data frame for dendrogram navigation. |
clusterPatientTable |
Table of sample by cluster counts. |
somCodesName |
Name of the SOM codes metadata slot. |
nPlots |
Number of 2D SOM plots to display. |
somRasterData |
Data frame for SOM raster visualization. |
somRasterObj |
Raster object for SOM visualization. |
env |
Environment used to store mutable state (legacy argument). |
A shinyApp object. Launch the app with
shiny::runApp(app).
sce <- CySA_example_sce() prepped <- prepClusterSelectorData(sce, total_cells_to_sample = 100) som_codes <- S4Vectors::metadata(sce)$SOM_codes dend <- stats::as.dendrogram(stats::hclust(stats::dist(som_codes))) dendTable <- data.frame( id = seq_len(nrow(som_codes)), label = rownames(som_codes), stringsAsFactors = FALSE ) clusterPatientTable <- table( sample_id = sce$sample_id, cluster_id = sce$cluster_id ) markers <- S4Vectors::metadata(sce)$map$colsUsed somRasterData <- data.frame( x = rep(seq_len(5), length.out = nrow(som_codes)), y = rep(seq_len(2), each = nrow(som_codes) / 2), id = seq_len(nrow(som_codes)) ) for (m in markers) { somRasterData[[m]] <- seq_len(nrow(som_codes)) / nrow(som_codes) } arr <- array( data = seq_len(10 * 10 * length(markers)), dim = c(10, 10, length(markers)) ) somRasterObj <- raster::brick(arr) names(somRasterObj) <- markers app <- clusterSelector( sce = prepped$sce, sce_subsampled = prepped$sce_subsampled, dList = prepped$dList, dend = dend, dendTable = dendTable, clusterPatientTable = clusterPatientTable, somRasterData = somRasterData, somRasterObj = somRasterObj ) if (interactive()) { shiny::runApp(app) }sce <- CySA_example_sce() prepped <- prepClusterSelectorData(sce, total_cells_to_sample = 100) som_codes <- S4Vectors::metadata(sce)$SOM_codes dend <- stats::as.dendrogram(stats::hclust(stats::dist(som_codes))) dendTable <- data.frame( id = seq_len(nrow(som_codes)), label = rownames(som_codes), stringsAsFactors = FALSE ) clusterPatientTable <- table( sample_id = sce$sample_id, cluster_id = sce$cluster_id ) markers <- S4Vectors::metadata(sce)$map$colsUsed somRasterData <- data.frame( x = rep(seq_len(5), length.out = nrow(som_codes)), y = rep(seq_len(2), each = nrow(som_codes) / 2), id = seq_len(nrow(som_codes)) ) for (m in markers) { somRasterData[[m]] <- seq_len(nrow(som_codes)) / nrow(som_codes) } arr <- array( data = seq_len(10 * 10 * length(markers)), dim = c(10, 10, length(markers)) ) somRasterObj <- raster::brick(arr) names(somRasterObj) <- markers app <- clusterSelector( sce = prepped$sce, sce_subsampled = prepped$sce_subsampled, dList = prepped$dList, dend = dend, dendTable = dendTable, clusterPatientTable = clusterPatientTable, somRasterData = somRasterData, somRasterObj = somRasterObj ) if (interactive()) { shiny::runApp(app) }
Returns the default 20-color palette used by CySA for cluster visualizations.
CySA_default_cluster_cols()CySA_default_cluster_cols()
A character vector of hex colors.
CySA_default_cluster_cols()CySA_default_cluster_cols()
Creates a small, deterministic SingleCellExperiment object that
contains the metadata and column data expected by CySA functions.
CySA_example_sce(n_cells = 1000, n_nodes = 50, n_markers = 12)CySA_example_sce(n_cells = 1000, n_nodes = 50, n_markers = 12)
n_cells |
Number of cells (columns). |
n_nodes |
Number of SOM nodes. |
n_markers |
Number of markers (rows). |
A SingleCellExperiment with
SOM_codes, SOM_stats, sample_id, and
cluster_id.
sce <- CySA_example_sce() head(S4Vectors::metadata(sce)$SOM_codes)sce <- CySA_example_sce() head(S4Vectors::metadata(sce)$SOM_codes)
This function generates a scatter plot for a Bioconductor Experiment object.
plotScatterBJ( x, chs, gate = NULL, color_by = NULL, facet_by = NULL, bins = 100, assay = "exprs", label = c("target", "channel", "both"), zeros = FALSE, k_pal = NULL, rowNames = NULL )plotScatterBJ( x, chs, gate = NULL, color_by = NULL, facet_by = NULL, bins = 100, assay = "exprs", label = c("target", "channel", "both"), zeros = FALSE, k_pal = NULL, rowNames = NULL )
x |
A Bioconductor Experiment object. |
chs |
A character vector specifying the variables to be plotted on the x and y axes. |
gate |
Optional gate object. |
color_by |
A character specifying the variable used for color coding points (optional). |
facet_by |
A character specifying the variable used for faceting the plot (optional). |
bins |
Number of bins for the 2D histogram (default is 100). |
assay |
The assay to use for plotting (default is "exprs"). |
label |
Label for points on the plot ("target", "channel", or "both"). |
zeros |
Logical, whether to exclude rows with all zero values (default is FALSE). |
k_pal |
Color palette for plotting. |
rowNames |
Optional character vector to specify row names for the plot. |
A ggplot2 scatter plot.
sce <- CySA_example_sce() plotScatterBJ(sce, chs = c("marker1", "marker2"))sce <- CySA_example_sce() plotScatterBJ(sce, chs = c("marker1", "marker2"))
Bivariate scatter plots including visualization of (group-specific) gates, their boundaries and percentage of selected cells.
plotSOMScatter( x, chs, metaSlot = "SOM_codes", pointSize = "n", color_by = "n", bins = 100, assay = "exprs", statsSlot = "SOM_stats", label = c("target", "channel", "both"), zeros = FALSE, k_pal = NULL, xRN = NULL, xCN = NULL )plotSOMScatter( x, chs, metaSlot = "SOM_codes", pointSize = "n", color_by = "n", bins = 100, assay = "exprs", statsSlot = "SOM_stats", label = c("target", "channel", "both"), zeros = FALSE, k_pal = NULL, xRN = NULL, xCN = NULL )
x |
|
chs |
character vector specifying which channels to plot. |
metaSlot |
name of the metadata slot containing SOM codes. |
pointSize |
column in SOM stats used to size points. |
color_by |
column to color points by. |
bins |
number of bins when coloring by density. |
assay |
name of the assay to use. |
statsSlot |
name of the metadata slot containing SOM stats. |
label |
how axis labels should be constructed. |
zeros |
logical specifying whether to include 0 values. |
k_pal |
optional cluster color palette. |
xRN |
optional row names. |
xCN |
optional channel names. |
a ggplot object.
sce <- CySA_example_sce() plotSOMScatter(sce, chs = c("marker1", "marker2"))sce <- CySA_example_sce() plotSOMScatter(sce, chs = c("marker1", "marker2"))
Subsamples a SingleCellExperiment object and builds the inputs
required by clusterSelector.
prepClusterSelectorData( sce, somFile = NULL, dList = NULL, total_cells_to_sample = 1e+05, somCodesName = "SOM_codes", assay = "exprs", seed = 123 )prepClusterSelectorData( sce, somFile = NULL, dList = NULL, total_cells_to_sample = 1e+05, somCodesName = "SOM_codes", assay = "exprs", seed = 123 )
sce |
A |
somFile |
Path to the SOM object. Used to cache/restore the subsampled version. |
dList |
Optional list of marker pairs for 2D plots. If |
total_cells_to_sample |
Number of cells to subsample in total. |
somCodesName |
Name of the SOM codes metadata slot. |
assay |
Name of the assay to use. |
seed |
Random seed for reproducibility. |
A list with sce, sce_subsampled, and dList.
sce <- CySA_example_sce(n_cells = 200, n_nodes = 10) prepped <- prepClusterSelectorData(sce, total_cells_to_sample = 100) names(prepped)sce <- CySA_example_sce(n_cells = 200, n_nodes = 10) prepped <- prepClusterSelectorData(sce, total_cells_to_sample = 100) names(prepped)