Skip to contents

These functions generate heatmaps, spectral plots, and interactive plots for OpenSpecy data.

Usage

plotly_spec(x, ...)

# Default S3 method
plotly_spec(x, ...)

# S3 method for class 'OpenSpecy'
plotly_spec(
  x,
  x2 = NULL,
  model = NULL,
  model_class = NULL,
  model_colorscale = list(c(0, "#d73027"), c(0.5, "#fee08b"), c(1, "#1a9850")),
  model_opacity = 0.28,
  line = list(color = "rgb(255, 255, 255)"),
  line2 = list(dash = "dot", color = "rgb(255,0,0)"),
  font = list(color = "#FFFFFF"),
  plot_bgcolor = "rgba(17, 0, 73, 0)",
  paper_bgcolor = "rgb(0, 0, 0)",
  showlegend = FALSE,
  make_rel = TRUE,
  ...
)

model_class_weights(model, model_class)

heatmap_spec(x, ...)

# Default S3 method
heatmap_spec(x, ...)

# S3 method for class 'OpenSpecy'
heatmap_spec(
  x,
  z = NULL,
  sn = NULL,
  cor = NULL,
  min_sn = NULL,
  min_cor = NULL,
  select = NULL,
  font = list(color = "#FFFFFF"),
  plot_bgcolor = "rgba(17, 0, 73, 0)",
  paper_bgcolor = "rgb(0, 0, 0)",
  colorscale = "Viridis",
  showlegend = FALSE,
  type = "interactive",
  ...
)

interactive_plot(x, ...)

# Default S3 method
interactive_plot(x, ...)

# S3 method for class 'OpenSpecy'
interactive_plot(
  x,
  x2 = NULL,
  select = NULL,
  line = list(color = "rgb(255, 255, 255)"),
  line2 = list(dash = "dot", color = "rgb(255,0,0)"),
  font = list(color = "#FFFFFF"),
  plot_bgcolor = "rgba(17, 0, 73, 0)",
  paper_bgcolor = "rgb(0, 0, 0)",
  colorscale = "Viridis",
  ...
)

Arguments

x

an OpenSpecy object containing metadata and spectral data for the first group.

x2

an optional second OpenSpecy object containing metadata and spectral data for the second group.

model

optional model library returned by train_spec_model(). Supplying this with model_class adds a logistic-regression coefficient background to plotly_spec().

model_class

exact trained class label whose signed logistic coefficients should be displayed. Positive weights are green, values near zero yellow, and negative weights red. These are model weights, not causal peak attributions.

model_colorscale

continuous Plotly colorscale for signed model weights, centered at zero.

model_opacity

opacity of the model-weight background from zero to one.

line

list; line parameter for x; passed to add_trace().

line2

list; line parameter for x2; passed to

font

list; passed to layout().

plot_bgcolor

color value; passed to layout().

paper_bgcolor

color value; passed to layout().

showlegend

whether to show the legend passed to

make_rel

logical, whether to make the spectra relative or use the raw values

z

optional numeric vector specifying the intensity values for the heatmap. If not provided, the function will use the intensity values from the OpenSpecy object.

sn

optional numeric value specifying the signal-to-noise ratio threshold. If provided along with min_sn, regions with SNR below the threshold will be excluded from the heatmap.

cor

optional numeric value specifying the correlation threshold. If provided along with min_cor, regions with correlation below the threshold will be excluded from the heatmap.

min_sn

optional numeric value specifying the minimum signal-to-noise ratio for inclusion in the heatmap. Regions with SNR below this threshold will be excluded.

min_cor

optional numeric value specifying the minimum correlation for inclusion in the heatmap. Regions with correlation below this threshold will be excluded.

select

optional index of the selected spectrum to highlight on the heatmap.

colorscale

colorscale passed to add_trace() can be an array or one of "Blackbody", "Bluered", "Blues", "Cividis", "Earth", "Electric", "Greens", "Greys", "Hot", "Jet", "Picnic", "Portland", "Rainbow", "RdBu", "Reds", "Viridis", "YlGnBu", "YlOrRd".

type

specification for plot type either interactive or static plot_ly().

...

further arguments passed to plot_ly().

Value

A plotly heatmap object displaying the OpenSpecy data. A subplot containing the heatmap and spectra plot. A plotly object displaying the spectra from the OpenSpecy object(s).

Author

Win Cowger, Zacharias Steinmetz

Examples

data("raman_hdpe")
tiny_map <- read_extdata("CA_tiny_map.zip") |> read_zip()
plotly_spec(raman_hdpe)
heatmap_spec(tiny_map, z = tiny_map$metadata$y, showlegend = TRUE)
sample_spec(tiny_map, size = 12) |> interactive_plot(select = 2, x2 = raman_hdpe) #> No trace type specified: #> Based on info supplied, a 'scatter' trace seems appropriate. #> Read more about this trace type -> https://plotly.com/r/reference/#scatter #> No scatter mode specifed: #> Setting the mode to markers #> Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode #> A line object has been specified, but lines is not in the mode #> Adding lines to the mode...