Skip to contents

Create GIF image for dynamic rotating view of 3D quaternary simplex plot

Usage

writeQuaternaryGIF(
  x,
  ...,
  cluster = NULL,
  filename = NULL,
  fps = 10,
  degreePerFrame = 10,
  width = 5,
  height = 5,
  res = 100
)

Arguments

x

Input object that plotQuaternary accepts.

...

All other arguments needed for plotQuaternary. Must be specified with exact argument names instead of a positional manner.

cluster

One cluster that exists in clusterVar if users need to view the plot for a specific group. Default NULL plot all cells.

filename

Output GIF image file path. Default NULL does not write to file.

fps

Number of frame per second, must be a factor of 100. Default 10.

degreePerFrame

Number of degree that the tetrahedron is rotated per frame. Default 10.

width, height, res

grDevices::png parameters to set figure size and resolutation. Width and Height are in inches. Default 5, 5, 100.

Value

A object of class magick-image that can be shown in the Viewer panel in RStudio or equivalent display device. If filename is specified, the GIF image will be written to the file path.

Examples

gene <- selectTopFeatures(rnaRaw, rnaCluster, c("RE", "OS", "CH", "ORT"))
#> Selected 30 features for "CH".
#> Selected 30 features for "ORT".
#> Selected 30 features for "OS".
#> Selected 30 features for "RE".
# \donttest{
writeQuaternaryGIF(rnaRaw, clusterVar = rnaCluster, features = gene,
                   vertices = c("RE", "OS", "CH", "ORT"),
                   gifPath = tempfile(fileext = ".gif"))
#>  Assembling frames
#>  Assembling frames ... done
#> 
#> # A tibble: 37 × 7
#>    format width height colorspace matte filesize density
#>    <chr>  <int>  <int> <chr>      <lgl>    <int> <chr>  
#>  1 gif      500    500 sRGB       TRUE         0 72x72  
#>  2 gif      500    500 sRGB       TRUE         0 72x72  
#>  3 gif      500    500 sRGB       TRUE         0 72x72  
#>  4 gif      500    500 sRGB       TRUE         0 72x72  
#>  5 gif      500    500 sRGB       TRUE         0 72x72  
#>  6 gif      500    500 sRGB       TRUE         0 72x72  
#>  7 gif      500    500 sRGB       TRUE         0 72x72  
#>  8 gif      500    500 sRGB       TRUE         0 72x72  
#>  9 gif      500    500 sRGB       TRUE         0 72x72  
#> 10 gif      500    500 sRGB       TRUE         0 72x72  
#> # ℹ 27 more rows
# }