-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculate_AcetylEnrichment_based_on_MQevidence.R
executable file
·48 lines (32 loc) · 1.62 KB
/
Calculate_AcetylEnrichment_based_on_MQevidence.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
44
45
46
47
48
# calculate enrichment based on evidence.txt
# read in evidence.txt file
# you can use choose.files()
evidence_file <- "C:\\RAWFILES\\Master\\combined\\txt\\evidence.txt"
evidence <- read.delim(file=evidence_file,sep="\t", header=TRUE,stringsAsFactors=FALSE)
# get rid of CONs, and reverse
evidence <- evidence[!evidence$Reverse=="+",]
evidence <- evidence[!evidence$Potential.contaminant=="+",]
evidence <- evidence[!grepl(evidence$Proteins, pattern="iRT"),]
# get overview of raw files in evidence.txt
table(evidence$Raw.file)
length(table(evidence$Raw.file))
# only keep acetylome raw-files (only relevant when searched together with proteome files)
bool_acetylom <- grepl(evidence$Raw.file, pattern="acet")
evidence <- evidence[bool_acetylom,]
evidence$Modifications
# calculate enrichment
enrichment<- numeric(length(unique(evidence$Raw.file))) # initialize
names(enrichment) <- unique(evidence$Raw.file)
number_acetyl_evidences <- numeric(length(unique(evidence$Raw.file)))
names(number_acetyl_evidences) <- unique(evidence$Raw.file)
for (i in 1:length(enrichment)){
rawfile_i <- unique(evidence$Raw.file)[i]
evidence_i <- evidence[evidence$Raw.file == rawfile_i,]
modifications_i <- evidence_i$Modifications
bool_acetylated_i<- grepl(modifications_i, pattern="Acetyl [(]K[)]") #check if this pattern matches how acetyl-k peptides are written in the evidence.txt!
enrichment_i <- sum(bool_acetylated_i)/length(bool_acetylated_i)
number_acetyl_evidences[i] <- sum(bool_acetylated_i)
enrichment[i]<- enrichment_i*100
}
number_acetyl_evidences
enrichment