Skip to content

Commit f831151

Browse files
committed
add fraction matching based on only the light / na labels
1 parent a780511 commit f831151

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

R/utils_fractions.R

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@
265265
#' @keywords internal
266266
.removeOverlappingFeatures = function(input) {
267267
fraction_keep = Fraction = NULL
268-
268+
269269
if (data.table::uniqueN(input$Fraction) > 1) {
270-
input[, fraction_keep := .getCorrectFraction(.SD),
271-
by = "feature",
272-
.SDcols = c("feature", "Fraction", "Run", "Intensity")]
270+
input[, fraction_keep := .getCorrectFraction(.SD),
271+
by = "feature",
272+
.SDcols = c("feature", "Fraction", "Run", "Intensity", "IsotopeLabelType")]
273273
input = input[Fraction == fraction_keep]
274274
input = input[, !(colnames(input) == "fraction_keep"), with = FALSE]
275275
}
@@ -284,9 +284,19 @@
284284
#' highest mean intensity for a given feature
285285
#' @keywords internal
286286
.getCorrectFraction = function(input) {
287-
Intensity = Run = Fraction = NULL
288-
289-
measurement_count = input[!is.na(Intensity) & Intensity > 0,
287+
Intensity = Run = Fraction = IsotopeLabelType = NULL
288+
289+
# For protein turnover: select fraction based on non-heavy peptide intensity
290+
# only. Heavy peptides inherit the same fraction via the shared feature key.
291+
# NA IsotopeLabelType represents peptides whose sequence cannot carry the
292+
# label; these are treated the same as light for fraction selection purposes.
293+
non_heavy_rows = input[(IsotopeLabelType == "L" | is.na(IsotopeLabelType)) &
294+
!is.na(Intensity) & Intensity > 0]
295+
if (nrow(non_heavy_rows) > 0) {
296+
input = non_heavy_rows
297+
}
298+
299+
measurement_count = input[!is.na(Intensity) & Intensity > 0,
290300
list(n_obs = data.table::uniqueN(Run)),
291301
by = "Fraction"]
292302
which_max_measurements = which(measurement_count$n_obs == max(measurement_count$n_obs))

0 commit comments

Comments
 (0)