RxClass Tutorial

Similar Classes in RxClass


The RxClass application and the RxClass API offer functionality which allows users to retrieve similar classes relative to the selected or specified class. Similar classes are defined here as classes which have shared drug members with the drug members of the selected class.

In RxClass, the user can view the similar classes by selecting the similar classes link above the class drug table.

Similar classes link

When the similar classes link is selected, a popup menu is displayed with the similar classes. The class information along with the equivalence score is displayed for each similar class. The color bar can contain up to three distinct colors denoting the percentage of drugs in class 1 only, class 2 only and in both classes.

Similar classes popup list

Selecting the Venn link will display the Venn diagram between the two classes, along with the similarity table, which is a summary of clinically significant drugs contained in each of the two classes.

Similarity Table

Similarity Class Drug Members

The similarity algorithm uses only clinically significant RxNorm ingredients for each drug class to determine the similarity between the classes. The following rules apply to determine the similar class drug membership:
  • All precise ingredients (TTY=PIN) are converted to RxNorm ingredients (TTY=IN)
  • Multiple ingredients (TTY=MIN) are eliminated.
  • Only clinically significant ingredients are selected. A clinically significant ingredient is defined by:
    • The ingredient is listed in RxNorm as prescribable.
    • One or more RxNorm clinical drugs (TTY=SCD) contain the ingredient.
For example, the ATC class Barbiturates and derivatives (N03AA) contains five members: barbexaclone, Mephobarbital, metharbital, Phenobarbital and Primidone. But barbexaclone is not clinically significant because there are no clinical drugs containing it in RxNorm, so it is eliminated from the drug membership for similar class comparisons.

Similarity Scoring

The RxClass API similarity functions offer three ways to select similar classes based on the equivalence and inclusion scores. Equivalence scores are the default and the most commonly used and easiest to understand. Equivalence and inclusion scores are described below and in detail in the JBMS paper.

Equivalence Score
Many drug classes only contain a small number of drugs, and a small number of shared drugs between classes can yield relatively high Jaccard values. In order to reduce the similarity of pairs of classes with small numbers of shared drugs, we use a modified version of the Jaccard which we call the equivalence score.

Equivalence score formula
where am represents the number of drugs common to A and M, and a + m + am the total number of unique drugs in both classes.


Class 1: Barbiturates and derivatives (N02AA)
members:  Mephobarbital, metharbital, Phenobarbital, Primidone

Class 2: Phenobarbital (N0000005893) in NDFRT (has_ingredient)
members: Phenobarbital, Primidone

# common drugs: 2 (Phenobarbital, Primidone)
# unique drugs: 4 (Mephobarbital, metharbital, Phenobarbital, Primidone)

Equivalence score: 
   2.4 /4 = 0.39

Inclusion Score
The equivalence score measures the similarity between the two classes, but does not reflect whether one class is included in the other. The inclusion score is a metric for finding specific classes that are included in broader classes. This metric combines two elements. The first one measures the intensity of the “one-sidedness”, i.e., the extent to which the instances outside the intersection are not distributed between both sides, but rather belong to only one of the two classes. The second element measures the coverage of the specific class by the broader class. The inclusion score is calculated by:

Inclusion score formula
where am represents the number of drugs common to A and M, and a and m the number of drugs specific to A and M, respectively.
For example, if A contains 10 drugs and M contains 20 drugs and if the two classes share 9 drugs, IS(A,M) = -0.75, providing a strong indication that A is included in M.

In summary, a negative inclusion score indicates that A is included in M, while a positive score indicates that M is included in A. A score of 0 indicates neither set is more included. In the RxClass API, the user can return similar drug classes for either negative inclusion scores (included_in) or positive inclusion scores (includes).

RxClass API Similarity Functions

The RxClass API offers three methods relating to similar classes:
  • /similar - finds the similar classes to the specified class. The results returned are equivalent to selecting the similar classes link in RxClass.
  • /similarByRxcuis - find the similar classes from a list of RxNorm drug identifiers. This method allows users to specify a list of RxCUIs and finds the similar classes to that list.
  • /similarInfo - return the similarity information for two classes. This method returns the similarity information (scores, drug members of each class) that is viewed when a user in RxClass selects the Venn link in the similar class selection menu.