Skip to contents

Create an animation showing how gene-gene relationships evolve with increasing diffusion time t.

Usage

animate_magic(
  data,
  gene_x,
  gene_y,
  gene_color = NULL,
  t_max = 20,
  delay = 2,
  operator = NULL,
  filename = NULL,
  width = 600,
  height = 500,
  point_size = 1,
  interval = 200,
  verbose = FALSE,
  ...
)

Arguments

data

Input data matrix (cells x genes).

gene_x

Gene for x-axis (name or index).

gene_y

Gene for y-axis (name or index).

gene_color

Gene for coloring points (optional).

t_max

Maximum t value. Default is 20.

delay

Number of initial frames before diffusion. Default is 2.

operator

Pre-computed magic object. Default is NULL.

filename

Output filename (.gif). Default is NULL (no save).

width

Plot width in pixels. Default is 600.

height

Plot height in pixels. Default is 500.

point_size

Point size. Default is 1.

interval

Milliseconds between frames. Default is 200.

verbose

Verbosity. Default is FALSE.

...

Additional arguments passed to magic().

Value

A list of ggplot objects (one per frame), or writes a GIF file.

Details

This function creates an animation showing how MAGIC diffusion progressively reveals gene-gene relationships. It requires the gganimate and gifski packages for GIF output.

Examples

if (FALSE) { # \dontrun{
data(magic_testdata)

# Create animation frames
frames <- animate_magic(magic_testdata, 
                        gene_x = 1, gene_y = 2,
                        t_max = 10)

# Save as GIF (requires gganimate and gifski)
animate_magic(magic_testdata, 
              gene_x = 1, gene_y = 2,
              t_max = 10,
              filename = "magic_animation.gif")
} # }