R: AE (Adverse Events) dotplot of incidence and relative risk
AEdotplot
R Documentation
AE (Adverse Events) dotplot of incidence and relative risk
Description
A three-panel display of the most
frequently occurring AEs in the active arm of a clinical
study. The first panel displays their incidence by
treatment group, with different symbols for each
group. The second panel displays the relative risk
of an event on the active arm relative to the
placebo arm, with 95% confidence intervals for a 2x2 table.
By default, the AEs are ordered by
relative risk so that events with the largest
increases in risk for the active treatment are
prominent at the top of the display.
By setting the argument sortbyRelativeRisk=FALSE, the AEs retain
the order specified by the levels of the factor.
The third panel displays the numerical values of number of patients for
each treatment,
number of adverse events for each treatment, and relative risk.
The third panel can be suppressed by the print method.
Usage
AEdotplot(xr, ...)
## S3 method for class 'formula'
AEdotplot(xr, groups=NULL, data=NULL,
sortbyRelativeRisk=TRUE,
...,
sub=list(deparse(this.call[1:4],
width.cutoff=500), cex=.7))
Arguments
xr
For the formula method, a formula of the form
AE ~ nAE/nTRT | OrgSys, where the condition variable is
optional.
For the formula method only, the variable names are not restricted.
See AEdotplot.data.frame for the support methods.
groups
Variable containing the treatment levels.
data
data.frame containing at least four variables:
containing the AE name as a factor, the treatment level as a factor, the number of observed
AE in that treatment level, the number of
patients in that treatment group. It may also contain a fifth variable
containing a condition variable used to
split the data.frame into partitions.
It may be used to partition the plot,
for example by organ system or by gender.
The treatment factor must have exactly two levels.
Each AE name must appear exactly once for each level of the treatment.
sortbyRelativeRisk
logical. If TRUE, then make the
Adverse Events an ordered factor ordering by relative risk.
If FALSE, then make the
Adverse Events an ordered factor retaining the order of the input levels.
sub
Subtitle for the plot. The default value is the command
that generates the plot.
...
Any of the arguments (such as the sorting options) listed in the
calling sequence for the methods documented in
AEdotplot.data.frame.
Details
The first panel is an ordinary dotplot of the percent of AE observed for each
treatment by AE.
The second panel shows relative risk of an event on the Treatment B arm
(usually the active compound)
relative to the Treatment A arm (usually the placebo), with 95% confidence
intervals for a 2x2 table. Confidence intervals on the log
relative risk are calculated using the asymptotic standard error
formula given as Equation 3.18 in Agresti A., Categorical Data
Analysis. Wiley: New York, 1990.
By default the AEdotplot function sorts the events by relative risk.
To retain the sort order implied by the levels of the AE
factor, specify the argument sortbyRelativeRisk=FALSE.
To control the sort order, make the AE factor in the input dataset
an ordered factor
and specify the levels in the order you want.
The third panel shows the numerical values of the number and percent
of observed events on each arm and the relative risk.
The display of third panel can be suppressed by specifying the
panel.widths argument. See the discussion of the
panel.widths in AEdotplot.data.frame.
Value
The primary interest is in the display of the plot.
The function returns
an AEdotplot object which is a list of three trellis
objects,
one for the the Percent plot, one for the Relative Risk plot, and one
for
the Text plot containing the table of input values. The object has
attributes
main and sub hold the main and subtitles. Each must
be a list containing the text in the first component.
ae.key is a key as described in
xyplot.
n.events is a vector containing the number of events in
each subpanel.
panel.widths is a vector of relative widths of the three components
of
the graph. The numbers must sum to one. Zero values are permitted.
The first width includes the left axis and the Percent plot. The second
is the Relative Risk plot, and the third is the plot of the table
values.
AEtable is a table containing the data plotted on its row.
Note
Ann Liu-Ferrara was a beta tester for the shiny app.
## formula method. See ?AEdotplot.data.frame for other methods.
data(AEdata)
head(AEdata)
AEdotplot(AE ~ nAE/nTRT, groups = TRT, data = AEdata) ## sort by Relative Risk
AEdotplot(AE ~ nAE/nTRT | OrgSys, groups = TRT, data = AEdata) ## conditioned on Organ System
## Not run:
AEdotplot(AE ~ nAE/nTRT, groups = TRT, data = AEdata, sortbyVar="PCT") ## PCT A
AEdotplot(AE ~ nAE/nTRT, groups = TRT, data = AEdata, sortbyVar="PCT", sortbyVarBegin=2) ## PCT B
AEdotplot(AE ~ nAE/nTRT, groups = TRT, data = AEdata, sortbyRelativeRisk=FALSE) ## levels(AE)
AEdotplot(AE ~ nAE/nTRT | OrgSys, groups = TRT, data = AEdata, sortbyVar="ase.logrelrisk")
## End(Not run)
## Not run:
AEdotplot(AE ~ nAE/nTRT | OrgSys, groups = TRT,
data = AEdata[c(AEdata$OrgSys %in% c("GI","Resp")),])
## test sortbyRelativeRisk=FALSE
ABCD.12345 <- AEdata[1:12,]
head(ABCD.12345)
AEdotplot(AE ~ nAE/nTRT | OrgSys, groups=TRT, data=ABCD.12345)
AEdotplot(AE ~ nAE/nTRT | OrgSys, groups=TRT, data=ABCD.12345, sort=FALSE)
## suppress third panel
tmp <- AEdotplot(AE ~ nAE/nTRT, groups = TRT, data = AEdata)
print(tmp, AEtable=FALSE)
## End(Not run)
## Not run:
## run the shiny app
shiny::runApp(system.file("shiny/AEdotplot", package="HH"))
## End(Not run)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(HH)
Loading required package: lattice
Loading required package: grid
Loading required package: latticeExtra
Loading required package: RColorBrewer
Loading required package: multcomp
Loading required package: mvtnorm
Loading required package: survival
Loading required package: TH.data
Loading required package: MASS
Attaching package: 'TH.data'
The following object is masked from 'package:MASS':
geyser
Loading required package: gridExtra
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HH/ae.dotplot7a.Rd_%03d_medium.png", width=480, height=480)
> ### Name: AEdotplot
> ### Title: AE (Adverse Events) dotplot of incidence and relative risk
> ### Aliases: AEdotplot AEdotplot.formula
> ### Keywords: hplot htest
>
> ### ** Examples
>
> ## formula method. See ?AEdotplot.data.frame for other methods.
> data(AEdata)
> head(AEdata)
TRT AE nAE nTRT OrgSys
1 A DYSPNEA 15 216 Resp
2 B DYSPNEA 9 431 Resp
3 A HYPERKALEMIA 4 216 Misc
4 B HYPERKALEMIA 9 431 Misc
5 A RASH 4 216 Misc
6 B RASH 9 431 Misc
>
> AEdotplot(AE ~ nAE/nTRT, groups = TRT, data = AEdata) ## sort by Relative Risk
> AEdotplot(AE ~ nAE/nTRT | OrgSys, groups = TRT, data = AEdata) ## conditioned on Organ System
>
> ## Not run:
> ##D AEdotplot(AE ~ nAE/nTRT, groups = TRT, data = AEdata, sortbyVar="PCT") ## PCT A
> ##D AEdotplot(AE ~ nAE/nTRT, groups = TRT, data = AEdata, sortbyVar="PCT", sortbyVarBegin=2) ## PCT B
> ##D AEdotplot(AE ~ nAE/nTRT, groups = TRT, data = AEdata, sortbyRelativeRisk=FALSE) ## levels(AE)
> ##D AEdotplot(AE ~ nAE/nTRT | OrgSys, groups = TRT, data = AEdata, sortbyVar="ase.logrelrisk")
> ## End(Not run)
>
>
> ## Not run:
> ##D
> ##D
> ##D AEdotplot(AE ~ nAE/nTRT | OrgSys, groups = TRT,
> ##D data = AEdata[c(AEdata$OrgSys %in% c("GI","Resp")),])
> ##D
> ##D ## test sortbyRelativeRisk=FALSE
> ##D ABCD.12345 <- AEdata[1:12,]
> ##D head(ABCD.12345)
> ##D AEdotplot(AE ~ nAE/nTRT | OrgSys, groups=TRT, data=ABCD.12345)
> ##D AEdotplot(AE ~ nAE/nTRT | OrgSys, groups=TRT, data=ABCD.12345, sort=FALSE)
> ##D
> ##D ## suppress third panel
> ##D tmp <- AEdotplot(AE ~ nAE/nTRT, groups = TRT, data = AEdata)
> ##D print(tmp, AEtable=FALSE)
> ## End(Not run)
>
> ## Not run:
> ##D ## run the shiny app
> ##D shiny::runApp(system.file("shiny/AEdotplot", package="HH"))
> ## End(Not run)
>
>
>
>
>
>
> dev.off()
null device
1
>