Pages

Saturday, December 27, 2014

FDA Adverse effect mining part 2

In the last 1st part of the blog we have shown how to use FDA data to visualize adverse events for a particular drug and how to use brandnames and ATC group class and visualize it using rCharts pyramid plots.  This section of the blog discusses about how to calculate the some useful statistics of the data and compare the side effects of two same class or off class drugs.  In the last section we didn't consider the outcome tables which indicates patient outcomes like hospitalization, death etc. The codes in the outcomes table are given as two letter codes and information about it can be found on the documentation of the data.  The codes are given in git. For this part we will use run.R , riskratio.R and function.R codes .
function.R has functions to get all the brandnames of a query drug and collects all the adverse events for particular drug. It also has get.Vis() function to plot pyramid plots by two letter outcome. If outcomes are not specified then it used all the data and plots it. 
run.R is used to execute those functions with the data which is given below.  The plots are also shown below.
 d1<-get.Names("Lipitor")  
 d2<-get.Names("Crestor")  
 d1se<-get.SideEffects(d1,"Lipitor")  
 d2se<-get.SideEffects(d2,"Crestor")  
 get.Vis(d1se,d2se,75,col=c("blue","red"))
 get.Vis(d1se,d2se,75,col=c("blue","red"),out=c("OT","HO"))


I am interested in comparing two standard techniques, namely Reporting odds ratio (ROR) and proportional reporting ratio (PRR) on two different datasets. Both methods use the values according to a 2x2  contingency table,

Drug of Interest Other drug
Event of Interest a b
other event c d

Reporting odds ratio equation is given below. The value (a/b) is the number of patients who had the event of interest and have taken the drug of interest (a) divided by the number of patients who had the event when taking any other drug (b). The value (c/d) is the number of patients who have taken the drug of interest but did not have the event of interest (c), divided by the number of people who had any other events, given that they took any other drug (d).

                                              


 The PRR on the other hand can be calculated as follows: 

                                           

 where a/(a + c)  can be thought of as the probability of an event of interest occurring, given the drug of interest was taken and an event occurred whereas , b/( b+ d) can be thought of as the probability that the event of interest occurred, given any other drug was taken and an event occurred.
 
# Comparing the Risk adverse effect for two types of drugs
# Get the reactions of Crestor which matches Lipitor
d<-d2se[which(d1se$reaction %in% d2se$reaction ),]
n<-d[complete.cases(d),]

# Aggregat all the data without considering the outcomes
crestor<-aggregate(count ~ reaction ,data=n, FUN=sum)
#head(dt[order(dt$count, decreasing = T), ])

# Get the reactions of Lipitor which matches Crestor from the above dataframe
t<-d1se[which(d$reaction %in% d1se$reaction),]
lipitor<-aggregate(count ~ reaction ,data=t, FUN=sum)

# compare crestor against Lipitor 
r1.prr<-prr(crestor,lipitor)
r1.ror<-ror(crestor,lipitor)


reaction ror
158 Renal failure 12.50
21 Blood cholesterol increased 7.32
25 Blood triglycerides increased 6.06
70 Fibromyalgia 5.78
75 Gastrooesophageal reflux disease 5.78
39 Chronic obstructive pulmonary disease 5.37
37 Chest discomfort 4.95
117 Migraine 4.95
147 Pancreatitis acute 4.95
170 Type 2 diabetes mellitus 4.54


reaction ror
158 Renal failure 12.50
21 Blood cholesterol increased 7.32
25 Blood triglycerides increased 6.06
70 Fibromyalgia 5.78
75 Gastrooesophageal reflux disease 5.78
39 Chronic obstructive pulmonary disease 5.37
37 Chest discomfort 4.95
117 Migraine 4.95
147 Pancreatitis acute 4.95
170 Type 2 diabetes mellitus 4.54

When crestor is compared to lipitor the prr and ror indicates that chances of Renal Failure , Increased Blood cholesterol, Fibromyaglia is more than lipitor, whereas when one takes lipitor there are more chances of abdominal discomfort, Rash, Muscle atrophy and so on.

Table below shows the prr of lipitor against crestor and its adverse reactions .

reaction prr
2 Abdominal discomfort 17.02
156 Rash 9.12
121 Muscle atrophy 6.68
63 Dyspepsia 6.38
19 Balance disorder 6.28
3 Abdominal pain 6.08
27 Bradycardia 4.86
80 Haematoma 4.86
114 Lung disorder 4.86
79 Gout 4.56

Thursday, December 18, 2014

Adverse Effect mining of FDA data Part 1

.
US Food and Drug Administration (FDA) Adverse Event Reporting System (FAERS, formerly AERS) is a database that contains information on adverse event and medication error reports submitted to the FDA. The database is designed to support the FDA's post-marketing safety surveillance program for drug and therapeutic biologic products. In this issue of my blog i have used 2012 quarter 4 data to visualize adverse reactions and also compare the adverse reactions for a group of drugs (group means by ATC code). There are some very important point to note the data is submitted from countries which mean a drug can have different names (brandnames) . So you can search as "Aspirin" on the database you need to search by all the alternate brandnames of Aspirin on the database. For that I have created a brandname based dataset of all the drugbank data which i will use for this example.

For this datasets used :
  • ATC drug group class data
  • Drug Brandnames data
  • 2012 FDA quarter 4 dataset.
R packages used
  • foreach
  • doParallel
  • rCharts(for visualization)
I used foreach with parallel because it takes a lot of time to query the data frames on a single processor making it parallel reduces a lot of timing. I am using rCharts NVD3 library for the interactive pyramid plots developed by Ramnath Vaidyanathan .  The codes for the work is avaialable at here. To simplify things I made a simple query "Aspirin" on the drug dataframe and used grepl with ignore case and drug_seq=1 ( which indicates primary medication) on lines 51-63(Initial.R script)  since aspirin is categorized  under 3 different classes such as Blood and blood forming organs ,Alimentary tract and metabolism and Nervous system , so i extracted all the drugs from each category and extracted the data from drug dataframe for each drugs and merged the results and visualized it as Interactive pyramid plots below.  I have some further ideas on this calculating some statistics based on class and also further categorizing using Mesh Class creating a Shiny app.

If you want the brandnames data with the ATC code classes leave a comment below with your email id or you can shoot an email.

Class Blood and blood forming organs ( Access the full charts at http://abhik1368.github.io/plots/classB.html)


Class Nervous System ( http://abhik1368.github.io/plots/classN.html)


Class Alimentary tract and metabolism (http://abhik1368.github.io/plots/classA.html)