thanks ATpoint, by using your suggestion, I got very good result. Thank you. here's my code for my counting :
peptide_count <- lapply(peptides, function(x) {#peptides, a list of peptides
peptide=x
length(unique(c(ranges(matchPattern(peptide, AAString(prot_seq))), #prot_seq : protein sequence to search on
ranges(matchPattern(reverse(peptide), AAString(prot_seq))))
)
)
})
some additional functions are added to make +/- peptide (like "RY" and "YR") as the same thing. because in this study, reverse peptide is no different to original peptide.
In stringr, str_count("RY|YR","RYYRRYRY") can do it. But matchPattern somehow can't, so sorry, I make my code complex .....
It is not very clear what is your problem and what you want to achieve.
Is the result of
str_countcorrect to you ? Or do you wantstr_count("AAA","AA")to result as 2 countsWhat kind of score do you want to apply ? Could you share an example ?
thanks Bastien, sorry my question was unclear. I want
str_count("AAA","AA")to result as 2 counts. for instance, "AAAAAA" will give 5 counts and "AARAAGAAN" gives us 3 counts. This counting strategy will give continuous peptide (like "AAAAAA") more counts.See ATpoint 's answer for the count part. And for the score, if you want to play it dirty you can divide the number of count by the peptide length or create your own score strategy using the start and end position in the result of
matchPattern. Like increase the score tilldf[end] < df[start+1]+1, or something similarthis is an advice from a real expert! YES, a scoring strategy, this is what i want to do after all exploratory analysis
Hi boaty,
If an answer was helpful you should upvote it, if the answer resolved your question you should mark it as accepted.
Thanks!
sorry for it. it's done now