RECETOX/recetox-aplcms

fix peak picking corner case when an EIC has between 2 and 10 features

Closed this issue · 1 comments

If an EIC after noise removal has between 2 and 10 features, it is always assumed to be a single peak no matter if it has 2 sections of consecutive scans at 2 distinct retention times. This causes very broad peaks instead of detecting 2 individual peaks.

if (dplyr::between(num_features, 2, 10)) {
# linear interpolation of missing intensities and calculate the area for a single EIC
eic_area <- interpol.area(feature_group[, "rt"], feature_group[, "intensity"], base.curve[, "base.curve"], all_diff_mean_rts)
rt_peak_shape <- c(median(feature_group[, "mz"]), median(feature_group[, "rt"]), sd(feature_group[, "rt"]), sd(feature_group[, "rt"]), eic_area)
peak_parameters <- rbind(peak_parameters, rt_peak_shape)
}
if (num_features < 2) {
time_weights <- all_diff_mean_rts[which(base.curve[, "base.curve"] %in% feature_group[2])]
rt_peak_shape <- c(feature_group[1], feature_group[2], NA, NA, feature_group[3] * time_weights)
peak_parameters <- rbind(peak_parameters, rt_peak_shape)
}
# application of selected model and method
if (num_features > 10) {
# find bandwidth for these particular range
rt_range <- range(feature_group[, "rt"])
bw <- min(max(bandwidth * (max(rt_range) - min(rt_range)), min_bandwidth), max_bandwidth)
bw <- seq(bw, 2 * bw, length.out = 3)
if (bw[1] > 1.5 * min_bandwidth) {
bw <- c(max(min_bandwidth, bw[1] / 2), bw)
}
rt_profile <- compute_chromatographic_profile(feature_group, base.curve)
if (shape_model == "Gaussian") {
rt_peak_shape <- compute_gaussian_peak_shape(rt_profile, bw, component_eliminate, BIC_factor, aver_diff)
} else {

hechth commented

The section handling this cases should simply be removed and the case for more than 10 features should simply become an else.