R/RcppExports.R

Defines functions continuousPtsAboveThresholdIdx continuousPtsAboveThreshold RectUnique FindEqualGreaterM WhichColMax DescendMin ColMax DescendZero SpectrumConsensus annotation_export SpectraSearchingBatch SpectraSearchingSingle SpectraSearching PerformDIADeco PerformDDADeco calculate_entropy_similarity calculate_unweighted_entropy_similarity SpectraDeconvCore dia_feature_preparation PerformDIA_main DecoSpectra

Documented in calculate_entropy_similarity calculate_unweighted_entropy_similarity

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

DecoSpectra <- function(idx_pg, spectra_eics, peak_ms1, num_scantime, idx_apex_eic, info_pk_ms1, peakwidth_min, snthr, is_dec_smoothed) {
    .Call(`_OptiLCMS_DecoSpectra`, idx_pg, spectra_eics, peak_ms1, num_scantime, idx_apex_eic, info_pk_ms1, peakwidth_min, snthr, is_dec_smoothed)
}

PerformDIA_main <- function(pm, swath, scanrt1, scanrt2, scanms1, scanms2, pkw_min, ppm2, sn, sm_span, filt) {
    .Call(`_OptiLCMS_PerformDIA_main`, pm, swath, scanrt1, scanrt2, scanms1, scanms2, pkw_min, ppm2, sn, sm_span, filt)
}

dia_feature_preparation <- function(groupPkMtx, chromPeaks, peakidx) {
    .Call(`_OptiLCMS_dia_feature_preparation`, groupPkMtx, chromPeaks, peakidx)
}

SpectraDeconvCore <- function(idx, spectra_eics, ms1Peak, ScanNum, ms1PeakInfo, idx_apex_ms1, min_peakwidth, max_peakwidth, snthr) {
    .Call(`_OptiLCMS_SpectraDeconvCore`, idx, spectra_eics, ms1Peak, ScanNum, ms1PeakInfo, idx_apex_ms1, min_peakwidth, max_peakwidth, snthr)
}

#' @title Unweighted entropy similarity between two spectra
#' @description Calculate the unweighted entropy similarity between two spectra
#'
#'
#' @param peaks_a A matrix of spectral peaks, with two columns: mz and intensity
#' @param peaks_b A matrix of spectral peaks, with two columns: mz and intensity
#' @param ms2_tolerance_in_da The MS2 tolerance in Da, set to -1 to disable
#' @param ms2_tolerance_in_ppm The MS2 tolerance in ppm, set to -1 to disable
#' @param clean_spectra Whether to clean the spectra before calculating the entropy similarity, see \code{\link{clean_spectrum}}
#' @param min_mz The minimum mz value to keep, set to -1 to disable
#' @param max_mz The maximum mz value to keep, set to -1 to disable
#' @param noise_threshold The noise threshold, set to -1 to disable, all peaks have intensity < noise_threshold * max_intensity will be removed
#' @param max_peak_num The maximum number of peaks to keep, set to -1 to disable
#'
#' @return The unweighted entropy similarity
#'
#' @examples
#' mz_a <- c(169.071, 186.066, 186.0769)
#' intensity_a <- c(7.917962, 1.021589, 100.0)
#' mz_b <- c(120.212, 169.071, 186.066)
#' intensity_b <- c(37.16, 66.83, 999.0)
#' peaks_a <- matrix(c(mz_a, intensity_a), ncol = 2, byrow = FALSE)
#' peaks_b <- matrix(c(mz_b, intensity_b), ncol = 2, byrow = FALSE)
#' calculate_unweighted_entropy_similarity(peaks_a, peaks_b,
#'                                        ms2_tolerance_in_da = 0.02, ms2_tolerance_in_ppm = -1,
#'                                        clean_spectra = TRUE, min_mz = 0, max_mz = 1000,
#'                                        noise_threshold = 0.01,
#'                                        max_peak_num = 100)
#'
calculate_unweighted_entropy_similarity <- function(peaks_a, peaks_b, ms2_tolerance_in_da, ms2_tolerance_in_ppm, clean_spectra, min_mz, max_mz, noise_threshold, max_peak_num) {
    .Call(`_OptiLCMS_r_calculate_unweighted_entropy_similarity`, peaks_a, peaks_b, ms2_tolerance_in_da, ms2_tolerance_in_ppm, clean_spectra, min_mz, max_mz, noise_threshold, max_peak_num)
}

#' @title Entropy similarity between two spectra
#' @description Calculate the entropy similarity between two spectra
#'
#'
#' @param peaks_a A matrix of spectral peaks, with two columns: mz and intensity
#' @param peaks_b A matrix of spectral peaks, with two columns: mz and intensity
#' @param ms2_tolerance_in_da The MS2 tolerance in Da, set to -1 to disable
#' @param ms2_tolerance_in_ppm The MS2 tolerance in ppm, set to -1 to disable
#' @param clean_spectra Whether to clean the spectra before calculating the entropy similarity, see \code{\link{clean_spectrum}}
#' @param min_mz The minimum mz value to keep, set to -1 to disable
#' @param max_mz The maximum mz value to keep, set to -1 to disable
#' @param noise_threshold The noise threshold, set to -1 to disable, all peaks have intensity < noise_threshold * max_intensity will be removed
#' @param max_peak_num The maximum number of peaks to keep, set to -1 to disable
#'
#' @return The entropy similarity
#'
#' @examples
#' mz_a <- c(169.071, 186.066, 186.0769)
#' intensity_a <- c(7.917962, 1.021589, 100.0)
#' mz_b <- c(120.212, 169.071, 186.066)
#' intensity_b <- c(37.16, 66.83, 999.0)
#' peaks_a <- matrix(c(mz_a, intensity_a), ncol = 2, byrow = FALSE)
#' peaks_b <- matrix(c(mz_b, intensity_b), ncol = 2, byrow = FALSE)
#' calculate_entropy_similarity(peaks_a, peaks_b,
#'                              ms2_tolerance_in_da = 0.02, ms2_tolerance_in_ppm = -1,
#'                              clean_spectra = TRUE, min_mz = 0, max_mz = 1000,
#'                              noise_threshold = 0.01,
#'                              max_peak_num = 100)
#'
calculate_entropy_similarity <- function(peaks_a, peaks_b, ms2_tolerance_in_da, ms2_tolerance_in_ppm, clean_spectra, min_mz, max_mz, noise_threshold, max_peak_num) {
    .Call(`_OptiLCMS_r_calculate_entropy_similarity`, peaks_a, peaks_b, ms2_tolerance_in_da, ms2_tolerance_in_ppm, clean_spectra, min_mz, max_mz, noise_threshold, max_peak_num)
}

