Last data update: 2014.03.03

R: It fortifies the data, fills some default settings and...
as.ggplotR Documentation

It fortifies the data, fills some default settings and returns a regular ggplot object.

Description

The orginal data format is preserved during the ggcyo constructor because they still need to be used during the plot building process. This function is usually called automatically in the print/plot method of ggycyto. Sometime it is useful to coerce it to ggplot explictily by user so that it can be used as a regular ggplot object.

Usage

as.ggplot(x)

Arguments

x

ggcyto object with the data that has not yet been fortified to data.frame.

Value

ggplot object

Examples

data(GvHD)
fs <- GvHD[1:3]
#construct the `ggcyto` object (inherits from `ggplot` class)
p <- ggcyto(fs, aes(x = `FSC-H`)) + geom_histogram()
class(p) # a ggcyto object
p$data # data has not been fortified
p1 <- as.ggplot(p) # convert it to a ggplot object explictily
class(p1)
p1$data # data is fortified

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/as.ggplot.Rd_%03d_medium.png", width=480, height=480)
> ### Name: as.ggplot
> ### Title: It fortifies the data, fills some default settings and returns a
> ###   regular ggplot object.
> ### Aliases: as.ggplot
> 
> ### ** Examples
> 
> data(GvHD)
> fs <- GvHD[1:3]
> #construct the `ggcyto` object (inherits from `ggplot` class)
> p <- ggcyto(fs, aes(x = `FSC-H`)) + geom_histogram()
> class(p) # a ggcyto object
[1] "ggcyto_flowSet"
attr(,"package")
[1] "ggcyto"
> p$data # data has not been fortified
A flowSet with 3 experiments.

An object of class 'AnnotatedDataFrame'
  rowNames: s5a01 s5a02 s5a03
  varLabels: Patient Visit ... name (5 total)
  varMetadata: labelDescription

  column names:
  FSC-H SSC-H FL1-H FL2-H FL3-H FL2-A FL4-H Time
> p1 <- as.ggplot(p) # convert it to a ggplot object explictily
> class(p1)
[1] "gg"     "ggplot"
> p1$data # data is fortified
       .rownames Patient Visit Days Grade  name FSC-H
    1:     s5a01       5     1   -6     3 s5a01   371
    2:     s5a01       5     1   -6     3 s5a01   190
    3:     s5a01       5     1   -6     3 s5a01   141
    4:     s5a01       5     1   -6     3 s5a01   167
    5:     s5a01       5     1   -6     3 s5a01   128
   ---                                               
10256:     s5a03       5     3    6     3 s5a03   231
10257:     s5a03       5     3    6     3 s5a03   197
10258:     s5a03       5     3    6     3 s5a03    76
10259:     s5a03       5     3    6     3 s5a03   346
10260:     s5a03       5     3    6     3 s5a03   367
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>