<p>I don't know any python (or R package) to do this), but this is how I would do it based on these matrices:</p>

<ol>
<li>Do a multidimensional scaling (MDS) plot of the target_similarity matrix.  Explore the visualization: </li>
<li>Find which drug targets the drug closest to the 0,0 point in the 2D space</li>
</ol>

<p>However this doesn't say anything about the affinity between the drug and the target.
If you wanted to add this then you could weight how much close is the distance between the drug and the target vs how close are they to the center of the MDS (a simple division could work if the distance is scaled between 0 and 1 and averaged).</p>

<p>Note that depending on the original information used to calculate the similarities and the affinities it could be done in other ways</p>

CC BY-SA 4.0
2019-01-13T08:46:43.430Z
I like the MDS idea even though I don't fully understand the 2nd part. 
I can do a MDS on target similarities and another one on drug similarities.
Then create a di-graph like [here](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3605000/figure/F1/), part C. Drugs and targets will be connected through edges based on their affinity scores. An affinity threshold will define which drug is connected to which target, and an assigned weight will give the affinity score.
BND
CC BY-SA 4.0
2019-01-13T09:06:27.280Z
No, I didn't say anything about a MDS on drugs similarities. The center of the MDS of the targets is the closest point to all the targets. That's why you need to find the drug that aims to the target closer to the center of the MDS.
llrs
CC BY-SA 4.0
2019-01-11T14:44:23.913Z
2019-01-11T14:44:23.913Z
llrs
<p>I have 4 pandas data frames containing the following data:</p>

<ol>
<li>affinity_score1: affinity between each couple (Drug-Target) measured using  tool1</li>
<li>affinity_score2: affinity between each couple (Drug-Target) measured using tool2 </li>
</ol>

<p>The two tools (tool1, tool2) give measure in different scales and are not 100% accurate.</p>

<ol start="3">
<li>Drug_similarity: a similarity matrix between drugs</li>
<li>Target_similarity: a similarity matrix between targets.</li>
</ol>

<p>Here also the tool used to measure the similarity is not 100% accurate.</p>

<pre><code>import pandas as pd

affinity_score1 = [{'Drug0': -24.5, 'Drug1': -17.1, 'Drug2': -13.1},
           {'Drug0': -20.0, 'Drug1': -21.6, 'Drug2': -18.1},
           {'Drug0': -19.0, 'Drug1': -15.4, 'Drug2': -20.0}]

affinity_score2 = [{'Drug0': 1.5, 'Drug1': 0.8, 'Drug2': 0.4},
           {'Drug0': 1.2, 'Drug1': 1.3, 'Drug2': 0.9},
           {'Drug0': 0.8, 'Drug1': 0.7, 'Drug2': 0.9}]
affinity_score1_df = pd.DataFrame(affinity_score1).rename(index={0:'TargetX',1:'TargetY', 2:'TargetZ'})
affinity_score2_df = pd.DataFrame(affinity_score2).rename(index={0:'TargetX',1:'TargetY', 2:'TargetZ'})
Drug_similarity = [{'Drug0': 1, 'Drug1': 0.8, 'Drug2': 0.2},
           {'Drug0': 0.8, 'Drug1': 1, 'Drug2': 0.9},
           {'Drug0': 0.2, 'Drug1': 0.9, 'Drug2': 1}]
Target_similarity = [{'TargetX': 1, 'TargetY': 0.8, 'TargetZ': 0.2},
           {'TargetX': 0.8, 'TargetY': 1, 'TargetZ': 0.9},
           {'TargetX': 0.2, 'TargetY': 0.9, 'TargetZ': 1}]
Drug_similarity = pd.DataFrame(Drug_similarity).rename(index={0:'Drug0',1:'Drug1', 2:'Drug2'})
Target_similarity = pd.DataFrame(Target_similarity).rename(index={0:'TargetX',1:'TargetY', 2:'TargetZ'})
</code></pre>

<p><strong>I am trying to find the Drug who can have as many Targets as possible.</strong></p>

<p>So far, a simple approach could be to select the Drug having the highest average score in both affinity scoring tools.</p>

<p>This approach does not use the information in the similarity matrices. 
Given that if a Drug1 is successful with TargetX, and TargetX is similar to  TargetY then Drug1 can also easily be successful with TargetY. Considering the inaccuracy of the scoring tools, I think including this information could improve the accuracy of the answer, eliminating some false positives. 
Also, if a Drug from a cluster of similar drugs (information that can be derived from the drugs similarity matrix) is the only one predicted to have good affinities with some targets, then this is more likely to be a false positive. 
But I don't know how to efficiently integrate all the information. Scipy may help with clustering the two similarity matrices.</p>

<p>Another way of analysis is to set affinity and similarity thresholds, in which case each data frame could be transformed into a network:</p>

<ul>
<li>Each node is a drug or a target.</li>
<li>Two types of edges: similarity (between drugs or targets) and affinity (drug-target)</li>
<li>The connected nodes have passed the thresholds. </li>
<li>The edges have weights: affinity or similarity score. </li>
</ul>

<p>The problem then becomes finding the most connected node (a drug node) with the highest weight values (scores on tool1 and tool2). Connected nodes through similarity may then be used to validate the number of targets for each drug. 
It seems a more complicated approach but more rigorous with most likely higher positive predictive value.</p>

