npData | R Documentation |
Understanding the npData objects returned by BVT functions
An object of class npData
is returned from all BCT plotting functions. The primary use of these is to allow for the graph
to be saved so it can be plotted later using plot
or a BVT plotting function. Modifications can also be made such as changing
a bar plot to a box plot or changing any of the bvt_graphic_options
or plotColors
settings. These
saved objects can also be passed to functions such as link{pick_points}
, to further analyze the data or make new factor levels.
These objects also have some useful information stored in them stored in the a named list with the sections: summary, stats, plotType,
and options. A breakdown of each section is below.
npData$summary
This section is a containing the summary data and descriptive statistics for the plot. The data is broken down by group
, subgroup
, and
highlight
factor levels if active and reflects the essential statistics of the plot. A bar plot might have mean and 2x standard error of
the mean listed by factor level while a box plot would have the quartile values. These summary statistics will change with aggFun
and errFun
settings. Not yet implemented for scatter plots generated with geneScatter
.
npData$stats
This section is a named list containing an overall p-value where applicable or NA
(npData$stats$p.value
), the name of the statistical
test performed (e.g. pairwise.wilcox.test
; npData$stats$test
), and the object returned by that test (npData$stats$results
).
In the case of geneScatter
, this section will provide a linear model from lm
, and the output of cor.test
for each trend line present.
npData$plotType
This is a text string that corresponds to the plot type. Valid options include box
, dot
, bar
, density
, and scatter
.
npData$options
This section has all the options and data needed to regenerate the plot. The three parts worth noting are npData$options$x
which
as all the numeric data as a vector
or data.frame
, npData$options$by
which contains a
factor
or a data.frame
of factors used to subset or highlight the data, and npData$options$xypos
which contains the actual x and y coordinates for all points on the graph including those subject to jitter
, distribution
, or beeswarm
settings from the pointMethod
option. Note that x
and by
are the original data with NA
still present while xypos
is post filtering and may be smaller and has the corresponding row numbers of the original x
and by
data to allow for mapping between the two
systems. This can be useful when making custom modifications to a graph as shown in the example below.
genePlot
, isoPlot
, geneScatter
data(iris)
#plotting a saved graph with different options
a<-genePlot(t(iris[,1:4]), group=iris$Species, plotType="bar", main="npData Example")
#Note that only the first two columns of data are used below
#as this is the maximum allowed for the \emph{density plots}.
plot(a, plotType="density", theme=npColorTheme)
#Example showing the use of npData$options$xypos with a toy data set
salesData<-data.frame(Q1=c(1,4,2,2), Q2=c(2,3,4,2), Q3=c(4,4,2,3))
stores<-factor(c("Store 1","Store 2","Store 3","Store 4"))
#Transposition is necessary since expression data is typical the transpose of tidy data
b<-genePlot(t(salesData), highlight=stores, plotType="dot",
theme=npGGTheme, pointLaneWidth=2,
plotColors=list(lines=setAlpha("black",.5)),
legendSize=1, main="Toy Sales Data",
pointMethod="jitter", ylab="Sales Volume (Millions)")
#Drawing connecting lines
for(i in 1:4){
lines(
x=b$options$xypos[b$options$xypos$ID==i,"x"],
y=b$options$xypos[b$options$xypos$ID==i,"y"],
col=npGGTheme$plotColors$points[i]
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.