Last data update: 2014.03.03

R: Convert a flowFrame/flowSet/GatingSet to a ggplot-compatible...
fortify.flowFrameR Documentation

Convert a flowFrame/flowSet/GatingSet to a ggplot-compatible data.table

Description

It extracts events matrices and appends the pData to it so that ggplot can use the pData for facetting.

Usage

## S3 method for class 'flowFrame'
fortify(model, data, ...)

## S3 method for class 'flowSet'
fortify(model, data, ...)

## S3 method for class 'GatingSet'
fortify(model, ...)

Arguments

model

flowFrame, flowSet or GatingSet

data

not used.

...

not used.

Value

data.table

data.table

data.table

Examples

dataDir <- system.file("extdata",package="flowWorkspaceData")
gs <- load_gs(list.files(dataDir, pattern = "gs_manual",full = TRUE))

attr(gs, "subset") <- "CD4" #must attach subset information to GatingSet object before foritfying it
fortify(gs)

fs <- getData(gs, "CD8")
fortify(fs)#fs is a flowSet/ncdfFlowSet

fr <- fs[[1]]
fortify(fr)#fr is a flowFrame

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(ggcyto)
Loading required package: ggplot2
Loading required package: flowCore
Loading required package: ncdfFlow
Loading required package: flowViz
Loading required package: lattice
Loading required package: RcppArmadillo
Loading required package: BH
Loading required package: flowWorkspace
Loading required package: gridExtra
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/ggcyto/fortify.flowSet.Rd_%03d_medium.png", width=480, height=480)
> ### Name: fortify.flowFrame
> ### Title: Convert a flowFrame/flowSet/GatingSet to a ggplot-compatible
> ###   data.table
> ### Aliases: fortify fortify.GatingSet fortify.flowFrame fortify.flowSet
> 
> ### ** Examples
> 
> dataDir <- system.file("extdata",package="flowWorkspaceData")
> gs <- load_gs(list.files(dataDir, pattern = "gs_manual",full = TRUE))
loading R object...
loading tree object...
Done
> 
> attr(gs, "subset") <- "CD4" #must attach subset information to GatingSet object before foritfying it
> fortify(gs)
                     .rownames                    name     FSC-A  FSC-H
    1: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs 140733.05 133376
    2: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs 134347.02 125651
    3: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs 101553.95  96602
    4: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs  87721.18  79682
    5: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs 112648.49 106622
   ---                                                                 
34030: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs  91501.85  86287
34031: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs 104606.81  97939
34032: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs 117452.62 111203
34033: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs 104229.41 100303
34034: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs 110641.73 106703
          FSC-W    SSC-A <B710-A> <R660-A>  <R780-A> <V450-A>  <V545-A>
    1: 69150.98 91113.96 3103.893 3302.285 2073.7874 2995.523 1794.2277
    2: 70071.60 70116.48 3126.778 1829.362 1607.4141 2506.567 1726.7777
    3: 68895.48 44620.80 2900.414 2457.046  483.4440 2699.779 1560.5170
    4: 72147.98 66181.08 2926.262 1373.588 1509.9983 2499.317 1500.7338
    5: 69240.23 49759.08 2829.928 1268.914  715.3616 2481.033  517.2481
   ---                                                                 
34030: 69496.75 68497.80 2982.018 2146.991  334.9059 2732.116 1587.7156
34031: 69997.77 40012.56 2818.660 2040.412 1554.1492 2628.634 1589.1610
34032: 69219.13 42007.56 3102.433 2756.337  783.0721 2762.716 1640.4987
34033: 68101.44 40349.40 2917.709 2307.589 1578.7362 2656.411 1710.2008
34034: 67955.13 39222.12 2957.168 2244.951  364.9129 2602.406 1020.7272
       <G560-A>  <G780-A>    Time
    1: 2396.823 2860.2954     0.2
    2: 2193.345  997.0442     0.7
    3: 2758.237 3262.8647     1.5
    4: 2222.489 1040.4622     2.0
    5: 2172.823 1662.3625     2.1
   ---                           
34030: 2480.849 2453.1873 29526.9
34031: 2342.115 2704.5933 29527.5
34032: 2504.073 2347.7258 29531.7
34033: 2270.374 1823.3966 29532.9
34034: 2159.926 2824.5662 29538.0
> 
> fs <- getData(gs, "CD8")
> fortify(fs)#fs is a flowSet/ncdfFlowSet
                     .rownames                    name     FSC-A  FSC-H
    1: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs 127717.88 119616
    2: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs  84330.34  77826
    3: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs 113783.64 107160
    4: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs 103148.27  97894
    5: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs 110324.17 106074
   ---                                                                 