<p>Any python package to implement such an approach?
And also a visualization tool.</p>

<p>The original data has 38 Targets with 806 drugs.</p>

<python><drugs>
Drug with as many targets as possible through a system biology graph?
# Drug with as many targets as possible through a system biology graph?

(Asked by: username_0 on 2019-01-11)

I have 4 pandas data frames containing the following data:

affinity_score1: affinity between each couple (Drug-Target) measured using  tool1
affinity_score2: affinity between each couple (Drug-Target) measured using tool2 

The two tools (tool1, tool2) give measure in different scales and are not 100% accurate.

Drug_similarity: a similarity matrix between drugs
Target_similarity: a similarity matrix between targets.

Here also the tool used to measure the similarity is not 100% accurate.
import pandas as pd

affinity_score1 = [{'Drug0': -24.5, 'Drug1': -17.1, 'Drug2': -13.1},
           {'Drug0': -20.0, 'Drug1': -21.6, 'Drug2': -18.1},
           {'Drug0': -19.0, 'Drug1': -15.4, 'Drug2': -20.0}]

affinity_score2 = [{'Drug0': 1.5, 'Drug1': 0.8, 'Drug2': 0.4},
           {'Drug0': 1.2, 'Drug1': 1.3, 'Drug2': 0.9},
           {'Drug0': 0.8, 'Drug1': 0.7, 'Drug2': 0.9}]
affinity_score1_df = pd.DataFrame(affinity_score1).rename(index={0:'TargetX',1:'TargetY', 2:'TargetZ'})
affinity_score2_df = pd.DataFrame(affinity_score2).rename(index={0:'TargetX',1:'TargetY', 2:'TargetZ'})
Drug_similarity = [{'Drug0': 1, 'Drug1': 0.8, 'Drug2': 0.2},
           {'Drug0': 0.8, 'Drug1': 1, 'Drug2': 0.9},
           {'Drug0': 0.2, 'Drug1': 0.9, 'Drug2': 1}]
Target_similarity = [{'TargetX': 1, 'TargetY': 0.8, 'TargetZ': 0.2},
           {'TargetX': 0.8, 'TargetY': 1, 'TargetZ': 0.9},
           {'TargetX': 0.2, 'TargetY': 0.9, 'TargetZ': 1}]
Drug_similarity = pd.DataFrame(Drug_similarity).rename(index={0:'Drug0',1:'Drug1', 2:'Drug2'})
Target_similarity = pd.DataFrame(Target_similarity).rename(index={0:'TargetX',1:'TargetY', 2:'TargetZ'})

I am trying to find the Drug who can have as many Targets as possible.
So far, a simple approach could be to select the Drug having the highest average score in both affinity scoring tools.
This approach does not use the information in the similarity matrices. 
Given that if a Drug1 is successful with TargetX, and TargetX is similar to  TargetY then Drug1 can also easily be successful with TargetY. Considering the inaccuracy of the scoring tools, I think including this information could improve the accuracy of the answer, eliminating some false positives. 
Also, if a Drug from a cluster of similar drugs (information that can be derived from the drugs similarity matrix) is the only one predicted to have good affinities with some targets, then this is more likely to be a false positive. 
But I don't know how to efficiently integrate all the information. Scipy may help with clustering the two similarity matrices.
Another way of analysis is to set affinity and similarity thresholds, in which case each data frame could be transformed into a network:

Each node is a drug or a target.
Two types of edges: similarity (between drugs or targets) and affinity (drug-target)
The connected nodes have passed the thresholds. 
The edges have weights: affinity or similarity score. 

The problem then becomes finding the most connected node (a drug node) with the highest weight values (scores on tool1 and tool2). Connected nodes through similarity may then be used to validate the number of targets for each drug. 
It seems a more complicated approach but more rigorous with most likely higher positive predictive value.
Any python package to implement such an approach?
And also a visualization tool.
The original data has 38 Targets with 806 drugs.

**Tags:** python, drugs

---

## 1 answers

### Answer by username_1 on 2019-01-11. Score: 2

I don't know any python (or R package) to do this), but this is how I would do it based on these matrices:

1. Do a multidimensional scaling (MDS) plot of the target\_similarity matrix. Explore the visualization:
2. Find which drug targets the drug closest to the 0,0 point in the 2D space

However this doesn't say anything about the affinity between the drug and the target.
If you wanted to add this then you could weight how much close is the distance between the drug and the target vs how close are they to the center of the MDS (a simple division could work if the distance is scaled between 0 and 1 and averaged).

Note that depending on the original information used to calculate the similarities and the affinities it could be done in other ways

> **Comments:**
> **username_0**: I like the MDS idea even though I don't fully understand the 2nd part.  I can do a MDS on target similarities and another one on drug similarities. Then create a di-graph like [here](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3605000/figure/F1/), part C. Drugs and targets will be connected through edges based on their affinity scores. An affinity threshold will define which drug is connected to which target, and an assigned weight will give the affinity score.  
> **username_1**: No, I didn't say anything about a MDS on drugs similarities. The center of the MDS of the targets is the closest point to all the targets. That's why you need to find the drug that aims to the target closer to the center of the MDS.  

---

