Skip to contents

This function generates a plot for a given sample from Particle Size Distribution (PSD) data and fits from Imaging FlowCytobot (IFCB). The PSD data and fits can be generated by ifcb_psd (Hayashi et al. 2025).

Usage

ifcb_psd_plot(sample_name, data, fits, start_fit, flags = NULL)

Arguments

sample_name

The name of the sample to plot in DYYYYMMDDTHHMMSS_IFCBXXX.

data

A data frame containing the PSD data (data output from ifcb_psd), where each row represents a sample and each column represents different particle sizes in micrometers.

fits

A data frame containing the fit parameters for the power curve (fits output from ifcb_psd), where each row represents a sample and the columns include the parameters a, k, and R^2.

start_fit

The x-value threshold below which data should be excluded from the plot and fit.

flags

Optional data frame or tibble with columns sample and flag. If sample_name appears in flags$sample, the corresponding flag text will be displayed on the plot as a red label in the top-left corner.

Value

A ggplot object representing the PSD plot for the sample.

References

Hayashi, K., Enslein, J., Lie, A., Smith, J., Kudela, R.M., 2025. Using particle size distribution (PSD) to automate imaging flow cytobot (IFCB) data quality in coastal California, USA. International Society for the Study of Harmful Algae. https://doi.org/10.15027/0002041270

Examples

if (FALSE) { # \dontrun{
# Initialize a python session if not already set up
ifcb_py_install()

# Analyze PSD
psd <- ifcb_psd(
  feature_folder = 'path/to/features',
  hdr_folder = 'path/to/hdr_data',
  save_data = TRUE,
  output_file = 'psd/svea_2021',
  plot_folder = NULL,
  use_marker = FALSE,
  start_fit = 13,
  r_sqr = 0.5
)

# Optional flags
flags <- tibble::tibble(
  sample = "D20230316T101514",
  flag   = "Incomplete Run."
)

# Plot PSD of the first sample
plot <- ifcb_psd_plot(
  sample_name = "D20230316T101514",
  data = psd$data,
  fits = psd$fits,
  start_fit = 10,
  flags = flags
)

# Inspect plot
print(plot)
} # }