CountGroups: Calculate differences in cell counts between groups

Description Usage Arguments Value See Also Examples

View source: R/2_buildSOM.R

Description

Calculate differences in cell counts between groups

Usage

1
CountGroups(fsom, groups, plot = TRUE, silent = FALSE, ...)

Arguments

fsom

FlowSOM object as generated by BuildSOM

groups

List containing an array with file names for each group

plot

Logical. If TRUE, make a starplot of each individual file

silent

Logical. If TRUE, print progress messages

...

Extra arguments to be passed on to the PlotStars function

Value

Distance matrix

See Also

PlotStars,PlotGroups

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
   library(FlowSOM)
   set.seed(1)
   
   # Build the FlowSOM tree on the example file
   fileName <- system.file("extdata","lymphocytes.fcs",package="FlowSOM")
   flowSOM.res <- FlowSOM(fileName, compensate=TRUE,transform=TRUE,
                    scale=TRUE,colsToUse=c(9,12,14:18),nClus = 10)
   
   # Have a look at the resulting tree
   PlotStars(flowSOM.res[[1]],backgroundValues = as.factor(flowSOM.res[[2]]))
   
   # Select all cells except the branch that corresponds with automated 
   # cluster 7 (CD3+ TCRyd +) and write te another file for the example
   # In practice you would not generate any new file but use your different
   # files from your different groups
   ff <- flowCore::read.FCS(fileName)
   ff_tmp <- ff[flowSOM.res[[1]]$map$mapping[,1] %in% 
                     which(flowSOM.res[[2]] != 7),]
   flowCore::write.FCS(ff_tmp,file="ff_tmp.fcs")
   # Make an extra file without cluster 7 and double amount of cluster 10
   ff_tmp <- ff[c(which(flowSOM.res[[1]]$map$mapping[,1] %in% 
                                 which(flowSOM.res[[2]] != 7)),
                  which(flowSOM.res[[1]]$map$mapping[,1] %in% 
                                 which(flowSOM.res[[2]] == 5))),]
   flowCore::write.FCS(ff_tmp,file="ff_tmp2.fcs")
   
   # Compare the original file with the two new files we made
   groupRes <- CountGroups(flowSOM.res[[1]], 
                 groups=list("AllCells"=c(fileName),
                           "Without_ydTcells"=c("ff_tmp.fcs","ff_tmp2.fcs")))
   PlotGroups(flowSOM.res[[1]], groupRes)
   
   # Compare only the file with the double amount of cluster 10
   groupRes <- CountGroups(flowSOM.res[[1]], 
                 groups=list("AllCells"=c(fileName),
                 "Without_ydTcells"=c("ff_tmp2.fcs")))
   PlotGroups(flowSOM.res[[1]], groupRes)

FlowSOM documentation built on May 31, 2017, 11:26 a.m.