Skip to contents

A function for plotting spatial phylogenetic trees on Visium 10X data.

Usage

SpatialPhyloPlot(
  visium_version,
  newick_file,
  image_file,
  tissue_positions_file,
  clone_df,
  scale_factors,
  clone_group_column,
  clone_barcode_column = "Barcode",
  palette = "default",
  plot_points = TRUE,
  plot_polygon = FALSE,
  point_alpha = 0.8,
  point_size = 1.5,
  point_shape = 19,
  hull_alpha = 0,
  hull_expansion = 0.005,
  centroid_alpha = 0.9,
  centroid_size = 8,
  plot_internal_nodes = FALSE,
  internal_node_colour = "grey80",
  internal_node_size = 3,
  internal_node_alpha = 0.5,
  segment_alpha = 0.8,
  segment_width = 2,
  segment_colour = "grey",
  fig_offset_x = 0,
  fig_offset_y = 0,
  multisample = FALSE,
  shared_clones = FALSE,
  plot_connections = FALSE,
  image_file_left = NA,
  image_file_right = NA,
  image_file_top = NA,
  image_file_bottom = NA,
  clone_df_left = NA,
  clone_df_right = NA,
  clone_df_top = NA,
  clone_df_bottom = NA,
  tissue_positions_file_left = NA,
  tissue_positions_file_right = NA,
  tissue_positions_file_top = NA,
  tissue_positions_file_bottom = NA,
  scale_factors_left = NA,
  scale_factors_right = NA,
  scale_factors_top = NA,
  scale_factors_bottom = NA,
  connection_width = 1,
  connection_colour = "grey",
  nestedness = 10,
  origin_coord = NA,
  origin_name = "diploid",
  ...
)

Arguments

visium_version

Which version of Visium was used. Should be either `"V1"` or `"V2"`

newick_file

A file path to the phylogenetic tree in the Newick format saved as a `.new` file.

image_file

A file path to the hires Visium 10X png image to plot.

tissue_positions_file

A file path to the Visium 10X `tissue_positions_list.csv` file for V1 or `tissue_positions.csv` file for V2.

clone_df

A `data.frame` listing which barcode belongs to which clone.

scale_factors

A path to the `scalefactors_json.json` file produced by SpaceRanger.

clone_group_column

The name of the column in `clone_df` that indicates the clones.

clone_barcode_column

The name of the column in `clone_df` that indicates the barcode.

palette

A named list of colours for each clone. Defaults to `RColorBrewer` `Set2` followed by the `pals` `alphabet` sets.

plot_points

Whether individual Visium spots should be plotted. Defaults to `TRUE`.

plot_polygon

Whether a polygon should be plotted for each clone. Defaults to `FALSE`.

point_alpha

The alpha transparency value for points, default is `0.8`.

point_size

The size of the Visium spot points, default is `1.5`.

point_shape

The shape to use for the Visium spot points, default is `19`.

hull_alpha

The alpha transparency value for polygons/hulls to be plotted, default is `0` (not plotted).

hull_expansion

The hull/polygon extension amount, default is `0.005`.

centroid_alpha

The alpha transparency value for the centroids plotted as part of the phylogenetic tree, default is `0.9`.

centroid_size

The size of the plotted centroid points, default is `8`.

plot_internal_nodes

Whether or not to plot internal nodes in the tree. Defaults to `FALSE`.

internal_node_colour

Colour used to represent internal nodes. Defaults to `"grey80"`.

internal_node_size

Size of internal nodes. Defaults to `3`.

internal_node_alpha

Alpha for internal nodes. Defaults to `0.5`

segment_alpha

The alpha transparency value for phylogenetic tree segments, default is `0.8`.

segment_width

The width of the phylogenetic tree segments, default is `2`.

segment_colour

The colour of the phylogenetic tree segments, default is `"grey"`.

fig_offset_x

The offset to adjust the histology image x_end location, if required. Default is `0.011`, adjustments not recommended.

fig_offset_y

The offset to adjust the histology image y location, if required. Default is `0.011` adjustments not recommended.

multisample

Whether multiple samples are being plotted with the same phylogenetic tree. Defaults to `FALSE`.

shared_clones

Whether the same clones appear in multiple samples. Defaults to `FALSE`.

plot_connections

Whether connections should be plotted between clones that are present in multiple samples. Defaults to `FALSE`.

image_file_left

If running in multisample mode; a file path to the hires Visium 10X png image to plot to the left of the main sample.

image_file_right

If running in multisample mode; a file path to the hires Visium 10X png image to plot to the right of the main sample.

image_file_top

If running in multisample mode; a file path to the hires Visium 10X png image to plot above the main sample.

image_file_bottom

If running in multisample mode; a file path to the hires Visium 10X png image to plot below the main sample.

clone_df_left

If running in multisample mode; a `data.frame` listing which barcode belongs to which clone belonging to the sample plotted to the left of the main sample.

clone_df_right

If running in multisample mode; a `data.frame` listing which barcode belongs to which clone belonging to the sample plotted to the right of the main sample.

clone_df_top

If running in multisample mode; a `data.frame` listing which barcode belongs to which clone belonging to the sample plotted above the main sample.

clone_df_bottom

If running in multisample mode; a `data.frame` listing which barcode belongs to which clone belonging to the sample plotted below the main sample.

tissue_positions_file_left

If running in multisample mode; a path to the Visium 10X `tissue_positions_list.csv` file for V1 or `tissue_positions.csv` file for V2, belonging to the sample plotted to the left of the main sample.

tissue_positions_file_right

If running in multisample mode; a path to the Visium 10X `tissue_positions_list.csv` file for V1 or `tissue_positions.csv` file for V2, belonging to the sample plotted to the right of the main sample.

tissue_positions_file_top

If running in multisample mode; a path to the Visium 10X `tissue_positions_list.csv` file for V1 or `tissue_positions.csv` file for V2, belonging to the sample plotted above the main sample.

tissue_positions_file_bottom

If running in multisample mode; a path to the Visium 10X `tissue_positions_list.csv` file for V1 or `tissue_positions.csv` file for V2, belonging to the sample plotted below the main sample.

scale_factors_left

If running in multisample mode; a path to the Visium 10X `scalefactors_json.json` file produced by SpaceRanger, belonging to the sample plotted to the left of the main sample.

scale_factors_right

If running in multisample mode; a path to the Visium 10X `scalefactors_json.json` file produced by SpaceRanger, belonging to the sample plotted to the right of the main sample.

scale_factors_bottom

If running in multisample mode; a path to the Visium 10X `scalefactors_json.json` file produced by SpaceRanger, belonging to the sample plotted below the main sample.

connection_width

The width of the connecting segment linking clones between samples. Defaults to `1`.

connection_colour

The colour of the connecting segment linking clones between samples. Defaults to `grey`.

nestedness

Roughly, how many layers of internal nodes there are in the phylogenetic tree. Defaults to `10`. Consider increasing if you notice missing connections, otherwise leave as is.

origin_coord

xy coordinates at which to plot the "origin" of the phylogenetic tree. Defaults to `NA`. Example: `c(0,1)` for top left corner.

origin_name

Name of the origin clone in the phylogenetic tree. Defaults to `"diploid"` in line with MEDICC2 output.

scale_factors_topIf

running in multisample mode; a path to the Visium 10X `scalefactors_json.json` file produced by SpaceRanger, belonging to the sample plotted on top of the main sample.

Value

A ggplot2 object with the tissue, clones, and phylogenetic trees plotted together.