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

Source: `R/ggcyto.R`
`as.ggplot.Rd`

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.

    as.ggplot(x, pre_binning = FALSE)

## Arguments

x | ggcyto object with the data that has not yet been fortified to data.frame.
pre_binning | whether to pass the binned data to ggplot to avoid the overhead to scaling the original raw data for geom_hex layer

## 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#> [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 Timep1 <- 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