Description Usage Arguments Details Value Author(s) Examples
Helper functions for quick-and-dirty creation of custom panels, usually in the context of a one-off application. This creates a new class with specialized methods for showing content based on a user-specified function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | createCustomTable(
FUN,
restrict = NULL,
className = "CustomTable",
fullName = "Custom table",
where = topenv(parent.frame())
)
createCustomPlot(
FUN,
restrict = NULL,
className = "CustomPlot",
fullName = "Custom plot",
where = topenv(parent.frame())
)
|
FUN |
A function that generates a data.frame or a ggplot,
for |
restrict |
Character vector of names of optional arguments in |
className |
String containing the name of the new Panel class. |
fullName |
String containing the full name of the new class. |
where |
An environment indicating where the class and method definitions should be stored. |
FUN
is expected to have the following first 3 arguments:
se
, a SummarizedExperiment object for the current dataset of interest.
rows
, a list of row selections received from the transmitting panel.
This contains one or more character vectors of row names in active and saved selections.
Alternatively, this may be NULL
if no selection has been made in the transmitter.
columns
, a list of column selections received from the transmitting panel.
This contains one or more character vectors of column names in active and saved selections.
Alternatively, this may be NULL
if no selection has been made in the transmitter.
Any number of additional named arguments may also be present in FUN
.
All such arguments should have default values,
as these are used to automatically generate UI elements in the panel:
Character vectors will get a selectInput
.
Strings will get a textInput
.
Numeric scalars will get a numericInput
.
Logical scalars will get a checkboxInput
.
Arguments with other types of default values are ignored.
If restrict
is specified, arguments will only have corresponding UI elements if they are listed in restrict
.
All user interactions with these elements will automatically trigger regeneration of the panel contents.
Classes created via these functions are extremely limited. Only scalar inputs are supported via the UI and all panels cannot transmit to the rest of the app. We recommend only using these functions for one-off applications to quickly prototype concepts; serious Panel extensions should be done explicitly.
A new class and its methods are defined in the global environment. A generator function for creating new instances of the class is returned.
Aaron Lun
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | library(scater)
CUSTOM_DIMRED <- function(se, rows, columns, ntop=500, scale=TRUE,
mode=c("PCA", "TSNE", "UMAP"))
{
if (is.null(columns)) {
return(
ggplot() + theme_void() + geom_text(
aes(x, y, label=label),
data.frame(x=0, y=0, label="No column data selected."),
size=5)
)
}
mode <- match.arg(mode)
if (mode=="PCA") {
calcFUN <- runPCA
} else if (mode=="TSNE") {
calcFUN <- runTSNE
} else if (mode=="UMAP") {
calcFUN <- runUMAP
}
kept <- se[, unique(unlist(columns))]
kept <- calcFUN(kept, ncomponents=2, ntop=ntop,
scale=scale, subset_row=unique(unlist(rows)))
plotReducedDim(kept, mode)
}
GEN <- createCustomPlot(CUSTOM_DIMRED)
GEN()
if (interactive()) {
library(scRNAseq)
sce <- ReprocessedAllenData("tophat_counts")
library(scater)
sce <- logNormCounts(sce, exprs_values="tophat_counts")
iSEE(sce, initial=list(
ColumnDataPlot(PanelId=1L),
GEN(ColumnSelectionSource="ColumnDataPlot1")
))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.