|
265 | 265 | #' @keywords internal |
266 | 266 | .removeOverlappingFeatures = function(input) { |
267 | 267 | fraction_keep = Fraction = NULL |
268 | | - |
| 268 | + |
269 | 269 | 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")] |
273 | 273 | input = input[Fraction == fraction_keep] |
274 | 274 | input = input[, !(colnames(input) == "fraction_keep"), with = FALSE] |
275 | 275 | } |
|
284 | 284 | #' highest mean intensity for a given feature |
285 | 285 | #' @keywords internal |
286 | 286 | .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, |
290 | 300 | list(n_obs = data.table::uniqueN(Run)), |
291 | 301 | by = "Fraction"] |
292 | 302 | which_max_measurements = which(measurement_count$n_obs == max(measurement_count$n_obs)) |
|
0 commit comments