Search
Question: Splitting a fasta file based on specific Amino acid for plotting
0
2.1 years ago by
Assa Yeroslaviz1.4k
Munich, Germany
Assa Yeroslaviz1.4k wrote:

Hi all after a few days of searching and trial & error I would like to ask for your help.

I have a protein sequence, let's say this one (one line):

>protein1
VSGERKTQKAASNGTQIRSKLKRTKQTATKTKTLQGPAEKKPPSGSQAPRTKQRVTKWQ

I would like to split the protein after each occurrence of a specific AA, let's say "K" ( the cleavage point of trypsin) so that I will get a list or an IRanges object with the start and end positions) with these elements:

MK
TGQMMDESDEDFK
ELCASFFQRVK
...
​PPSGSQAPRTK
QRVTK
WQ...

Using IRanges and matchPattern(), I was only able to create an object of the pattern I'm looking for, but not of the sub-sequence.

Than I would like to plot these subsequences onto the complete sequence of the protein

The end goal of my analysis is to plot the protein sequence (x-axis) against all cleavage patterns (Y-axis)

which should then looks like the attached image

the bottom line represents the protein, each of rows above stands for one specific peptide. The Idea is to calculate which protease or combination of proteases gives the highest coverage of the protein in question.

I would really like to know if there are any packages out there dealing with this kind of questions/problems as I have not found any.

Hope I have made myself clear enough and of course for any help I can get. Thanks a lot in advance

Assa

modified 2.1 years ago by Michael Lawrence10k • written 2.1 years ago by Assa Yeroslaviz1.4k
0
2.1 years ago by
United States
Michael Lawrence10k wrote:

matchPattern() returns a Views object, which is the combination of the underlying sequence and the matching ranges. We need to convert the ranges so that the sequence is partitioned, where the position of the match is the end of each partition.

library(Biostrings)
hits <- matchPattern("K", protein1)
subseqs <- PartitioningByEnd(end(hits))

As for visualizing it, I don't have any good solutions. I tried using ggbio and Gviz but both are pretty disappointing.

thanks for the response. That works very nicely. I do have though a follow-up question.

Is it possible to use multiple pattern in this case?

I have tried this code, but I get NONE as a result:

>toMatch <-c("K", "R")
>hits <- matchPattern(pattern=paste(toMatch,collapse="|"), protein1)
>hits
Views on a 119-letter AAString subject
views: NONE

I have also tried to convert the two letters into a AAStringSet object, the matchpattern() takes only XString object and not a set.

Is there a different way to do it?

thanks again

Do you want to know where each individual pattern matches, or is there actual ambiguity? It looks like Biostrings does not have a lot of support for matching amino acid strings. For example, neither matchPDict() nor matchPattern(fixed=FALSE) support AAStringSet. I think the latter would be easy to support?

Some protease cleave the sequence after two different AA, in my case these two are "K" and "R". So I basically want to find all the positions where either K or R are and cut there.

Is there a way to also extract the sequences themselves when doing it (for now for one pattern)? I would like to have not only the IRanges object with the positions, but also the sub-sequences if possible.

Getting the subsequences is just:

extractList(protein1, subseqs)