Filter a similarity matrix
Dear all,
I obtained a similarity matrix from a multialignment of about 200 protein sequences. I would like to filter this matrix by only 100% identity because I'd like to identify and discard identical accession from this list of proteins.
Any advice?
Thanks in advance
• 2,303 views
•
link
1 answer
Something like this?
library(data.table)
df = data.frame(p1 = c(1, 0.5, 1), p2= c(0.5, 1, 0.6), p3 = c(1, 0.6, 1))
df1 <- stack(df)
setDT(df1)
df1[, pp := c("p1", "p2", "p3")]
setkey(df1, values)
and the result:
> df1
values ind pp
1: 0.5 p1 p2
2: 0.5 p2 p1
3: 0.6 p2 p3
4: 0.6 p3 p2
5: 1.0 p1 p1
6: 1.0 p1 p3
7: 1.0 p2 p2
8: 1.0 p3 p1
9: 1.0 p3 p3
• 0 views
•
link
Log in to answer this question.
Just use R, python, perl or any other language that you're familiar with. Note that this may be simpler if the matrix is symmetric, though handling a triangular matrix isn't terribly difficult either.