-
Notifications
You must be signed in to change notification settings - Fork 1
/
annotate_nterm.R
43 lines (31 loc) · 1.72 KB
/
annotate_nterm.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# function for annotation of N-terminal modifications
annotate_nterm <- function(peptidestsv, # peptide.tsv table
tmtmass = 304.2072, # either 304.2072 for 16plex or 229.1629 for 10/11plex
protease_specificity = "R|K") # or R for argc
{
require(dplyr)
require(stringr)
if (tmtmass == 304.2072){
nterm_tmt <- "N-term\\(304.2072\\)"
ktmt <- "K\\(304.2072\\)"
} else if (tmtmass == 229.1629){
nterm_tmt <- "N-term\\(229.1629\\)"
ktmt <- "K\\(229.1629\\)"
} else {
error("Please check your tmtmass argument input.")
}
nterm_annotated <- peptidestsv %>%
mutate(nterm = case_when(str_detect(assigned_modifications, nterm_tmt) ~ "TMT-labelled",
str_detect(assigned_modifications, "N-term\\(42.0106\\)") ~ "acetylated",
TRUE ~ "free")) %>%
mutate(tmt_tag = case_when(str_detect(assigned_modifications, nterm_tmt) ~ "nterm",
str_detect(assigned_modifications, ktmt) ~ "lysine",
str_detect(assigned_modifications, ktmt,
negate = TRUE) & str_detect(assigned_modifications, "N-term\\(42.0106\\)") ~ "untagged_acetylated",
str_detect(assigned_modifications, ktmt,
negate = TRUE) & nterm == "acetylated" ~ "untagged_acetylated",
str_detect(assigned_modifications, ktmt,
negate = TRUE) & nterm == "free" ~ "untagged_free",
TRUE ~ "untagged"))
return(nterm_annotated)
}