I have 4 pandas data frames containing the following data:

  1. affinity_score1: affinity between each couple (Drug-Target) measured using tool1
  2. 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.

  1. Drug_similarity: a similarity matrix between drugs
  2. 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.


1 Answer 1


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

  • $\begingroup$ 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, 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. $\endgroup$
    – BND
    Commented Jan 13, 2019 at 8:46
  • $\begingroup$ 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. $\endgroup$
    – llrs
    Commented Jan 13, 2019 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.