14566: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs 102727.06  94475
14567: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs  83445.57  75251
14568: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs 100791.84  94089
14569: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs 130091.12 122710
14570: CytoTrol_CytoTrol_1.fcs CytoTrol_CytoTrol_1.fcs  95898.64  88870
          FSC-W    SSC-A  <B710-A> <R660-A> <R780-A> <V450-A> <V545-A> <G560-A>
    1: 69974.92 76954.91 1287.7864 1928.069 3771.027 2748.227 1659.868 2883.010
    2: 71013.20 66052.55 1456.5524 1515.816 3703.416 2656.468 1611.848 2799.425
    3: 69586.83 62380.92  702.0849 1983.690 3516.511 2661.088 1503.404 2635.943
    4: 69053.52 47501.16 1381.0764 1475.110 3616.322 2465.127 1488.220 1573.408
    5: 68161.90 34369.44  868.7352 2158.518 3542.206 2419.111 1640.010 2182.615
   ---                                                                         
14566: 71260.34 65382.24 1221.6210 1100.074 3659.936 2513.086 1822.485 1002.374
14567: 72672.64 87513.72  800.7334 1018.420 3719.805 2377.336 1610.197 1642.019
14568: 70204.73 76909.55 1557.0449 2146.589 3853.656 2639.901 1610.063 2158.575
14569: 69478.05 44694.72 1373.2374 1203.216 3427.881 2434.620 1782.115 1652.422
14570: 70719.18 58815.12  860.4343 1585.692 3718.582 2331.083 1549.893 1314.604
       <G780-A>    Time
    1: 3480.190     0.7
    2: 3414.590     1.5
    3: 2710.354     4.8
    4: 2576.110     6.7
    5: 3234.683     6.8
   ---                 
14566: 3320.133 29516.1
14567: 1198.867 29527.7
14568: 3429.701 29528.4
14569: 1507.701 29529.1
14570: 2398.052 29530.5
> 
> fr <- fs[[1]]
> fortify(fr)#fr is a flowFrame
                                  .rownames
    1: 7817b649-f92d-4103-bd46-6364fdbe85db
    2: 7817b649-f92d-4103-bd46-6364fdbe85db
    3: 7817b649-f92d-4103-bd46-6364fdbe85db
    4: 7817b649-f92d-4103-bd46-6364fdbe85db
    5: 7817b649-f92d-4103-bd46-6364fdbe85db
   ---                                     
14566: 7817b649-f92d-4103-bd46-6364fdbe85db
14567: 7817b649-f92d-4103-bd46-6364fdbe85db
14568: 7817b649-f92d-4103-bd46-6364fdbe85db
14569: 7817b649-f92d-4103-bd46-6364fdbe85db
14570: 7817b649-f92d-4103-bd46-6364fdbe85db
                                       name     FSC-A  FSC-H    FSC-W    SSC-A
    1: 7817b649-f92d-4103-bd46-6364fdbe85db 127717.88 119616 69974.92 76954.91
    2: 7817b649-f92d-4103-bd46-6364fdbe85db  84330.34  77826 71013.20 66052.55
    3: 7817b649-f92d-4103-bd46-6364fdbe85db 113783.64 107160 69586.83 62380.92
    4: 7817b649-f92d-4103-bd46-6364fdbe85db 103148.27  97894 69053.52 47501.16
    5: 7817b649-f92d-4103-bd46-6364fdbe85db 110324.17 106074 68161.90 34369.44
   ---                                                                        
14566: 7817b649-f92d-4103-bd46-6364fdbe85db 102727.06  94475 71260.34 65382.24
14567: 7817b649-f92d-4103-bd46-6364fdbe85db  83445.57  75251 72672.64 87513.72
14568: 7817b649-f92d-4103-bd46-6364fdbe85db 100791.84  94089 70204.73 76909.55
14569: 7817b649-f92d-4103-bd46-6364fdbe85db 130091.12 122710 69478.05 44694.72
14570: 7817b649-f92d-4103-bd46-6364fdbe85db  95898.64  88870 70719.18 58815.12
        <B710-A> <R660-A> <R780-A> <V450-A> <V545-A> <G560-A> <G780-A>    Time
    1: 1287.7864 1928.069 3771.027 2748.227 1659.868 2883.010 3480.190     0.7
    2: 1456.5524 1515.816 3703.416 2656.468 1611.848 2799.425 3414.590     1.5
    3:  702.0849 1983.690 3516.511 2661.088 1503.404 2635.943 2710.354     4.8
    4: 1381.0764 1475.110 3616.322 2465.127 1488.220 1573.408 2576.110     6.7
    5:  868.7352 2158.518 3542.206 2419.111 1640.010 2182.615 3234.683     6.8
   ---                                                                        
14566: 1221.6210 1100.074 3659.936 2513.086 1822.485 1002.374 3320.133 29516.1
14567:  800.7334 1018.420 3719.805 2377.336 1610.197 1642.019 1198.867 29527.7
14568: 1557.0449 2146.589 3853.656 2639.901 1610.063 2158.575 3429.701 29528.4
14569: 1373.2374 1203.216 3427.881 2434.620 1782.115 1652.422 1507.701 29529.1
14570:  860.4343 1585.692 3718.582 2331.083 1549.893 1314.604 2398.052 29530.5
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>