plot_JSD_logo: Calculate and plot the Jensen-Shannon divergence between 2...

View source: R/pwm_utils.R

plot_JSD_logoR Documentation

Description

Calculate and plot the Jensen-Shannon divergence between 2 sets of sequences contained in 2 data.frames

Usage

plot_JSD_logo(
  df1,
  df2,
  ID_col,
  alphabet,
  y_lims = c(-0.5, 0.5),
  max_JS_div_thrshld,
  anno_width = 0.75,
  highlight_colour = "grey74",
  axis_txt_size = 10,
  ttl_txt = NULL,
  ...
)

Arguments

df1

A data.frame with a column called Sequence and anther defined in ID_col. Use the wrapper fasta2df() to import a fasta file to a dataframe that is compatible with this function.

df2

A different data.frame with the same properties as df1.

ID_col

A character specifying the column name in df1 and df2 to be used as the sequence ID.

alphabet

A character vector containing the alphabet letters present in Sequence. Guessed by default from df1.

y_lims

A numeric vector of length 2 specifying the Y-axis min and max value. Default c(-0.5, 0.5)

max_JS_div_thrshld

The maximal absolute JS divergence threshold to consider a letter position to be highlighted by a vertical bar in the plot.

anno_width

A small number that defines how wide the vertical bar should be. Default 0.75.

highlight_colour

A colour name to fill the letter highlighting rectangle. Default grey74 with alpha = 0.5.

axis_txt_size

A number specifying the size of the axis text in the plot. Default 10.

ttl_txt

Some text in quotes specifying the plot title.

...

Advanced parameters passed to renumber_logo_seq_breaks.

Value

A ggplot sequence logo with the Jensen-Shannon divergence on the Y-axis.

Examples

plot_JSD_logo(df1 = clade1, df2 = clade2f, ID_col = 'Species',
              max_JS_div_thrshld = 0.2, anno_width = 0.5)

Ni-Ar/niar documentation built on Feb. 3, 2025, 9:25 a.m.