R/PhViD.search.R

`PhViD.search` <-
function(RESULT,DRUG=NULL,EVENT=NULL) {
# fonction permettant de rechercher les résultats pour un médicament, un effet indésirable ou les deux


RESULT$ALLSIGNALS[,1]<-as.character(RESULT$ALLSIGNALS[,1])
RESULT$ALLSIGNALS[,2]<-as.character(RESULT$ALLSIGNALS[,2])
#if (RESULT$COMPARE$RANKSTAT == 2 | RESULT$COMPARE$RANKSTAT == 3)
#  rang <- rank(-RESULT$ALLSIGNALS[,5])
#else rang <- rank(RESULT$ALLSIGNALS[,5])

if (RESULT$INPUT.PARAM$RANKSTAT == 2 | RESULT$INPUT.PARAM$RANKSTAT == 3)
  rang <- rank(-RESULT$ALLSIGNALS[,5])
else rang <- rank(RESULT$ALLSIGNALS[,5])

EXIST_DRUG <- TRUE
EXIST_EVENT <- TRUE
if (is.null(DRUG)==FALSE) EXIST_DRUG <- length(RESULT$ALLSIGNALS[,1][RESULT$ALLSIGNALS[,1]==DRUG])!=0
if (is.null(EVENT)==FALSE) EXIST_EVENT <- length(RESULT$ALLSIGNALS[,2][RESULT$ALLSIGNALS[,2]==EVENT])!=0

#if (EVENT==NULL) RESULT$ALLSIGNALS[,3]<-RESULT$ALLSIGNALS[,3][RESULT$ALLSIGNALS[,1]==DRUG]
#if (DRUG==NULL) RESULT$ALLSIGNALS[,3]<-RESULT$ALLSIGNALS[,3][RESULT$ALLSIGNALS[,2]==EVENT]

if (is.null(EVENT)==FALSE & is.null(DRUG)==FALSE) {
Lmedic   <- RESULT$ALLSIGNALS[,1][RESULT$ALLSIGNALS[,1]==DRUG & RESULT$ALLSIGNALS[,2]==EVENT]
Leffect  <- RESULT$ALLSIGNALS[,2][RESULT$ALLSIGNALS[,1]==DRUG & RESULT$ALLSIGNALS[,2]==EVENT]
effectif <- RESULT$ALLSIGNALS[,3][RESULT$ALLSIGNALS[,1]==DRUG & RESULT$ALLSIGNALS[,2]==EVENT]
expect_E <- RESULT$ALLSIGNALS[,4][RESULT$ALLSIGNALS[,1]==DRUG & RESULT$ALLSIGNALS[,2]==EVENT]
stat     <- RESULT$ALLSIGNALS[,5][RESULT$ALLSIGNALS[,1]==DRUG & RESULT$ALLSIGNALS[,2]==EVENT]
r        <- rang[RESULT$ALLSIGNALS[,1]==DRUG & RESULT$ALLSIGNALS[,2]==EVENT]
#fdr      <- RESULT$OpChar[,1][RESULT$ALLSIGNALS[,1]==DRUG & RESULT$ALLSIGNALS[,2]==EVENT]
fdr      <- RESULT$ALLSIGNALS[,9][RESULT$ALLSIGNALS[,1]==DRUG & RESULT$ALLSIGNALS[,2]==EVENT]
}

if (is.null(EVENT) & is.null(DRUG)==FALSE) {
Lmedic   <- RESULT$ALLSIGNALS[,1][RESULT$ALLSIGNALS[,1]==DRUG]
Leffect  <- RESULT$ALLSIGNALS[,2][RESULT$ALLSIGNALS[,1]==DRUG]
effectif <- RESULT$ALLSIGNALS[,3][RESULT$ALLSIGNALS[,1]==DRUG]
expect_E <- RESULT$ALLSIGNALS[,4][RESULT$ALLSIGNALS[,1]==DRUG]
stat     <- RESULT$ALLSIGNALS[,5][RESULT$ALLSIGNALS[,1]==DRUG]
r        <- rang[RESULT$ALLSIGNALS[,1]==DRUG]
#fdr      <- RESULT$OpChar[,1][RESULT$ALLSIGNALS[,1]==DRUG]
fdr      <- RESULT$ALLSIGNALS[,9][RESULT$ALLSIGNALS[,1]==DRUG]
}

if (is.null(EVENT)==FALSE & is.null(DRUG)) {
Lmedic   <- RESULT$ALLSIGNALS[,1][RESULT$ALLSIGNALS[,2]==EVENT]
Leffect  <- RESULT$ALLSIGNALS[,2][RESULT$ALLSIGNALS[,2]==EVENT]
effectif <- RESULT$ALLSIGNALS[,3][RESULT$ALLSIGNALS[,2]==EVENT]
expect_E <- RESULT$ALLSIGNALS[,4][RESULT$ALLSIGNALS[,2]==EVENT]
stat     <- RESULT$ALLSIGNALS[,5][RESULT$ALLSIGNALS[,2]==EVENT]
r        <- rang[RESULT$ALLSIGNALS[,2]==EVENT]
#fdr      <- RESULT$OpChar[,1][RESULT$ALLSIGNALS[,2]==EVENT]
fdr      <- RESULT$ALLSIGNALS[,9][RESULT$ALLSIGNALS[,2]==EVENT]
}


RES <- vector(mode="list")
RES$DRUG <- DRUG
RES$EVENT <- EVENT
RES$EXIST_EVENT <- EXIST_EVENT
RES$EXIST_DRUG  <- EXIST_DRUG
RES$EXIST_COUPLE <- length(Lmedic)!=0
RES$LIST <- data.frame(Lmedic,Leffect,effectif,expect_E,stat,r,fdr)
colnames(RES$LIST) <- c("drug name","event","count","expected count","stat","rank","fdr")
RES
}

Try the PhViD package in your browser

Any scripts or data that you put into this service are public.

PhViD documentation built on May 2, 2019, 11:37 a.m.