| Title: | Identifying the Frequency of Polyfunctional Antigen-Specific T cells in ICS Flow Cytometry Data |
|---|---|
| Description: | polyICSFlow systematically identifies all cytokine combinations detected in an intracellular cytokine staining (ICS) flow cytometry assay and quantifies polyfunctional antigen-specific responses to single or multiple antigens. The package also offers versatile plotting options for efficient data exploration and visualization of cytokine co-expression profiles. |
| Authors: | Lisa Loksø Dietz [aut, cre] (ORCID: <https://orcid.org/0000-0002-1797-5766>), Sofie Van Gassen [aut] (ORCID: <https://orcid.org/0000-0002-7119-5330>), Sarah Bonte [aut] (ORCID: <https://orcid.org/0000-0002-0637-4893>), Yvan Saeys [aut] (ORCID: <https://orcid.org/0000-0002-0415-1506>), Ole Schmeltz Søgaard [aut] (ORCID: <https://orcid.org/0000-0001-9107-2023>) |
| Maintainer: | Lisa Loksø Dietz <[email protected]> |
| License: | GPL (>=2) |
| Version: | 0.99.3 |
| Built: | 2026-06-11 21:26:32 UTC |
| Source: | https://github.com/BiocStaging/polyICSFlow |
Assing each cell to a combination of gated markers.
assignMarkerCombinations(data_markerPos, mode = c("simple", "exhaustive"))assignMarkerCombinations(data_markerPos, mode = c("simple", "exhaustive"))
data_markerPos |
A data.frame where each row is a cell and each column is a gated marker describing
whether a cell is included in the gate, as constructed by the |
mode |
Character string specifying the level of detail in the polyfunctionality assignment.
If |
The input data.frame with three extra columns describing
MarkerComb: A factor describing which marker combination a specific cell has. Describes
the exact combinations, which are mutually exclusive (e.g., 4 markers → 2⁴ = 16 combinations).
MarkerCount: An integer describing the number of functions of the cell (count of positive markers).
Functionality: A factor grouping MarkerCount) into three categories; No cytokines (MarkerCount == 0),
Monofunctional (MarkerCount == 1), or Polyfunctional (MarkerCount > 1).
getMarkerPositivity, calcPolyfunctionality
# Define path to data path_data <- system.file("extdata", package = "polyICSFlow") # Read fcs files as flowSet fs <- flowCore::read.flowSet(path = path_data, pattern = ".fcs", truncate_max_range = FALSE, transformation = FALSE) # Create GatingSet gs <- flowWorkspace::GatingSet(fs) # Apply GatingTemplate gt <- openCyto::gatingTemplate(file.path(path_data, "gatingTemp_cytokines.csv")) openCyto::gt_gating(x = gt, y = gs) # Get marker positivity per cell df_markerPos <- getMarkerPositivity(x = gs, gate_names = c("IFN+","TNFa+","IL2+","CD107a+")) # Assign marker combinations to each cell based on marker positivity # Simple mode df_markerComb <- assignMarkerCombinations(data_markerPos = df_markerPos, mode = "simple") # Exhaustive mode df_markerComb <- assignMarkerCombinations(data_markerPos = df_markerPos, mode = "exhaustive")# Define path to data path_data <- system.file("extdata", package = "polyICSFlow") # Read fcs files as flowSet fs <- flowCore::read.flowSet(path = path_data, pattern = ".fcs", truncate_max_range = FALSE, transformation = FALSE) # Create GatingSet gs <- flowWorkspace::GatingSet(fs) # Apply GatingTemplate gt <- openCyto::gatingTemplate(file.path(path_data, "gatingTemp_cytokines.csv")) openCyto::gt_gating(x = gt, y = gs) # Get marker positivity per cell df_markerPos <- getMarkerPositivity(x = gs, gate_names = c("IFN+","TNFa+","IL2+","CD107a+")) # Assign marker combinations to each cell based on marker positivity # Simple mode df_markerComb <- assignMarkerCombinations(data_markerPos = df_markerPos, mode = "simple") # Exhaustive mode df_markerComb <- assignMarkerCombinations(data_markerPos = df_markerPos, mode = "exhaustive")
Calculate the frequency of cells positive for each marker combination within a defined population and subtract the corresponding background. Negative values are set to zero.
calcPolyfunctionality( x, md_cols, pop_col = "cell_type", resolution = "MarkerComb", condition_col = "Stimulation", background_val = "unstimulated" )calcPolyfunctionality( x, md_cols, pop_col = "cell_type", resolution = "MarkerComb", condition_col = "Stimulation", background_val = "unstimulated" )
x |
A dataframe generated by the |
md_cols |
A character vector specifying the names of metadata columns in |
pop_col |
A string giving the name of the column in |
resolution |
A string specifying the column in |
condition_col |
A string giving the name of the column in |
background_val |
A value from |
A dataframe similar to x, with the addition of four new columns:
n_cells_pos: Number of positive cells
n_cells_tot: Number of total cells
perc_pos: Percentage positive cells, i.e.
(n_cells_pos/n_cells_tot)*100
perc_pos_backgroundSubtracted: Percentage positive cells with
corresponding background subtracted. Negative values are set to zero.
getMarkerPositivity, assignMarkerCombinations
# Define path to data path_data <- system.file("extdata", package = "polyICSFlow") # Read fcs files as flowSet fs <- flowCore::read.flowSet(path = path_data, pattern = ".fcs", truncate_max_range = FALSE, transformation = FALSE) # Create GatingSet gs <- flowWorkspace::GatingSet(fs) # Apply GatingTemplate gt <- openCyto::gatingTemplate(file.path(path_data, "gatingTemp_cytokines.csv")) openCyto::gt_gating(x = gt, y = gs) # Get marker positivity per cell df_markerPos <- getMarkerPositivity(x = gs, gate_names = c("IFN+","TNFa+","IL2+","CD107a+")) # Assign marker combinations to each cell based on marker positivity df_markerComb <- assignMarkerCombinations(data_markerPos = df_markerPos, mode = "exhaustive") # Read metadata and cell labels df_md <- read.csv(file.path(path_data, "metadata.csv")) metacluster_labels <- readRDS(file.path(path_data, "cell_labels.rds")) # Add metadata and cell labels to dataframe df <- df_markerComb %>% dplyr::mutate(ID = df_md$ID, Stimulation = df_md$Stimulation, cell_type = metacluster_labels) # Calculate by Marker Combination result <- calcPolyfunctionality(x = df, md_cols = c("ID"), pop_col = "cell_type", resolution = "MarkerComb", condition_col = "Stimulation", background_val = "Unstim") # Calculate by Marker Count result <- calcPolyfunctionality(x = df, md_cols = c("ID"), pop_col = "cell_type", resolution = "MarkerCount", condition_col = "Stimulation", background_val = "Unstim") # Calculate by Functionality result <- calcPolyfunctionality(x = df, md_cols = c("ID"), pop_col = "cell_type", resolution = "Functionality", condition_col = "Stimulation", background_val = "Unstim") # Calculate by logical at least n result <- calcPolyfunctionality(x = df, md_cols = c("ID"), pop_col = "cell_type", resolution = "atleast_2_IFN+TNFa+", condition_col = "Stimulation", background_val = "Unstim") # Calculate by logical Polyfunctional, at least marker result <- calcPolyfunctionality(x = df, md_cols = c("ID"), pop_col = "cell_type", resolution = "Polyfunctional_atleast_IFN+", condition_col = "Stimulation", background_val = "Unstim") # Calculate by custom resolution df2 <- df %>% dplyr::mutate(MarkerCountAbove3_atleast_IFN_TNFa = MarkerCount == 3 & .data[["atleast_2_IFN+TNFa+"]]) result <- calcPolyfunctionality(x = df2, md_cols = c("ID"), pop_col = "cell_type", resolution = "MarkerCountAbove3_atleast_IFN_TNFa", condition_col = "Stimulation", background_val = "Unstim")# Define path to data path_data <- system.file("extdata", package = "polyICSFlow") # Read fcs files as flowSet fs <- flowCore::read.flowSet(path = path_data, pattern = ".fcs", truncate_max_range = FALSE, transformation = FALSE) # Create GatingSet gs <- flowWorkspace::GatingSet(fs) # Apply GatingTemplate gt <- openCyto::gatingTemplate(file.path(path_data, "gatingTemp_cytokines.csv")) openCyto::gt_gating(x = gt, y = gs) # Get marker positivity per cell df_markerPos <- getMarkerPositivity(x = gs, gate_names = c("IFN+","TNFa+","IL2+","CD107a+")) # Assign marker combinations to each cell based on marker positivity df_markerComb <- assignMarkerCombinations(data_markerPos = df_markerPos, mode = "exhaustive") # Read metadata and cell labels df_md <- read.csv(file.path(path_data, "metadata.csv")) metacluster_labels <- readRDS(file.path(path_data, "cell_labels.rds")) # Add metadata and cell labels to dataframe df <- df_markerComb %>% dplyr::mutate(ID = df_md$ID, Stimulation = df_md$Stimulation, cell_type = metacluster_labels) # Calculate by Marker Combination result <- calcPolyfunctionality(x = df, md_cols = c("ID"), pop_col = "cell_type", resolution = "MarkerComb", condition_col = "Stimulation", background_val = "Unstim") # Calculate by Marker Count result <- calcPolyfunctionality(x = df, md_cols = c("ID"), pop_col = "cell_type", resolution = "MarkerCount", condition_col = "Stimulation", background_val = "Unstim") # Calculate by Functionality result <- calcPolyfunctionality(x = df, md_cols = c("ID"), pop_col = "cell_type", resolution = "Functionality", condition_col = "Stimulation", background_val = "Unstim") # Calculate by logical at least n result <- calcPolyfunctionality(x = df, md_cols = c("ID"), pop_col = "cell_type", resolution = "atleast_2_IFN+TNFa+", condition_col = "Stimulation", background_val = "Unstim") # Calculate by logical Polyfunctional, at least marker result <- calcPolyfunctionality(x = df, md_cols = c("ID"), pop_col = "cell_type", resolution = "Polyfunctional_atleast_IFN+", condition_col = "Stimulation", background_val = "Unstim") # Calculate by custom resolution df2 <- df %>% dplyr::mutate(MarkerCountAbove3_atleast_IFN_TNFa = MarkerCount == 3 & .data[["atleast_2_IFN+TNFa+"]]) result <- calcPolyfunctionality(x = df2, md_cols = c("ID"), pop_col = "cell_type", resolution = "MarkerCountAbove3_atleast_IFN_TNFa", condition_col = "Stimulation", background_val = "Unstim")
Get number of cells in your dataset positive for each distinct marker combination (MarkerComb), number of functions (MarkerCount), and Functionality.
extractCellCounts( data_markerComb, cell_subset_params = list(cellTypes = NULL, cellTypes_plot = NULL) )extractCellCounts( data_markerComb, cell_subset_params = list(cellTypes = NULL, cellTypes_plot = NULL) )
data_markerComb |
A dataframe generated by the |
cell_subset_params |
List with parameters describing what subset of cells (cellTypes_plot) should be counted,
from a vector of cell types (cellTypes). Default = |
A grouped tibble with cell counts of the input data grouped by "MarkerComb", "MarkerCount", and
"Functionality".
# Define path to data path_data <- system.file("extdata", package = "polyICSFlow") # Read fcs files as flowSet fs <- flowCore::read.flowSet(path = path_data, pattern = ".fcs", truncate_max_range = FALSE, transformation = FALSE) # Create GatingSet gs <- flowWorkspace::GatingSet(fs) # Apply GatingTemplate gt <- openCyto::gatingTemplate(file.path(path_data, "gatingTemp_cytokines.csv")) openCyto::gt_gating(x = gt, y = gs) # Get marker positivity per cell df_markerPos <- getMarkerPositivity(x = gs, gate_names = c("IFN+","TNFa+","IL2+","CD107a+")) # Assign marker combinations to each cell based on marker positivity df_markerComb <- assignMarkerCombinations(data_markerPos = df_markerPos, mode = "exhaustive") # Get cell counts from all data cell_counts <- extractCellCounts(data_markerComb = df_markerComb) # Get cell counts from subset of data (metacluster 2 and 4) metacluster_labels <- readRDS(file.path(path_data, "cell_labels.rds")) cell_counts <- extractCellCounts(data_markerComb = df_markerComb, cell_subset_params = list(cellTypes = metacluster_labels, cellTypes_plot = c(2,4)))# Define path to data path_data <- system.file("extdata", package = "polyICSFlow") # Read fcs files as flowSet fs <- flowCore::read.flowSet(path = path_data, pattern = ".fcs", truncate_max_range = FALSE, transformation = FALSE) # Create GatingSet gs <- flowWorkspace::GatingSet(fs) # Apply GatingTemplate gt <- openCyto::gatingTemplate(file.path(path_data, "gatingTemp_cytokines.csv")) openCyto::gt_gating(x = gt, y = gs) # Get marker positivity per cell df_markerPos <- getMarkerPositivity(x = gs, gate_names = c("IFN+","TNFa+","IL2+","CD107a+")) # Assign marker combinations to each cell based on marker positivity df_markerComb <- assignMarkerCombinations(data_markerPos = df_markerPos, mode = "exhaustive") # Get cell counts from all data cell_counts <- extractCellCounts(data_markerComb = df_markerComb) # Get cell counts from subset of data (metacluster 2 and 4) metacluster_labels <- readRDS(file.path(path_data, "cell_labels.rds")) cell_counts <- extractCellCounts(data_markerComb = df_markerComb, cell_subset_params = list(cellTypes = metacluster_labels, cellTypes_plot = c(2,4)))
Create a dataframe describing whether each cell is included by the gates where each row is a cell and each column is a marker.
getMarkerPositivity(x, gate_names = NULL)getMarkerPositivity(x, gate_names = NULL)
x |
An object of class |
gate_names |
The names of the cytokine gates. If |
A data.frame where each row is a cell and each column is a gated marker which can be used as input for
the assignMarkerCombinations function.
This code is strongly based on the GetFlowJoLabels function.
GatingSet, gatingTemplate,
gt_gating, assignMarkerCombinations,
calcPolyfunctionality
# Define path to data path_data <- system.file("extdata", package = "polyICSFlow") # Read fcs files as flowSet fs <- flowCore::read.flowSet(path = path_data, pattern = ".fcs", truncate_max_range = FALSE, transformation = FALSE) # Create GatingSet gs <- flowWorkspace::GatingSet(fs) # Apply GatingTemplate gt <- openCyto::gatingTemplate(file.path(path_data, "gatingTemp_cytokines.csv")) openCyto::gt_gating(x = gt, y = gs) # Get marker positivity per cell df_markerPos <- getMarkerPositivity(x = gs, gate_names = c("IFN+","TNFa+","IL2+","CD107a+"))# Define path to data path_data <- system.file("extdata", package = "polyICSFlow") # Read fcs files as flowSet fs <- flowCore::read.flowSet(path = path_data, pattern = ".fcs", truncate_max_range = FALSE, transformation = FALSE) # Create GatingSet gs <- flowWorkspace::GatingSet(fs) # Apply GatingTemplate gt <- openCyto::gatingTemplate(file.path(path_data, "gatingTemp_cytokines.csv")) openCyto::gt_gating(x = gt, y = gs) # Get marker positivity per cell df_markerPos <- getMarkerPositivity(x = gs, gate_names = c("IFN+","TNFa+","IL2+","CD107a+"))
markers.Plot a stacked bar plot of cell counts by marker combination, faceted by the minimum number of markers
co-expressed (). Within each facet, the x-axis shows all marker or marker-combination categories
corresponding to that level (e.g., single markers for , two-marker combinations for , etc.).
plotCellCountsAtLeast( data_markerComb, cell_subset_params = list(cellTypes = NULL, cellTypes_plot = NULL), palette_comb = NULL )plotCellCountsAtLeast( data_markerComb, cell_subset_params = list(cellTypes = NULL, cellTypes_plot = NULL), palette_comb = NULL )
data_markerComb |
A dataframe generated by the |
cell_subset_params |
List with parameters describing what subset of cells (cellTypes_plot) should be plotted,
from a vector of cell types (cellTypes). Default = |
palette_comb |
A named character vector mapping marker combination
names (as produced by |
A ggplot.
# Define path to data path_data <- system.file("extdata", package = "polyICSFlow") # Read fcs files as flowSet fs <- flowCore::read.flowSet(path = path_data, pattern = ".fcs", truncate_max_range = FALSE, transformation = FALSE) # Create GatingSet gs <- flowWorkspace::GatingSet(fs) # Apply GatingTemplate gt <- openCyto::gatingTemplate(file.path(path_data, "gatingTemp_cytokines.csv")) openCyto::gt_gating(x = gt, y = gs) # Get marker positivity per cell df_markerPos <- getMarkerPositivity(x = gs, gate_names = c("IFN+","TNFa+","IL2+","CD107a+")) # Assign marker combinations to each cell based on marker positivity df_markerComb <- assignMarkerCombinations(data_markerPos = df_markerPos, mode = "simple") # Plot all cells plotCellCountsAtLeast(data_markerComb = df_markerComb) # Plot only subset of data (metacluster 2 and 4) metacluster_labels <- readRDS(file.path(path_data, "cell_labels.rds")) plotCellCountsAtLeast(data_markerComb = df_markerComb, cell_subset_params = list(cellTypes = metacluster_labels, cellTypes_plot = c(2,4)))# Define path to data path_data <- system.file("extdata", package = "polyICSFlow") # Read fcs files as flowSet fs <- flowCore::read.flowSet(path = path_data, pattern = ".fcs", truncate_max_range = FALSE, transformation = FALSE) # Create GatingSet gs <- flowWorkspace::GatingSet(fs) # Apply GatingTemplate gt <- openCyto::gatingTemplate(file.path(path_data, "gatingTemp_cytokines.csv")) openCyto::gt_gating(x = gt, y = gs) # Get marker positivity per cell df_markerPos <- getMarkerPositivity(x = gs, gate_names = c("IFN+","TNFa+","IL2+","CD107a+")) # Assign marker combinations to each cell based on marker positivity df_markerComb <- assignMarkerCombinations(data_markerPos = df_markerPos, mode = "simple") # Plot all cells plotCellCountsAtLeast(data_markerComb = df_markerComb) # Plot only subset of data (metacluster 2 and 4) metacluster_labels <- readRDS(file.path(path_data, "cell_labels.rds")) plotCellCountsAtLeast(data_markerComb = df_markerComb, cell_subset_params = list(cellTypes = metacluster_labels, cellTypes_plot = c(2,4)))
markers.Plot a stacked bar plot of cell counts within each marker combination for cells positive for exactly 1, 2, ..., markers.
plotCellCountsExactly( data_markerComb, cell_subset_params = list(cellTypes = NULL, cellTypes_plot = NULL), palette_comb = NULL )plotCellCountsExactly( data_markerComb, cell_subset_params = list(cellTypes = NULL, cellTypes_plot = NULL), palette_comb = NULL )
data_markerComb |
A dataframe generated by the |
cell_subset_params |
List with parameters describing what subset of cells (cellTypes_plot) should be plotted,
from a vector of cell types (cellTypes). Default = |
palette_comb |
A named character vector mapping marker combination
names (as produced by |
A ggplot.
# Define path to data path_data <- system.file("extdata", package = "polyICSFlow") # Read fcs files as flowSet fs <- flowCore::read.flowSet(path = path_data, pattern = ".fcs", truncate_max_range = FALSE, transformation = FALSE) # Create GatingSet gs <- flowWorkspace::GatingSet(fs) # Apply GatingTemplate gt <- openCyto::gatingTemplate(file.path(path_data, "gatingTemp_cytokines.csv")) openCyto::gt_gating(x = gt, y = gs) # Get marker positivity per cell df_markerPos <- getMarkerPositivity(x = gs, gate_names = c("IFN+","TNFa+","IL2+","CD107a+")) # Assign marker combinations to each cell based on marker positivity df_markerComb <- assignMarkerCombinations(data_markerPos = df_markerPos, mode = "simple") # Plot all cells plotCellCountsExactly(data_markerComb = df_markerComb) # Plot only subset of data (metacluster 2 and 4) metacluster_labels <- readRDS(file.path(path_data, "cell_labels.rds")) plotCellCountsExactly(data_markerComb = df_markerComb, cell_subset_params = list(cellTypes = metacluster_labels, cellTypes_plot = c(2,4)))# Define path to data path_data <- system.file("extdata", package = "polyICSFlow") # Read fcs files as flowSet fs <- flowCore::read.flowSet(path = path_data, pattern = ".fcs", truncate_max_range = FALSE, transformation = FALSE) # Create GatingSet gs <- flowWorkspace::GatingSet(fs) # Apply GatingTemplate gt <- openCyto::gatingTemplate(file.path(path_data, "gatingTemp_cytokines.csv")) openCyto::gt_gating(x = gt, y = gs) # Get marker positivity per cell df_markerPos <- getMarkerPositivity(x = gs, gate_names = c("IFN+","TNFa+","IL2+","CD107a+")) # Assign marker combinations to each cell based on marker positivity df_markerComb <- assignMarkerCombinations(data_markerPos = df_markerPos, mode = "simple") # Plot all cells plotCellCountsExactly(data_markerComb = df_markerComb) # Plot only subset of data (metacluster 2 and 4) metacluster_labels <- readRDS(file.path(path_data, "cell_labels.rds")) plotCellCountsExactly(data_markerComb = df_markerComb, cell_subset_params = list(cellTypes = metacluster_labels, cellTypes_plot = c(2,4)))
Plots 2D scatter plots of all possible marker combinations, where each panel (facet) corresponds to one of the
possible combinations of markers.
The top-left panel represents cells negative for all markers, while the bottom-right represents cells positive for all markers,
with intermediate panels showing mixed combinations.
Within each panel, the x-axis denotes the markers and the y-axis shows the transformed MFI values.
Each point corresponds to a single cell, with cells belonging to the combination represented in that facet
highlighted in color, and all other cells displayed in grey background for reference.
plotMarkerComb2DScatters( input, assigned_MarkerCombs, cell_subset_params = list(cellTypes = NULL, cellTypes_plot = NULL), palette_comb = NULL, return_list = FALSE )plotMarkerComb2DScatters( input, assigned_MarkerCombs, cell_subset_params = list(cellTypes = NULL, cellTypes_plot = NULL), palette_comb = NULL, return_list = FALSE )
input |
Either a matrix of marker expression or an object of class
|
assigned_MarkerCombs |
A vector of assigned marker combinations per
cell in |
cell_subset_params |
List with parameters describing what subset of cells (cellTypes_plot) should be plotted,
from a vector of cell types (cellTypes). Default = |
palette_comb |
A named character vector mapping marker combination
names (as produced by |
return_list |
Logical. If FALSE (default), the plots are combined by cowplot. If TRUE, a list of plots are returned to allow further customization. |
A ggplot object visualizing 2D scatterplots of all
marker combinations.
# Define path to data path_data <- system.file("extdata", package = "polyICSFlow") # Read fcs files as flowSet fs <- flowCore::read.flowSet(path = path_data, pattern = ".fcs", truncate_max_range = FALSE, transformation = FALSE) # Create GatingSet gs <- flowWorkspace::GatingSet(fs) # Apply GatingTemplate gt <- openCyto::gatingTemplate(file.path(path_data, "gatingTemp_cytokines.csv")) openCyto::gt_gating(x = gt, y = gs) # Get marker positivity per cell df_markerPos <- getMarkerPositivity(x = gs, gate_names = c("IFN+","TNFa+","IL2+","CD107a+")) # Assign marker combinations to each cell based on marker positivity df_markerComb <- assignMarkerCombinations(data_markerPos = df_markerPos) # Plot 2D scatter of marker combinations in dataset (all data) # From gatingSet plotMarkerComb2DScatters(input = gs, assigned_MarkerCombs = df_markerComb$MarkerComb) # From flowSet plotMarkerComb2DScatters(input = fs, assigned_MarkerCombs = df_markerComb$MarkerComb) # Plot only subset of data (metacluster 2 and 4) metacluster_labels <- readRDS(file.path(path_data, "cell_labels.rds")) plotMarkerComb2DScatters(input = fs, assigned_MarkerCombs = df_markerComb$MarkerComb, cell_subset_params = list(cellTypes = metacluster_labels, cellTypes_plot = c(2,4))) # As list plot_list <- plotMarkerComb2DScatters(input = fs, assigned_MarkerCombs = df_markerComb$MarkerComb, return_list = TRUE)# Define path to data path_data <- system.file("extdata", package = "polyICSFlow") # Read fcs files as flowSet fs <- flowCore::read.flowSet(path = path_data, pattern = ".fcs", truncate_max_range = FALSE, transformation = FALSE) # Create GatingSet gs <- flowWorkspace::GatingSet(fs) # Apply GatingTemplate gt <- openCyto::gatingTemplate(file.path(path_data, "gatingTemp_cytokines.csv")) openCyto::gt_gating(x = gt, y = gs) # Get marker positivity per cell df_markerPos <- getMarkerPositivity(x = gs, gate_names = c("IFN+","TNFa+","IL2+","CD107a+")) # Assign marker combinations to each cell based on marker positivity df_markerComb <- assignMarkerCombinations(data_markerPos = df_markerPos) # Plot 2D scatter of marker combinations in dataset (all data) # From gatingSet plotMarkerComb2DScatters(input = gs, assigned_MarkerCombs = df_markerComb$MarkerComb) # From flowSet plotMarkerComb2DScatters(input = fs, assigned_MarkerCombs = df_markerComb$MarkerComb) # Plot only subset of data (metacluster 2 and 4) metacluster_labels <- readRDS(file.path(path_data, "cell_labels.rds")) plotMarkerComb2DScatters(input = fs, assigned_MarkerCombs = df_markerComb$MarkerComb, cell_subset_params = list(cellTypes = metacluster_labels, cellTypes_plot = c(2,4))) # As list plot_list <- plotMarkerComb2DScatters(input = fs, assigned_MarkerCombs = df_markerComb$MarkerComb, return_list = TRUE)
Plot a heatmap of all possible marker combinations.
plotMarkerCombHeatmap( marker_names, orientation = c("vertical", "horizontal"), palette_count = NULL, palette_comb = NULL, full_names = TRUE )plotMarkerCombHeatmap( marker_names, orientation = c("vertical", "horizontal"), palette_count = NULL, palette_comb = NULL, full_names = TRUE )
marker_names |
A character vector specifying the marker names used to generate all possible combinations. |
orientation |
A string specifying the orientation of the heatmap, either vertical or horizontal.
Default = |
palette_count |
A named character vector mapping the number of markers
per cell to colors. If |
palette_comb |
A named character vector mapping marker combination
names to colors. If |
full_names |
Logical. If TRUE (default) the marker combinations are displayed with their full names (i.e., negative markers are also present). If FALSE, only the positive markers are displayed. |
A Heatmap object visualizing all marker
combinations. The heatmap includes two layers of annotation:
MarkerCount: A marker count annotation (colored
with palette_count) showing the number of markers in each combination.
MarkerComb: A combination annotation (colored
with palette_comb) showing the exact subset of markers present.
# Vertical heatmap plotMarkerCombHeatmap(marker_names = c("IFN","TNFa","IL2","CD107a"), orientation = "vertical") # Horizontal heatmap plotMarkerCombHeatmap(marker_names = c("IFN","TNFa","IL2","CD107a"), orientation = "horizontal")# Vertical heatmap plotMarkerCombHeatmap(marker_names = c("IFN","TNFa","IL2","CD107a"), orientation = "vertical") # Horizontal heatmap plotMarkerCombHeatmap(marker_names = c("IFN","TNFa","IL2","CD107a"), orientation = "horizontal")