Constructs a density plot for a calculated variable in e_meta portion of ftmsData object

densityPlot(
  ftmsObj,
  variable,
  samples = NA,
  groups = FALSE,
  title = NA,
  yaxis = "density",
  plot_hist = FALSE,
  plot_curve = TRUE,
  curve_colors = NA,
  hist_color = "gray",
  xlabel = NA,
  ylabel = paste0(toupper(substring(yaxis, 1, 1)), substring(yaxis, 2), sep = "")
)

Arguments

ftmsObj

ftmsData object of class peakData or compoundData

variable

column name of column in e_meta which should be plotted. Must be one of the column names in ftmsObj$e_meta that contains numeric values.

samples

vector of sample names to plot. Default of NA indicates all samples found in ftmsObj should be plotted. Specify samples=FALSE to plot no samples, only groups.

groups

vector of group names to plot. Value of NA indicates all groups found in ftmsObj should be plotted. Default value of groups=FALSE to plot no groups, only samples.

title

plot title, default is NA (no title)

yaxis

what should the y-axis represent, "density" or "count"?

plot_hist

TRUE/FALSE should a histogram be added to the plot? A histogram may only be added if a single sample or groups is plotted.

plot_curve

TRUE/FALSE should a smoothed curve be added to the plot?

curve_colors

named vector of colors for curves, where names correspond to samples or groups chosen. Named colors or hex codes are accepted.

hist_color

(single) color for histogram bars. Named colors or hex codes are accepted.

xlabel

x axis label, default is NULL, which will result in the same name as "variable"

ylabel

y axis label, default is "Density"

Value

a plotly object

Details

If a histogram is produced, the histogram bar data as a data frame is attached to the output as the attribute hist_data. This may be useful for adding additional data to the plot, e.g. for linking selections in multiple plots.

See also

plot_ly

Author

Allison Thompson, Lisa Bramer, Amanda White