Table-class: The Table class

Table-classR Documentation

The Table class

Description

The Table is a virtual class for all panels containing a datatable widget from the DT package, where each row usually corresponds to a row or column of the SummarizedExperiment object. It provides observers for rendering the table widget, monitoring single selections, and applying global and column-specific searches (which serve as multiple selections).

Slot overview

The following slots control aspects of the DT::datatable selection:

  • Selected, a string containing the name of the currently selected row of the data.frame. Defaults to NA, in which case the value should be chosen by the subclass' .refineParameters method.

  • Search, a string containing the regular expression for the global search. Defaults to "", i.e., no search.

  • SearchColumns, a unnamed character vector of length equal to the number of columns of the data.frame, where each entry contains the search string for its corresponding column. Alternatively, a character vector of variable length, containing search strings for one or more columns. Defaults to an character vector of length zero, which is internally expanded to an vector of zero-length strings, i.e., no search.

The following slots control the appearance of the table:

  • HiddenColumns, a character vector containing names of columns to hide. Defaults to an empty vector.

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 Table class. Refer to the documentation for each method for more details on the remaining arguments.

For defining the interface:

  • .defineOutput(x) returns a UI element for a dataTableOutput widget.

  • .defineDataInterface(x) will create interface elements for modifying the table, namely to choose which columns to hide. Note that this is populated by .generateOutput upon table rendering, as we do not know the available columns before that point.

For defining reactive expressions:

  • .createObservers(x, se, input, session, pObjects, rObjects) sets up observers for all of the slots. This will also call the equivalent Panel method.

  • .renderOutput(x, se, output, pObjects, rObjects) will add a rendered datatable object to output. This will also call the equivalent Panel method to render the panel information text boxes.

  • .generateOutput(x, se, all_memory, all_contents) returns a list containing contents, a data.frame with one row per point currently present in the table; commands, a list of character vector containing the R commands required to generate contents and plot; and varname, a string specifying the name of the variable in commands used to generate contents.

  • .exportOutput(x, se, all_memory, all_contents) will create a CSV file containing the current table, and return a string containing the path to that file. This assumes that the contents field returned by .generateOutput is a data.frame or can be coerced into one.

For controlling selections:

  • .multiSelectionRestricted(x) returns TRUE. Transmission of a selection to a Table will manifest as a subsetting of the rows.

  • .multiSelectionActive(x) returns a list containing the contents of x[["Search"]] and x[["ColumnSearch"]]. If both contain only empty strings, a NULL is returned instead.

  • .multiSelectionCommands(x, index) returns a character vector of R expressions that - when evaluated - return a character vector of the row names of the table after applying all search filters. The value of index is ignored.

  • .singleSelectionValue(x, contents) returns the name of the row that was last selected in the datatable widget.

For documentation:

  • .definePanelTour(x) returns an data.frame containing the steps of a tour relevant to subclasses, mostly describing the effect of selection from other panels and the use of row filters to transmit selections.

Unless explicitly specialized above, all methods from the parent class Panel are also available.

Subclass expectations

The Table 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.

Author(s)

Aaron Lun

See Also

Panel, for the immediate parent class.


csoneson/SEE documentation built on Dec. 13, 2024, 6:43 p.m.