The DotPlot is a virtual class for all panels where each row or column in the SummarizedExperiment is represented by no more than one point (i.e., a “dot”) in a brushable ggplot plot. It provides slots and methods to create the plot, to control various aesthetics of the dots, and to store the brush or lasso selection.
Slot overview
The following slots are relevant to coloring of the points:
ColorBy
, a string specifying how points should be colored. This should be one of"None"
,"Feature name"
,"Sample name"
and either"Column data"
(for ColumnDotPlots) or"Row data"
(for RowDotPlots). Defaults to"None"
.ColorByDefaultColor
, a string specifying the default color to use for all points ifColorBy="None"
. Defaults to"black"
ingetPanelDefault
.ColorByFeatureName
, a string specifying the feature to be used for coloring points whenColorBy="Feature name"
. For RowDotPlots, this is used to highlight the point corresponding to the selected feature; for ColumnDotPlots, this is used to color each point according to the expression of that feature. IfNA
, this defaults to the name of the first row.ColorByFeatureSource
, a string specifying the name of the panel to use for transmitting the feature selection toColorByFeatureName
. Defaults to"---"
.ColorBySampleName
, a string specifying the sample to be used for coloring points whenColorBy="Sample name"
. For RowDotPlots, this is used to color each point according to the expression of that sample; for ColumnDotPlots, this is used to highlight the point corresponding to the selected sample. IfNA
, this defaults to the name of the first column.ColorBySampleSource
, a string specifying the name of the panel to use for transmitting the sample selection toColorBySampleNameColor
. Defaults to"---"
.ColorByFeatureDynamicSource
, a logical scalar indicating whetherx
should dynamically change its selection source when coloring by feature. Defaults toFALSE
ingetPanelDefault
.ColorBySampleDynamicSource
, a logical scalar indicating whetherx
should dynamically change its selection source when coloring by feature. Defaults toFALSE
ingetPanelDefault
.SelectionAlpha
, a numeric scalar in [0, 1] specifying the transparency to use for non-selected points. Defaults to 0.1 ingetPanelDefault
.
The following slots control other metadata-related aesthetic aspects of the points:
ShapeBy
, a string specifying how the point shape should be determined. This should be one of"None"
and either"Column data"
(for ColumnDotPlots) or"Row data"
(for RowDotPlots). Defaults to"None"
.SizeBy
, a string specifying the metadata field for controlling point size. This should be one of"None"
and either"Column data"
(for ColumnDotPlots) or"Row data"
(for RowDotPlots). Defaults to"None"
.
The following slots control the faceting:
FacetRowBy
, a string indicating what to use for creating row facets. For RowDotPlots, this should be one of"None"
,"Row data"
or"Row selection"
. For ColumnDotPlots, this should be one of"None"
,"Column data"
or"Column selection"
. Defaults to"None"
, i.e., no row faceting.FacetByColumn
, a string indicating what to use for creating column facets. For RowDotPlots, this should be one of"None"
,"Row data"
or"Row selection"
. For ColumnDotPlots, this should be one of"None"
,"Column data"
or"Column selection"
. Defaults to"None"
, i.e., no column faceting.
The following slots control any text to be shown on the plot:
LabelCenters
, a logical scalar indicating whether the label the centers (technically medoids) of all cells in each group, where groups are defined by a discrete covariate in the relevant metadata field. Defaults toFALSE
.LabelCentersBy
, a string specifying the metadata field to define the groups whenLabelCenters
isTRUE
. This should be a discrete variable inrowData
orcolData
for RowDotPlots and ColumnDotPlots, respectively. Defaults to the name of the first column.LabelCentersColor
, a string specifying the color used for the labels at the center of each group. Only used whenLabelCenters
isTRUE
. Defaults to"black"
.CustomLabels
, a logical scalar indicating whether custom labels should be inserted on specific points. Defaults toFALSE
.CustomLabelsText
, a (possibly multi-line) string with the names of the points to label whenCustomLabels
is set toTRUE
. Each line should contain the name of a row or column for RowDotPlots and ColumnDotPlots, respectively. Leading and trailing whitespace are stripped, and all text on a line after#
is ignored. Defaults to the name of the first row/column.
The following slots control interactions with the plot image:
ZoomData
, a named numeric vector of plot coordinates with"xmin"
,"xmax"
,"ymin"
and"ymax"
elements parameterizing the zoom boundaries. Defaults to an empty vector, i.e., no zoom.BrushData
, a list containing either a Shiny brush (see?brushedPoints
) or an iSEE lasso (see?lassoPoints
). Defaults to an empty list, i.e., no brush or lasso.HoverInfo
, a logical scalar indicating whether the feature/sample name should be shown upon mouse-over of the point. Defaults toTRUE
.
The following slots control some aspects of the user interface:
DataBoxOpen
, a logical scalar indicating whether the data parameter box should be open. Defaults toFALSE
.VisualBoxOpen
, a logical scalar indicating whether the visual parameter box should be open. Defaults toFALSE
.VisualChoices
, a character vector specifying the visible interface elements upon initialization. This can contain zero or more of"Color"
,"Shape"
,"Size"
,"Point"
,"Facet"
,"Text"
, and"Other"
. Defaults to"Color"
.
The following slots control the addition of a contour:
ContourAdd
, logical scalar indicating whether a contour should be added to a (scatter) plot. Defaults toFALSE
.ContourColor
, string specifying the color to use for the contour lines. Defaults to"blue"
.
The following slot controls whether the aspect ratio is fixed to 1 or not:
FixAspectRatio
, logical scalar indicating whether the aspect ratio of a scatter plot should be fixed to 1. Defaults toFALSE
.
The following slot controls whether the violin boundaries are plotted or not:
ViolinAdd
, logical scalar indicating whether the violin boundaries should be plotted. Defaults toTRUE
.
The following slots control the general appearance of the points.
PointSize
, positive numeric scalar specifying the relative size of the points. Defaults to 1.PointAlpha
, non-negative numeric scalar specifying the transparency of the points. Defaults to 1, i.e., not transparent.Downsample
, logical scalar indicating whether to downsample points for faster plotting. Defaults toFALSE
ingetPanelDefault
.DownsampleResolution
, numeric scalar specifying the resolution of the downsampling grid (see?subsetPointsByGrid
) ifDownsample=TRUE
. Larger values correspond to reduced downsampling at the cost of plotting speed. Defaults to 200 ingetPanelDefault
.
The following slots refer to general plotting parameters:
FontSize
, positive numeric scalar specifying the relative font size. Defaults to 1 ingetPanelDefault
.PointSize
, positive numeric scalar specifying the relative point size. Defaults to 1 ingetPanelDefault
.LegendPosition
, string specifying the position of the legend on the plot. Defaults to"Bottom"
ingetPanelDefault
. The other valid choice is"Right"
.
In addition, this class inherits all slots from its parent Panel class.
Supported methods
In the following code snippets, x
is an instance of a DotPlot class.
Refer to the documentation for each method for more details on the remaining arguments.
For setting up the objects:
.cacheCommonInfo(x)
adds a"DotPlot"
entry containingvalid.assay.names
, a character vector of valid assay names. Valid names are defined as those that are non-empty, i.e., not""
. This method will also call the equivalent Panel method..refineParameters(x, se)
replacesNA
values inColorByFeatureName
andColorBySampleNameColor
with the first row and column name, respectively, ofse
. This will also call the equivalent Panel method.
For defining the interface:
.defineInterface(x, se, select_info)
defines the user interface for manipulating all slots described above and in the parent classes. It will also create a data parameter box that can respond to specialized.defineDataInterface
. This will override the Panel method..defineVisualColorInterface(x, se, select_info)
defines the user interface subpanel for manipulating the color of the points..defineVisualShapeInterface(x, se)
defines the user interface subpanel for manipulating the shape of the points..defineVisualSizeInterface(x, se)
defines the user interface subpanel for manipulating the size of the points..defineVisualPointInterface(x, se)
defines the user interface subpanel for manipulating other point-related parameters..defineVisualFacetInterface(x, se)
defines the user interface subpanel for manipulating facet-related parameters..defineVisualTextInterface(x, se)
defines the user interface subpanel for manipulating text-related parameters..defineVisualOtherInterface(x, se)
defines the user interface subpanel for manipulating other parameters. Currently this returnsNULL
..defineOutput(x)
returns a UI element for a brushable plot..allowableColorByDataChoices(x, se)
returns a character vector containing all atomic variables in the relevant*Data
dimension.
For generating the output:
.generateOutput(x, se, all_memory, all_contents)
returns a list containingcontents
, a data.frame with one row per point currently present in the plot;plot
, a ggplot object;commands
, a list of character vector containing the R commands required to generatecontents
andplot
; andvarname
, a string containing the name of the variable incommands
that was used to obtaincontents
..generateDotPlot(x, labels, envir)
returns a list containingplot
andcommands
, as described above. This is called within.generateOutput
for all DotPlot instances by default. Methods are also guaranteed to generate adot.plot
variable inenvir
containing the ggplot object corresponding toplot
..prioritizeDotPlotData(x, envir)
returnsNULL
..colorByNoneDotPlotField(x)
returnsNULL
..colorByNoneDotPlotScale(x)
returnsNULL
..exportOutput(x, se, all_memory, all_contents)
will create a PDF file containing the current plot, and return a string containing the path to that PDF. This assumes that theplot
field returned by.generateOutput
is a ggplot object.
For defining reactive expressions:
.createObservers(x, se, input, session, pObjects, rObjects)
sets up observers for some (but not all!) of the slots. This will also call the equivalent Panel method..renderOutput(x, se, output, pObjects, rObjects)
will add a rendered plot element tooutput
. The reactive expression will add the contents of the plot topObjects$contents
and the relevant commands topObjects$commands
. This will also call the equivalent Panel method to render the panel information text boxes.
For controlling selections:
.multiSelectionCommands(x, index)
returns a character vector of R expressions that - when evaluated - returns a character vector of the names of selected points in the active and/or saved selections ofx
. The active selection is returned ifindex=NA
, otherwise one of the saved selection is returned..multiSelectionActive(x)
returnsx[["BrushData"]]
orNULL
if there is no brush or closed lasso..multiSelectionClear(x)
returnsx
after setting theBrushData
slot to an empty list..singleSelectionValue(x, contents)
returns the name of the first selected element in the active brush. If no brush is active,NULL
is returned instead..singleSelectionSlots(x)
will return a list specifying the slots that can be updated by single selections in transmitter panels, mostly related to the choice of coloring parameters. This includes the output ofcallNextMethod
.
For documentation:
.definePanelTour(x)
returns an data.frame containing the steps of a tour relevant to subclasses, mostly describing the specification of visual effects and the creation of a brush or lasso.
Unless explicitly specialized above, all methods from the parent class Panel are also available.
Subclass expectations
The DotPlot is a rather vaguely defined class for which the only purpose is to avoid duplicating code for ColumnDotPlots and RowDotPlots. We recommend extending those subclasses instead.
See also
RowDotPlot and ColumnDotPlot, which are more amenable to extension.