PlotGroups: PlotGroups

View source: R/6_deprecated.R

PlotGroupsR Documentation

PlotGroups

Description

Plot differences between groups

Usage

PlotGroups(fsom, groups, threshold = NULL, pThreshold = 0.05, ...)

Arguments

fsom

FlowSOM object, as generated by BuildMST

groups

Groups result as generated by CountGroups

threshold

Relative difference in groups before the node is colored

pThreshold

Threshold on p-value from wilcox-test before the node is colored. If this is not NULL, threshold will be ignored.

...

Additional arguments to pass to PlotFlowSOM

Details

Plot FlowSOM trees, where each node is represented by a star chart indicating mean marker values, the size of the node is relative to the mean percentage of cells present in each

Value

A vector containing the labels assigned to the nodes for all groups except the first

See Also

PlotStars,PlotVariable, PlotFlowSOM,PlotLabels,PlotNumbers, PlotMarker,PlotPies,QueryStarPlot, PlotSD

Examples

#Run FlowSOM
fileName <-  system.file("extdata", "68983.fcs", package="FlowSOM")
fsom <- FlowSOM(fileName, compensate = TRUE, transform = TRUE,
                      scale = TRUE, colsToUse = c(9,12,14:18), nClus = 10)

ff <- flowCore::read.FCS(fileName)
# Make an additional file without cluster 7 and double amount of cluster 5
selection <- c(which(GetClusters(fsom) %in% which(fsom$metaclustering != 7)),
                 which(GetClusters(fsom) %in% which(fsom$metaclustering == 5)))
ff_tmp <- ff[selection,]
flowCore::write.FCS(ff_tmp, file="ff_tmp.fcs")

# Compare only the file with the double amount of cluster 10
features <- GetFeatures(fsom, 
                        c(fileName, "ff_tmp.fcs"),
                        level = "clusters",
                        type = "percentages")
stats <- GroupStats(features$cluster_percentages,                     
                    groups = list("AllCells" = c(fileName),
                                  "Without_ydTcells" = c("ff_tmp.fcs")))

fold_changes <- stats["fold changes", ]
fold_changes_label <- factor(ifelse(fold_changes < -1.5, 
                           "Underrepresented compared to Group 1",
                           ifelse(fold_changes > 1.5, 
                                  "Overrepresented compared to Group 1",
                                  "--")), 
                            levels = c("--", 
                               "Underrepresented compared to Group 1",
                               "Overrepresented compared to Group 1"))
fold_changes_label[is.na(fold_changes_label)] <- "--"                                   
gr_1 <- PlotStars(fsom, 
                  title = "All Cells", 
                  nodeSizes = stats["medians AllCells", ], 
                  list_insteadof_ggarrange = TRUE)
gr_2 <- PlotStars(fsom, title = "Group 2", 
               nodeSizes = stats["medians Without_ydTcells", ], 
                backgroundValues = fold_changes_label,
               backgroundColors = c("white", "red", "blue"), 
               list_insteadof_ggarrange = TRUE)
p <- ggpubr::ggarrange(plotlist = c(list(gr_1$tree), gr_2),
                    heights = c(3, 1))
p                   
         

saeyslab/FlowSOM documentation built on April 20, 2024, 8:30 p.m.