do_LigandReceptorPlot: Visualize Ligand-Receptor analysis output.

View source: R/do_LigandReceptorPlot.R

do_LigandReceptorPlotR Documentation

Visualize Ligand-Receptor analysis output.

Description

This function makes use of liana package to run Ligand-Receptor analysis. Takes the output of liana and generates a dot-plot visualization according to the user's specifications.

Usage

do_LigandReceptorPlot(
  liana_output,
  split.by = NULL,
  keep_source = NULL,
  keep_target = NULL,
  top_interactions = 25,
  top_interactions_by_group = FALSE,
  dot_border = TRUE,
  magnitude = "sca.LRscore",
  specificity = "aggregate_rank",
  sort.by = "E",
  sorting.type.specificity = "descending",
  sorting.type.magnitude = "descending",
  border.color = "black",
  axis.text.x.angle = 45,
  legend.position = "bottom",
  legend.type = "colorbar",
  legend.length = 20,
  legend.width = 1,
  legend.framecolor = "grey50",
  legend.tickcolor = "white",
  legend.framewidth = 0.5,
  legend.tickwidth = 0.5,
  use_viridis = FALSE,
  viridis.palette = "G",
  viridis.direction = 1,
  sequential.palette = "YlGnBu",
  sequential.direction = 1,
  font.size = 14,
  dot.size = 1,
  font.type = "sans",
  plot.grid = TRUE,
  grid.color = "grey90",
  grid.type = "dotted",
  compute_ChordDiagrams = FALSE,
  sort_interactions_alphabetically = FALSE,
  number.breaks = 5,
  plot.title.face = "bold",
  plot.subtitle.face = "plain",
  plot.caption.face = "italic",
  axis.title.face = "bold",
  axis.text.face = "plain",
  legend.title.face = "bold",
  legend.text.face = "plain",
  return_interactions = FALSE,
  invert_specificity = TRUE,
  invert_magnitude = FALSE,
  verbose = TRUE
)

Arguments

liana_output

tibble | Object resulting from running liana_wrap and liana_aggregate.

split.by

character | Whether to further facet the plot on the y axis by common ligand.complex or receptor.complex. Values to provide: NULL, ligand.complex, receptor.complex.

keep_source, keep_target

character | Identities to keep for the source/target of the interactions. NULL otherwise.

top_interactions

numeric | Number of unique interactions to retrieve ordered by magnitude and specificity. It does not necessarily mean that the output will contain as many, but rather an approximate value.

top_interactions_by_group

logical | Enforce the value on top_interactions to be applied to each group in source column.

dot_border

logical | Whether to draw a black border in the dots.

specificity, magnitude

character | Which columns to use for specificity and magnitude.

sort.by

character | How to arrange the top interactions. Interactions are sorted and then the top N are retrieved and displayed. This takes place after subsetting for keep_source and keep_target One of:

  • A: Sorts by specificity.

  • B: Sorts by magnitude.

  • C: Sorts by specificity, then magnitude (gives extra weight to specificity).

  • D: Sorts by magnitude, then specificity (gives extra weight to magnitude). Might lead to the display of non-significant results.

  • E: Sorts by specificity and magnitude equally.

sorting.type.specificity, sorting.type.magnitude

character | Whether the sorting of e magnitude or specificity columns is done in ascending or descending order. This synergises with the value of e invert_specificity and e invert_magnitude parameters.

border.color

character | Color for the border of the heatmap body.

axis.text.x.angle

numeric | Degree to rotate the X labels. One of: 0, 45, 90.

legend.position

character | Position of the legend in the plot. One of:

  • top: Top of the figure.

  • bottom: Bottom of the figure.

  • left: Left of the figure.

  • right: Right of the figure.

  • none: No legend is displayed.

legend.type

character | Type of legend to display. One of:

  • normal: Default legend displayed by ggplot2.

  • colorbar: Redefined colorbar legend, using guide_colorbar.

legend.length, legend.width

numeric | Length and width of the legend. Will adjust automatically depending on legend side.

legend.framecolor

character | Color of the lines of the box in the legend.

legend.tickcolor

character | Color of the ticks of the box in the legend.

legend.framewidth, legend.tickwidth

numeric | Width of the lines of the box in the legend.

use_viridis

logical | Whether to use viridis color scales.

viridis.palette

character | A capital letter from A to H or the scale name as in scale_fill_viridis.

viridis.direction

numeric | Either 1 or -1. Controls how the gradient of viridis scale is formed.

sequential.palette

character | Type of sequential color palette to use. Out of the sequential palettes defined in brewer.pal.

sequential.direction

numeric | Direction of the sequential color scale. Either 1 or -1.

font.size

numeric | Overall font size of the plot. All plot elements will have a size relationship with this font size.

dot.size

numeric | Size aesthetic for the dots.

font.type

character | Base font family for the plot. One of:

  • mono: Mono spaced font.

  • serif: Serif font family.

  • sans: Default font family.

plot.grid

logical | Whether to plot grid lines.

grid.color

character | Color of the grid in the plot. In heatmaps, color of the border of the cells.

grid.type

character | One of the possible linetype options:

  • blank.

  • solid.

  • dashed.

  • dotted.

  • dotdash.

  • longdash.

  • twodash.

compute_ChordDiagrams

logical | Whether to also compute Chord Diagrams for both the number of interactions between source and target but also between ligand.complex and receptor.complex.

sort_interactions_alphabetically

logical | Sort the interactions to be plotted alphabetically (TRUE) or keep them in their original order in the matrix (FALSE).

number.breaks

numeric | Controls the number of breaks in continuous color scales of ggplot2-based plots.

plot.title.face, plot.subtitle.face, plot.caption.face, axis.title.face, axis.text.face, legend.title.face, legend.text.face

character | Controls the style of the font for the corresponding theme element. One of:

  • plain: For normal text.

  • italic: For text in itallic.

  • bold: For text in bold.

  • bold.italic: For text both in itallic and bold.

return_interactions

logical | Whether to return the data.frames with the interactions so that they can be plotted as chord plots using other package functions.

invert_specificity, invert_magnitude

logical | Whether to -log10 transform specificity and magnitude columns.

verbose

logical | Whether to show extra comments, warnings,etc.

Value

A ggplot2 plot with the results of the Ligand-Receptor analysis.

Examples


  # Check Suggests.
  value <- SCpubr:::check_suggests(function_name = "do_LigandReceptorPlot", passive = TRUE)

  if (isTRUE(value)){
    liana_output <- readRDS(system.file("extdata/liana_output_example.rds", package = "SCpubr"))
    # Ligand Receptor analysis plot.
    p <- SCpubr::do_LigandReceptorPlot(liana_output = liana_output)
    p

  } else if (base::isFALSE(value)){
    message("This function can not be used without its suggested packages.")
    message("Check out which ones are needed using `SCpubr::state_dependencies()`.")
  }



enblacar/SCpubr documentation built on Feb. 11, 2024, 4:15 a.m.