plot.density.profile: Plot of NGS density signal at specific regions from deepTools...

View source: R/plot.density.profile.R

plot.density.profileR Documentation

Plot of NGS density signal at specific regions from deepTools matrices.

Description

Plots the density profile of NGS data signals, using as input a score matrix computed by deeptools's computeMatrix function or by computeMatrix.deeptools and density.matrix functions from this package.

Usage

## S3 method for class 'density.profile'
plot(
  matrix.file,
  plot.by.group = T,
  missing.data.as.zero = NULL,
  sample.names = NULL,
  region.names = NULL,
  signal.type = "mean",
  error.type = "sem",
  plot.error = T,
  error.transparency = 0.125,
  title = NULL,
  x.lab = NULL,
  y.lab = NULL,
  line.type = "solid",
  line.width = 0.5,
  x.lim = NULL,
  y.lim = NULL,
  y.identical.auto = T,
  y.ticks.interval = NULL,
  y.digits = 1,
  axis.line.width = 0.5,
  text.size = 12,
  legend.position = c(0.2, 0.85),
  plot.vertical.lines = T,
  write.reference.points = T,
  colors = c("#00A5CF", "#F8766D", "#AC88FF", "#E08B00", "#00BA38", "#BB9D00", "#FF61C9",
    "gray30"),
  n.row.multiplot = 1,
  multiplot.export.file = NULL,
  real.width.single.plot = 2.9,
  real.height.single.plot = 3.5,
  by.row = TRUE,
  print.multiplot = F
)

Arguments

matrix.file

A single string indicating a full path to a matrix.gz file generated by deepTools/computeMatrix or by computeMatrix.deeptools, or a list generated by the function read.computeMatrix.file or density.matrix.

plot.by.group

Logical value to define whether plot by group of regions or by sample. By default TRUE.

missing.data.as.zero

Logical value to define whether treat missing data as 0. If set as FALSE missing data will be converted to NA and will be excluded from the computations of the signal. By default TRUE.

sample.names

Samples names could be defined by a string vector. If set as NULL sample names will be get automatically by the matrix file. By default NULL.
Example: c("sample1", "sample2", "sample3")

region.names

Region names could be defined by a string vector. If set as NULL sample names will be get automatically by the matrix file. By default NULL.
Example: c("regionA", "regionB")

signal.type

String indicating the signal to be computed and plotted. Available parameters are "mean", "median" and "sum". By default "mean".

error.type

String indicating the type of error to be computed and plotted. Available parameters are "sem" and "sd", standard error mean and standard deviation respectively. By default "sem". Parameter considered only when plot.error = TRUE).

plot.error

Logical value to define whether to plot the error around the signal. By default TRUE.

error.transparency

Numeric value to define the alpha/transparency of the error. By default 0.125. Parameter considered only when plot.error = TRUE).

title

Title of each plot could be defined by a string vector. If set as NULL titles will be generated automatically. By default NULL.
Example: c("Title1", "Title2")

x.lab

Single string or string vector to define the X-axis label for all the plots. By default NULL, the label will be defined automatically.

y.lab

Single string or string vector to define the Y-axis label for all the plots. By default NULL, the label will be defined automatically.

line.type

Vector to define each line type. Both numeric and string codes are accepted. If only one element is given this will be applied to all the lines. By default "solid".
Example 1: c("solid", "dashed").
Example 2: c(1, 2)

line.width

Numeric value to define the line width for all the plots. By default 0.5.

x.lim

List of numeric vectors with two elements each to define the range of the X-axis. To set only one side use NA for the side to leave automatic. If only one range is given this one will be applied to all the plots. By default NULL, the range will be defined automatically.
Example list(c(0, 20), c(NA, 30), c(0, NA), c(NA, NA)).,

y.lim

List of numeric vectors with two elements each to define the range of the Y-axis. To set only one side use NA for the side to leave automatic. If only one range is given this one will be applied to all the plots. By default NULL, the range will be defined automatically.
Example list(c(0, 20), c(NA, 30), c(0, NA), c(NA, NA)).,

y.identical.auto

Logical value to define whether use the same Y-axis range for all the plots automatically depending on the values. Not used when y.lim is not NULL. By default TRUE.

y.ticks.interval

A number indicating the interval/bin spacing two ticks on the Y-axis. By default NULL: ticks are assigned automatically. Active only when y.identical.auto = TRUE and y.lim != NULL.

y.digits

A numeric value to define the number of digits to use for the y.axis values. By default 1 (eg. 1.5).

axis.line.width

Numeric value to define the axes and ticks line width for all plots. By default 0.5.

text.size

Numeric value to define the size of the text for the labels of all the plots. By default 12.

legend.position

Any ggplot supported value for the legend position (eg. "none", top", "bottom", "left", "right", c(fraction.x, fraction.y)). By default c(0.2, 0.85).

plot.vertical.lines

Logical value to define whether to plot a dashed gray vertical line in correspondence of the reference points of each plot. By default TRUE.

write.reference.points

Logical value to define whether to indicate the reference points on each plot. Applied only when x.lim is NULL. By default TRUE.

colors

Vector to define the line and error area colors. If only one value is provided it will applied to all the samples/groups. If the number of values is lower than the the required one, a random set of colors will be generated. All standard R.colors values are accepted. By default c("#00A5CF", "#F8766D", "#AC88FF", "#E08B00", "#00BA38", "#BB9D00", "#FF61C9", "gray30").

n.row.multiplot

Numeric value to define the number of rows in the final multiplot.

multiplot.export.file

If a string with the name of a PDF file is provided the multiplot will be exported. By default NULL.

real.width.single.plot

Numeric value, in inches, to define the real width of each plot in the multiplot exported, if required. By default 2.9 inches.

real.height.single.plot

Numeric value, in inches, to define the real height of each plot in the multiplot exported, if required. By default 3.5 inches.

by.row

Logical value to define whether the plots should be arranged by row. By default TRUE.

print.multiplot

Logical value to define whether to print the multiplot once created. By default FALSE.

Details

To know more about the deepTools's function computeMatrix see the package manual at the following link:
https://deeptools.readthedocs.io/en/develop/content/tools/computeMatrix.html.

Value

The function returns a list containing:

  • data.table with the computed values used for the plot;

  • metadata table with the information gotten from the matrix_file.gz;

  • plot.list with a plot for each list element;

  • multiplot with the image of all the plots together.

Examples

plot.density.profile(
  matrix.file = "/path.to/matrix.file.gz", plot.by.group = TRUE,
  missing.data.as.zero = NULL, sample.names = NULL, region.names = NULL,
  signal.type = "mean", error.type = "sem", plot.error = TRUE,
  error.transparency = 0.125, title = NULL, x.lab = NULL, y.lab = NULL,
  line.type = "solid", line.width = 0.5, x.lim = NULL, y.lim = NULL,
  y.identical.auto = TRUE, y.ticks.number = 5, text.size = 12,
  plot.vertical.lines = TRUE, colors = c("red", "blue", "#00BA38"),
  n.row.multiplot = 1, multiplot.export.file = "/path.to/multiplot.pdf",
  real.width.single.plot = 2.5, real.height.single.plot = 3,
  print.multiplot = FALSE)


sebastian-gregoricchio/Rseb documentation built on May 15, 2024, 5:45 a.m.