flowPeaks: Doing the flowPeaks analysis

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/flowPeaks.R

Description

This is the core function in the flowPeaks package. It generates the output of the cluster and information associated with each cluster, which can be used by the function plot for visualization

Usage

1
flowPeaks(x,tol=0.1,h0=1,h=1.5)

Arguments

x

a data matrix for the flow cytometry data, it needs to have at least two rows, and the names for each column should be unique. For a flowFrame data, its exprssion matrix slot should be used as x, where only channles of interest are selected (see the example below).

tol

The tolerance (between 0 and 1) when neighboring clusters should be considered to be merged

h0

The multiplier of the vaiarance matrix S0

h

The multiplier of the variance matrix S

Value

It returns an object of class flowPeaks, which is a list of the following variables:

peaks.cluster

An integer shows the cluster labels (between 1 and K for K clusters) for each cell. The clustering is based on the flowPeaks algorithm

peaks

A summary of the cluster information. It is a list with the following three variables:

  • cid: cluster labels, should always be 1:K;

  • w: the weights of the K clusters;

  • mu: The mean of all cells in the K clusters;

  • S: The variance matrix of the K clusters. Note that each variance matrix for each cluster has been stacked as a column vector

kmeans.cluster

An integer shows the cluster labels for the initial kmeans clustering

kmeans

A summary of the initial kmeans clustering. The meaning of the variables can be seens in the description of peaks above

info

The information that can be used for plot, and how the initial kmeans clustering and the final flowPeaks clustering are connected

x

The input data x

Author(s)

Yongchao Ge yongchao.ge@gmail.com

References

Ge Y. et al, flowPeaks: a fast unsupervised clustering for flow cytometry data via K-means and density peak finding, 2012, Bioinformatics 8(15):2052-8

See Also

plot.flowPeaks

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
##demonstrate how to use a flowFrame
## Not run: 
require(flowCore)
samp <- read.FCS(system.file("extdata","0877408774.B08",
package="flowCore"))
##do the clustering based on the asinh transforamtion of
##the first two FL channels
fp<-flowPeaks(asinh(samp@exprs[,3:4]))
plot(fp)

## End(Not run)

data(barcode)
fp<-flowPeaks(barcode[,c(1,3)])
plot(fp)

##to compare it with the gold standard
evalCluster(barcode.cid,fp$peaks.cluster,method="Vmeasure")

#to remove the outliers
fpc<-assign.flowPeaks(fp,fp$x)
plot(fp,classlab=fpc,drawboundary=FALSE,
  drawvor=FALSE,drawkmeans=FALSE,drawlab=TRUE)


#to adjust the cluster by increasing the tol,h0, h, which results
#in a smaller number of clusters
fp2<-adjust.flowPeaks(fp,tol=0.5,h0=2,h=2) 
summary(fp2)
print(fp) #an alternative of using summary(fp) 

Example output

Loading required package: flowCore

Starting the flow Peaks analysis...

    Task A: compute kmeans...

        step 0, set the intial seeds, tot.wss=1426.31
        step 1, do the rough EM, tot.wss=951.966 at 0.033632 sec
        step 2, do the fine transfer of Hartigan-Wong Algorithm
                 tot.wss=938.179 at 0.051139 sec
        ...finished summarization at 0.057 sec

    Task B: find peaks...
finished at 0.075 sec



Starting the flow Peaks analysis...

    Task A: compute kmeans...

        step 0, set the intial seeds, tot.wss=2.66069e+09
        step 1, do the rough EM, tot.wss=1.69145e+09 at 0.350987 sec
        step 2, do the fine transfer of Hartigan-Wong Algorithm
                 tot.wss=1.69036e+09 at 0.516488 sec
        ...finished summarization at 0.54 sec

    Task B: find peaks...
finished at 0.604 sec


[1] 0.9983352
      cluster.id     weight Pacific.blue.center APC.center
 [1,]          1 0.08530667            784.6786  1786.2346
 [2,]          2 0.08442779           1518.1979  1826.5504
 [3,]          3 0.08234390            750.3885   438.3863
 [4,]          4 0.07850226           1418.8294   439.6213
 [5,]          5 0.07834748           2088.5995  1838.5346
 [6,]          6 0.07625254           2032.4362   446.0405
 [7,]          7 0.07595958            772.0405  2488.5624
 [8,]          8 0.07391992           1577.7355  2609.4396
 [9,]          9 0.07086318           2070.2356  2466.3112
[10,]         10 0.06410852           2644.1186  1834.6225
[11,]         11 0.06380450           2587.7982   448.6811
[12,]         12 0.06055430           2623.5123  2460.2426
[13,]         13 0.03073317           3086.9572   445.9011
[14,]         14 0.03040705           3122.0747  2452.2894
[15,]         15 0.02927390           3128.4097  1785.3059
[16,]         16 0.01519523           2220.7283  1142.3692
      cluster.id      weight Pacific.blue.center APC.center
 [1,]          1 0.082343902            750.3885   438.3863
 [2,]          2 0.080237906           1535.4227  1862.5566
 [3,]          3 0.078502255           1418.8294   439.6213
 [4,]          4 0.078446980            788.5512  1839.0292
 [5,]          5 0.078347484           2088.5995  1838.5346
 [6,]          6 0.076252543           2032.4362   446.0405
 [7,]          7 0.075959583            772.0405  2488.5624
 [8,]          8 0.073919917           1577.7355  2609.4396
 [9,]          9 0.070863182           2070.2356  2466.3112
[10,]         10 0.064108517           2644.1186  1834.6225
[11,]         11 0.063804502           2587.7982   448.6811
[12,]         12 0.060554303           2623.5123  2460.2426
[13,]         13 0.030733174           3086.9572   445.9011
[14,]         14 0.030407049           3122.0747  2452.2894
[15,]         15 0.029273901           3128.4097  1785.3059
[16,]         16 0.011049571            910.2476  1165.2406
[17,]         17 0.006118997           1738.2096  1142.6793
[18,]         18 0.005278810           2340.1613  1162.4670
[19,]         19 0.003797426           2832.2125  1113.9316

flowPeaks documentation built on Nov. 8, 2020, 5:02 p.m.