R: Comparing dissimilarity between metabolic models with discrete wavelet transformation


I’m working on comparing bacteria metabolic models. Each model has a set of metabolites (around 2000) and their concentration for 200 time points. I’m in the process of comparing the models to cluster them based on their similarity. One method I followed is I did a pair wise comparison for each of the metabolite pairs in two models using Euclidean distance. Below is how my data look like. This is a sample data file.

enter image description here

I computed pair wise Euclidean distance for Met1 from Model A and Met1 from Model B. Likewise computed the distances for all the common metabolites between the 2 models (Met4 in Model A and Met4 in Model B) and summed up the distances to get a distance (dissimilarity) between the two models. Similarly I computed the dissimilarity matrix for all the models and I used hierarchical clustering to cluster them.

As mentioned above, now I want to compute the dissimilarity of the models using Discrete Wavelet Transformation as my distance measure. I would like to know how to use Discrete Wavelet Transformation to compute a dissimilarity distance between 2 time series and hence for my models.

Previously I used DWT as a distance measure with DBSCAN for clustering metabolites in one model according to their behavior. It worked fine.


Posted 2015-08-04T10:48:20.727

Reputation: 113



Take a look at the TSclust package. Here how you would apply it to your sample data.


#read in the data
model_a <- read.csv("~/Desktop/Model A.csv", header = TRUE, stringsAsFactors = FALSE)
model_b <- read.csv("~/Desktop/Model B.csv", header = TRUE, stringsAsFactors = FALSE)

#data must be in rows rather than columns
model_a <- as.data.frame(t(model_a))

model_b <- as.data.frame(t(model_b))

#calculate dissimlarities between metabolites in models 1 and 2
met1_DWT.diss <- as.numeric(diss.DWT(rbind(model_a['Met1', ], model_b['Met1', ])))
[1] 90.80332

met2_DWT.diss <- as.numeric(diss.DWT(rbind(model_a['Met2', ], model_b['Met2', ])))
[1] 1.499241


Posted 2015-08-04T10:48:20.727

Reputation: 206

Thank you very much for the answer. I implemented this with 2 methods WavDistance and diss.DWT but I got different values (I assume both these methods does the same thong where diss.DWT in TSclust is a wrapper for waveDistance in TSDist). The issue was my data was in columns. Once I took the transpose it was fine. Sorry about the delayed reply. – SriniShine – 2015-08-10T01:23:55.903