Last data update: 2014.03.03

R: Convert a polygonGate to a data.table useful for ggplot
fortify.polygonGateR Documentation

Convert a polygonGate to a data.table useful for ggplot

Description

It converts the boundaries slot into a data.table When 'nPoints' is supplied, the method tries to interpolate the polygon with more verticies.

Usage

## S3 method for class 'polygonGate'
fortify(model, data = NULL, nPoints = NULL, ...)

Arguments

model

polygonGate

data

data range used to reset off-bound gate coordinates to prevent interpolating on the extremely large space unnecessarily.

nPoints

total number of vertices of the polygon after interpolation. Default is NULL, which is no interpolation. The actual number may be more or less based on the lengths of edges due to the maximun and minimum limits on each edge. Interpolation is mainly for the purpose of plotting (so that it won't lose its shape from subsetting through 'limits'). But it is not necessary for other purposes like centroid calculation.

...

not used.

Value

data.table

Examples

sqrcut <- matrix(c(300,300,600,600,50,300,300,50),ncol=2,nrow=4)
colnames(sqrcut) <- c("FSC-H","SSC-H")
pg <- polygonGate(filterId="nonDebris", .gate= sqrcut)
fortify(pg) #no interpolation
fortify(pg, nPoints = 30) # with interpolation

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.polygonGate.Rd_%03d_medium.png", width=480, height=480)
> ### Name: fortify.polygonGate
> ### Title: Convert a polygonGate to a data.table useful for ggplot
> ### Aliases: fortify.polygonGate
> 
> ### ** Examples
> 
> sqrcut <- matrix(c(300,300,600,600,50,300,300,50),ncol=2,nrow=4)
> colnames(sqrcut) <- c("FSC-H","SSC-H")
> pg <- polygonGate(filterId="nonDebris", .gate= sqrcut)
> fortify(pg) #no interpolation
   FSC-H SSC-H
1:   300    50
2:   300   300
3:   600   300
4:   600    50
5:   300    50
> fortify(pg, nPoints = 30) # with interpolation
       FSC-H     SSC-H
 1: 300.0000  50.00000
 2: 300.0000  63.15789
 3: 300.0000  76.31579
 4: 300.0000  89.47368
 5: 300.0000 102.63158
 6: 300.0000 115.78947
 7: 300.0000 128.94737
 8: 300.0000 142.10526
 9: 300.0000 155.26316
10: 300.0000 168.42105
11: 300.0000 181.57895
12: 300.0000 194.73684
13: 300.0000 207.89474
14: 300.0000 221.05263
15: 300.0000 234.21053
16: 300.0000 247.36842
17: 300.0000 260.52632
18: 300.0000 273.68421
19: 300.0000 286.84211
20: 300.0000 300.00000
21: 300.0000 300.00000
22: 315.7895 300.00000
23: 331.5789 300.00000
24: 347.3684 300.00000
25: 363.1579 300.00000
26: 378.9474 300.00000
27: 394.7368 300.00000
28: 410.5263 300.00000
29: 426.3158 300.00000
30: 442.1053 300.00000
31: 457.8947 300.00000
32: 473.6842 300.00000
33: 489.4737 300.00000
34: 505.2632 300.00000
35: 521.0526 300.00000
36: 536.8421 300.00000
37: 552.6316 300.00000
38: 568.4211 300.00000
39: 584.2105 300.00000
40: 600.0000 300.00000
41: 600.0000 300.00000
42: 600.0000 286.84211
43: 600.0000 273.68421
44: 600.0000 260.52632
45: 600.0000 247.36842
46: 600.0000 234.21053
47: 600.0000 221.05263
48: 600.0000 207.89474
49: 600.0000 194.73684
50: 600.0000 181.57895
51: 600.0000 168.42105
52: 600.0000 155.26316
53: 600.0000 142.10526
54: 600.0000 128.94737
55: 600.0000 115.78947
56: 600.0000 102.63158
57: 600.0000  89.47368
58: 600.0000  76.31579
59: 600.0000  63.15789
60: 600.0000  50.00000
61: 600.0000  50.00000
62: 584.2105  50.00000
63: 568.4211  50.00000
64: 552.6316  50.00000
65: 536.8421  50.00000
66: 521.0526  50.00000
67: 505.2632  50.00000
68: 489.4737  50.00000
69: 473.6842  50.00000
70: 457.8947  50.00000
71: 442.1053  50.00000
72: 426.3158  50.00000
73: 410.5263  50.00000
74: 394.7368  50.00000
75: 378.9474  50.00000
76: 363.1579  50.00000
77: 347.3684  50.00000
78: 331.5789  50.00000
79: 315.7895  50.00000
80: 300.0000  50.00000
       FSC-H     SSC-H
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>