This function detects the peak mode locations for each sample per ADT markers. Using the peak mode instead of the peak region midpoint can be more accurate in determining the peak location if the bandwidth is generally proper and the local peak density is not too discrete.

get_peak_mode(
  cell_x_adt = NULL,
  cell_x_feature = NULL,
  adt_marker_select = NULL,
  adt_marker_index = NULL,
  bwFac_smallest = 1.1,
  bimodal_marker_index = NULL,
  trimodal_marker_index = NULL,
  positive_peak = NULL,
  neg_candidate_thres = asinh(10/5 + 1),
  lower_peak_thres = 0.001,
  arcsinh_transform_flag = TRUE
)

Arguments

cell_x_adt

Matrix of ADT raw counts in cells (rows) by ADT markers (columns) format.

cell_x_feature

Matrix of cells (rows) by cell features (columns) such as cell type, sample, and batch-related information.

adt_marker_select

Markers to normalize. Leaving empty to process all the ADT markers in the cell_x_adt matrix.

adt_marker_index

Index of the ADT markers that will be normalized. Leaving empty if adt_marker_select is not specified.

bwFac_smallest

The smallest bandwidth parameter value. Recommend 1.1 for general bi-modal ADT markers except for CD3, CD4, and CD8.

bimodal_marker_index

Index of the ADT markers that tend to have two peaks based on researchers' prior knowledge or preliminary observation on particular data to be processed.

trimodal_marker_index

Index of the ADT markers that tend to have three peaks based on researchers' prior knowledge (e.g., CD4) or preliminary observation on particular data to be processed.

positive_peak

A list variable containing a vector of ADT marker(s) and a corresponding vector of sample name(s) in matching order to specify that the uni-peak detected should be aligned to positive peaks. For example, for samples that only contain T cells. The only CD3 peak should be aligned with the positive peaks of other samples.

neg_candidate_thres

The upper bound for the negative peak. Users can refer to their IgG samples to obtain the minimal upper bound of the IgG sample peak. It can be one of the values of asinh(4/5+1), asinh(6/5+1), or asinh(8/5+1) if the right 95% quantile of IgG samples is large.

lower_peak_thres

The minimal ADT marker density height to call it a real peak. Set it to 0.01 to avoid suspicious positive peaks. Set it to 0.001 or smaller to include some small but tend to be real positive peaks, especially for markers like CD19.

arcsinh_transform_flag

The flag indicates if the input is raw count and arcsinh transformation is implemented.

Examples

if (FALSE) {
get_peak_mode(
  cell_x_adt = cell_x_adt,
  cell_x_feature = cell_x_feature,
  adt_marker_select = "CD3",
  neg_candidate_thres = asinh(6/5+1)
)
}