From 2b92ec4aab23e9c9f83837bdeff42133e89a2db0 Mon Sep 17 00:00:00 2001 From: Tom Smith Date: Tue, 17 Jan 2023 16:09:25 +0000 Subject: [PATCH] Speeds up silac_psm_seq_int ~100-fold!! --- R/silac_psm_seq_int.R | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/R/silac_psm_seq_int.R b/R/silac_psm_seq_int.R index 2cf6fe1..6ff68c0 100644 --- a/R/silac_psm_seq_int.R +++ b/R/silac_psm_seq_int.R @@ -47,7 +47,6 @@ silac_psm_seq_int <- function( obj <- obj %>% filter(.data$Quan.Channel!='') %>% - rowwise() %>% filter(is.finite(.data$Precursor.Abundance)) obj[[mod_col]] <- remove_silac_modifications( @@ -66,13 +65,10 @@ silac_psm_seq_int <- function( obj_seq <- obj %>% group_by(across(all_of(c(sequence_col, group_cols, mod_col)))) %>% tally() %>% + ungroup() %>% mutate('matched'=TRUE) %>% pivot_wider(names_from="Quan.Channel", - values_from=c("n", "matched")) %>% - mutate(n_Light=replace_na(.data$n_Light, 0), - n_Heavy=replace_na(.data$n_Heavy, 0), - matched_Light=replace_na(.data$matched_Light, FALSE), - matched_Heavy=replace_na(.data$matched_Heavy, FALSE)) + values_from=c("n", "matched")) # Depending on which SILAC modifications in Quan.Channel column, # the output columns need to be updated