PerformDDADeco <- function(pm, scant1, scant2, scanms1, scanms2, prec_mzs, win_size, ppm1, ppm2, sn, filt, intensity_thresh, ionmode, db_path, decoOn, useEntropy, show_output, thread_num, file_nm) {
    .Call(`_OptiLCMS_PerformDDADeco`, pm, scant1, scant2, scanms1, scanms2, prec_mzs, win_size, ppm1, ppm2, sn, filt, intensity_thresh, ionmode, db_path, decoOn, useEntropy, show_output, thread_num, file_nm)
}

PerformDIADeco <- function(pm, swath, scant1, scant2, scanms1, scanms2, pkw_min, ppm2, sn, span, filt) {
    .Call(`_OptiLCMS_PerformDIADeco`, pm, swath, scant1, scant2, scanms1, scanms2, pkw_min, ppm2, sn, span, filt)
}

SpectraSearching <- function(ConsensusRes, idxs, peak_matrix, ppm_ms1, ppm_ms2, rt_tol, rt_ms1, scan_ms1, ion_mode, database_path = "", database_table = "all", use_rt = FALSE, enableNL = FALSE, NLdatabase_path = "", useEntropy = FALSE) {
    .Call(`_OptiLCMS_SpectraSearching`, ConsensusRes, idxs, peak_matrix, ppm_ms1, ppm_ms2, rt_tol, rt_ms1, scan_ms1, ion_mode, database_path, database_table, use_rt, enableNL, NLdatabase_path, useEntropy)
}

SpectraSearchingSingle <- function(ConsensusRes, idxs, peak_matrix, ppm_ms1, ppm_ms2, ion_mode, database_path = "", database_table = "all", enableNL = FALSE, NLdatabase_path = "", useEntropy = FALSE) {
    .Call(`_OptiLCMS_SpectraSearchingSingle`, ConsensusRes, idxs, peak_matrix, ppm_ms1, ppm_ms2, ion_mode, database_path, database_table, enableNL, NLdatabase_path, useEntropy)
}

SpectraSearchingBatch <- function(ConsensusRes, idxs, peak_matrix, ppm_ms1, ppm_ms2, ion_mode, database_path = "", database_table = "all", enableNL = FALSE, NLdatabase_path = "", useEntropy = FALSE) {
    .Call(`_OptiLCMS_SpectraSearchingBatch`, ConsensusRes, idxs, peak_matrix, ppm_ms1, ppm_ms2, ion_mode, database_path, database_table, enableNL, NLdatabase_path, useEntropy)
}

annotation_export <- function(searching_res, type = 0L, topN = 10L, ion_mode = 0L, database_path = "", lipidsClass = FALSE) {
    .Call(`_OptiLCMS_annotation_export`, searching_res, type, topN, ion_mode, database_path, lipidsClass)
}

SpectrumConsensus <- function(DecResList, peak_mtx, ppm_ms2, concensus_frac = 0.5, db_correction = FALSE, database_path = "", use_rt = FALSE, ion_mode = 0L, useEntropy = FALSE) {
    .Call(`_OptiLCMS_SpectrumConsensus`, DecResList, peak_mtx, ppm_ms2, concensus_frac, db_correction, database_path, use_rt, ion_mode, useEntropy)
}

DescendZero <- function(yvals, numin, istart) {
    .Call(`_OptiLCMS_DescendZero`, yvals, numin, istart)
}

ColMax <- function(inval, n, dn) {
    .Call(`_OptiLCMS_ColMax`, inval, n, dn)
}

DescendMin <- function(yvals, numin, istart) {
    .Call(`_OptiLCMS_DescendMin`, yvals, numin, istart)
}

WhichColMax <- function(inval, n, dn) {
    .Call(`_OptiLCMS_WhichColMax`, inval, n, dn)
}

FindEqualGreaterM <- function(inval, size, values, valsize) {
    .Call(`_OptiLCMS_FindEqualGreaterM`, inval, size, values, valsize)
}

RectUnique <- function(m, order, nrow, ncol, xdiff, ydiff) {
    .Call(`_OptiLCMS_RectUnique`, m, order, nrow, ncol, xdiff, ydiff)
}

continuousPtsAboveThreshold <- function(x, istart, numin, threshold, num) {
    .Call(`_OptiLCMS_continuousPtsAboveThreshold`, x, istart, numin, threshold, num)
}

continuousPtsAboveThresholdIdx <- function(x, istart, numin, threshold, num) {
    .Call(`_OptiLCMS_continuousPtsAboveThresholdIdx`, x, istart, numin, threshold, num)
}
xia-lab/OptiLCMS documentation built on Nov. 6, 2024, 11:01 a.m.