Description
An R6 class that splits the MS1 mass range into n_bins windows with about equal numbers of precursors. The window boundaries (breaks) are computed once, when the object is created, with one of three methods:
-
“mixture” (default): the quantile breaks of the masses mixed with uniformly spread data, with the smallest share of uniform data that keeps all window widths within [min_window, max_window]; the quantile breaks themselves if they fit. The limits hold for the rounded and padded breaks. Stops if even windows of equal width violate the limits.
-
“quantile”: windows with equal numbers of masses, of any width.
-
“constant”: windows of equal width.
The breaks are rounded to digits decimals, and the outer breaks are rounded outward and padded by 1 / 10^digits, so that the windows enclose all masses.
The object cannot be changed: its fields are read-only and its methods only read them, so their results do not depend on the order in which they are called. To compare methods or settings, create one object for each. clone() copies an object.
Methods
Public methods
Cdsw$new()
Compute the breaks of n_bins windows over the masses with method.
Usage
Cdsw\$new(
masses,
n_bins = 25,
method = c("mixture", "quantile", "constant"),
max_window = 150,
min_window = 5,
digits = 2
)
Arguments
-
masses
-
MS1 masses (m/z): a numeric vector of finite values.
-
n_bins
-
Number of windows.
-
method
-
How to place the breaks:
“mixture” (default), “quantile” or “constant”; see Description.
-
max_window, min_window
-
Largest and smallest window width in m/z; used by
method = “mixture” only.
-
digits
-
Number of decimal places of the breaks.
Returns
A new Cdsw object.
Cdsw$print()
Print the number of masses and windows, the method and the range of window widths.
Usage
Arguments
Returns
The object, invisibly.
Cdsw$as_table()
The windows as a data frame.
Usage
Cdsw\$as_table(overlap = 1)
Arguments
-
overlap
-
Overlap of neighboring windows in m/z, at least 0: each window is widened by
overlap / 2 on both sides.
Returns
A data frame with one row per window: start from, end to, center mid, width and the number of precursors with from < m/z <= to (n_precursors).
Cdsw$error()
Deviation of the windows from equal numbers of precursors.
Usage
Returns
A list with manhattan (Manhattan distance), euclidean (Euclidean distance), normalized_counts (precursors per window) and equal_counts (the counts of windows with equal numbers of precursors), both counts normalized to length 1.
Cdsw$optimize_windows()
Move window starts and ends to regions with few precursors, with readjust_windows().
Usage
Cdsw\$optimize_windows(bin_width = 0.1, min_count = 15, overlap = 1)
Arguments
-
bin_width
-
Width of the bins (m/z) into which the masses are binned.
-
min_count
-
Bins with fewer than
min_count precursors count as empty.
-
overlap
-
Overlap of neighboring windows in m/z, as in
as_table().
Returns
A data frame with the columns of as_table().
Cdsw$plot()
Plot the precursors per window (from < m/z <= to); the dashed line marks equal counts.
Usage
Returns
A ggplot object.
Cdsw$plot_breaks()
Plot the breaks of this object against the constant and quantile breaks of the same masses.
Usage
Returns
A ggplot object.
Cdsw$plot_cycle()
Plot the DIA cycle, one window per step.
Usage
Cdsw\$plot_cycle(overlap = 1)
Arguments
-
overlap
-
Overlap of neighboring windows in m/z, as in
as_table().
Returns
A ggplot object.
Cdsw$clone()
The objects of this class are cloneable with this method.
Usage
Cdsw\$clone(deep = FALSE)
Arguments
-
deep
-
Whether to make a deep clone.