Pages

Showing posts with label R. Show all posts
Showing posts with label R. Show all posts

Wednesday, February 25, 2015

Link Prediction using Network based Inference - A quick matrix based implementation

I explored a paper proposed by Zhou etal used Network based Inference(NBI) method to predict missing links in bipartite network and was thinking a lot how to implement using some simple matrix ways. I have taken the pic below from Zhou paper above  to explain the idea .Given the bipartite graph , a two phase resource transfer Information from  X(x,y,z) set of nodes gets distributed to Y set of nodes and then again goes back to resource X .  This process allows us to define a technique for the calculation of the weight matrix W.  In 2010 a modified version of this approach is proposed in Solving the apparent diversity-accuracy dilemma of recommender systems which used a modified Hybrid algorithm in which the functions defined in NBI and HeatS are combined in connection with a parameter called λ.


In this post i am going to implement the algorithm how does this work using simple matrix method in R. Interested readers must see those publications for the mathematical equations explained. Before going a bit further , if we are given a weight matrix W( which is calculated using the algorithms above) and the adjacency matrix A of the bipartite network, it is possible to compute the recommendation matrix R using the equation below, where W is n x n matrix and A is n x m matrix .

                                                                               R = W.A      (1)

The R list is then sorted in a descending order with respect to the score.

We use this kind of calculations in chemo-genomics predictions and also other bipartite type data. When doing Drug target prediction we can use W is as the sequence similarity matrix and A as the Drug target adjacency matrix to obtain recommendation of targets based on sequence similarity . Similarity W can be a compound similarity matrix and A the bipartite compound target matrix. Now we can use equation (1) above to get recommendations of compounds given a sequence of interest. This trick of using matrix just blowed my mind off !! Isn't it cool ?

Now for the functions here it goes below. If you are using the codes do let me know the results how does it work. My next post would be integrating similarity matrices information along with the degree information into W.







Sunday, January 11, 2015

Tuberculosis and the Global Clinical Study Map using Clinical Trials data from Web .

People around the world through blogs , newsletters and other forms of media showing how deadly diseases like TB are spreading and killing people. Between last 2-3 years lot of people have come up with ideas like open source development in drugs , lot of consortium have been formed to move with the research. With a bit of data mining on the clinical trial data we can easily see whats going on with the drug discovery arena . Using some r libraries we can easily access the clinical trial data from clinicaltrail.gov website and parse the xml files . I searched for "tuberculosis" with the start date and 1/1/2013 and end date 12/31/2014 and the trials with a "closed" status including all the age groups. After looking at this map I would ask the Indian Health ministry, Is India waiting for the west to develop its drugs or it does want the people to die of this lethal disease ? Only 3 clinical trails are being done but none of them are Phase I-IV trails for new drugs. Is the scientific community just abandon their hands on this ? In USA two medical centers(Lincoln and cleveland) already seem to be working on the new drugs, one is bedaquiline (NCT02216331) and other SQ109(NCT01874314). I didn't look on European centers and Africa. The code for this available @ git . I used rMaps library with Leaflet.js library. One can play with any disease and with different start and end date and with trial status. The Map below (2013-14) is iframe embedded on html which is done using the command using rMaps package -

map$show('iframesrc',cdn=TRUE)

I found some issues with with the geocode function from the ggmap package takes a lot of time to access the google api for latitude and longitude . If anyone has a faster way to get those let me know.

The first maps shows the clinical trials from 2009-2014 which designates a lot of Trials being done on TB in India . But from 2013-14 no further interest was made on TB .    


Map from 2013 -14