Filter a similarity matrix
1
0
Entering edit mode
10.1 years ago

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

sequence • 1.9k views
ADD COMMENT
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode
10.1 years ago

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
ADD COMMENT

Login before adding your answer.

Traffic: 1873 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6