[R] compute similarity distance

houcemeddine othman houcemeddine.othman at pasteur.rns.tn
Wed Jun 20 16:37:54 CEST 2012


Hi,
I just started to use R for my Phd. I have to write a Formula by witch, given two matrices of vectors (electrostatic potential map) I shall calculate the similarity between them.
Could you please tell me if I'am doing it right. The complecte formula is attached to an image file

the script

#!/usr/bin/env Rscript

options(max.print=2000000)
x<-read.table("a")                                           #reading the matrix 'a'
y<-read.table("b")                                           #reading the matrix 'b'
#----------------------------------
                                                                        # based on Chris et al (2011): The effect of electrostatics on Factor H and related pathologies
c1<-x-y                                                                 # phiA(i,j,k)-phiB(i,j,k)
c<-sqrt(c1$V1^2+c1$V2^2+c1$V3^2)        # |phiA(i,j,k)-phiB(i,j,k)|
a<-sqrt(x$V1^2+x$V2^2+x$V3^2)           #|phiA(i,j,k)|
b<-sqrt(y$V1^2+y$V2^2+y$V3^2)           #|phiB(i,j,k)|
#----------------------------------
esdi<-c/max(a,b)                                        #|phiA(i,j,k)-phiB(i,j,k)|/max(|phiA(i,j,k)|,|phiB(i,j,k)|)
esd<-(1/1391093)*sum(esdi)                      # 1/N E*|phiA(i,j,k)-phiB(i,j,k)|/max(|phiA(i,j,k)|,|phiB(i,j,k)|)
esd


Best wishes
Houcemeddine OTHMAN
Pasteur Institute of Tunis
Venom and biotheurapetical Molecules Lab
-------------- next part --------------
A non-text attachment was scrubbed...
Name: similarity_formula.png
Type: image/png
Size: 7939 bytes
Desc: similarity_formula.png
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120620/e981e71e/attachment.png>


More information about the R-help mailing list