GetMajorityLabels: GetMajorityLabels

View source: R/4_metaClustering.R

GetMajorityLabelsR Documentation

GetMajorityLabels

Description

Get majority cluster and metacluster labels from a vector of manual labels per cell in the FlowSOM object. Especially useful as starting point for UpdateMetaclusters.

Usage

GetMajorityLabels(fsom, labels)

Arguments

fsom

FlowSOM object, as generated by FlowSOM

labels

Array of celltypes per cell in fsom

Value

Named list with array of majority labels for the FlowSOM clusters and metaclusters.

See Also

UpdateMetaclusters

Examples

# Identify the files
fcs_file <- system.file("extdata", "68983.fcs", package = "FlowSOM")
gating_file <- system.file("extdata", "gatingResult.csv", package = "FlowSOM")

# Specify the cell types of interest for assigning one label per cell
cellTypes <- c("B cells",
               "gd T cells", "CD4 T cells", "CD8 T cells",
               "NK cells", "NK T cells")
                
# Load manual labels (e.g. GetFlowJoLabels can be used to extract labels from
# an fcs file)
gatingResult <- as.factor(read.csv(gating_file, header = FALSE)[, 1])


# Build a FlowSOM tree
flowSOM.res <- FlowSOM(fcs_file,
                       scale = TRUE, 
                       compensate = TRUE, 
                       transform = TRUE,
                       toTransform = 8:18, 
                       colsToUse = c(9, 12, 14:18),
                       nClus = 10,
                       seed = 1)
   
# Get metacluster label based on the gatingResult
majorityLabels <- GetMajorityLabels(fsom = flowSOM.res, 
                                    labels = gatingResult)



saeyslab/FlowSOM documentation built on July 6, 2024, 10:59 a.m.