Skip to content

Commit 91d9e02

Browse files
kartikeyakirarm7pr
andauthored
pre-release tm_a_pca document update (#646)
part of #624 ~~blocked by #651 --------- Signed-off-by: kartikeya kirar <kirar.kartikeya1@gmail.com> Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com>
1 parent 0cb0b56 commit 91d9e02

File tree

2 files changed

+47
-38
lines changed

2 files changed

+47
-38
lines changed

R/tm_a_pca.R

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
#' Principal component analysis module
2-
#' @md
2+
#'
3+
#' Module conducts principal component analysis (PCA) on a given dataset and offers different
4+
#' ways of visualizing the outcomes, including elbow plot, circle plot, biplot, and eigenvector plot.
5+
#' Additionally, it enables dynamic customization of plot aesthetics, such as opacity, size, and
6+
#' font size, through UI inputs.
37
#'
48
#' @inheritParams teal::module
59
#' @inheritParams shared_params
610
#' @param dat (`data_extract_spec` or `list` of multiple `data_extract_spec`)
7-
#' Columns used to compute PCA.
8-
#' @param alpha optional, (`numeric`) If scalar then the plot points will have a fixed opacity. If a
9-
#' slider should be presented to adjust the plot point opacity dynamically then it can be a vector of
10-
#' length three with `c(value, min, max)`.
11-
#' @param size optional, (`numeric`) If scalar then the plot point sizes will have a fixed size.
12-
#' If a slider should be presented to adjust the plot point sizes dynamically then it can be a
13-
#' vector of length three with `c(value, min, max)`.
14-
#' @param font_size optional, (`numeric`) font size control for title, x-axis label, y-axis label and legend.
15-
#' If scalar then the font size will have a fixed size. If a slider should be presented to adjust the plot
16-
#' point sizes dynamically then it can be a vector of length three with `c(value, min, max)`.
17-
#'
11+
#' specifying columns used to compute PCA.
12+
#' @param alpha (`numeric`, optional) Specifies point opacity.
13+
#' - If vector of `length == 1` then the plot points will have a fixed opacity.
14+
#' - while vector of `value`, `min`, and `max` allows dynamic adjustment.
15+
#' @param size (`numeric`, optional) Specifies point size.
16+
#' - If vector of `length == 1` then the plot point sizes will have a fixed size
17+
#' - while vector of `value`, `min`, and `max` allows dynamic adjustment.
18+
#' @param font_size (`numeric`, optional) Specifies font size.
19+
#' It controls the font size for plot titles, axis labels, and legends.
20+
#' - If vector of `length == 1` then the font sizes will have a fixed size.
21+
#' - while vector of `value`, `min`, and `max` allows dynamic adjustment.
1822
#' @templateVar ggnames "Elbow plot", "Circle plot", "Biplot", "Eigenvector plot"
1923
#' @template ggplot2_args_multi
2024
#'
2125
#' @examples
22-
#' # general data example
2326
#' library(teal.widgets)
2427
#'
28+
#' # general data example
2529
#' data <- teal_data()
2630
#' data <- within(data, {
2731
#' require(nestcolor)
2832
#' USArrests <- USArrests
2933
#' })
34+
#'
3035
#' datanames(data) <- "USArrests"
3136
#'
3237
#' app <- init(
@@ -51,14 +56,11 @@
5156
#' )
5257
#' )
5358
#' )
54-
#'
5559
#' if (interactive()) {
5660
#' shinyApp(app$ui, app$server)
5761
#' }
5862
#'
5963
#' # CDISC data example
60-
#' library(teal.widgets)
61-
#'
6264
#' data <- teal_data()
6365
#' data <- within(data, {
6466
#' require(nestcolor)
@@ -70,7 +72,7 @@
7072
#' app <- init(
7173
#' data = data,
7274
#' modules = modules(
73-
#' teal.modules.general::tm_a_pca(
75+
#' tm_a_pca(
7476
#' "PCA",
7577
#' dat = data_extract_spec(
7678
#' dataname = "ADSL",
@@ -89,7 +91,6 @@
8991
#' )
9092
#' )
9193
#' )
92-
#'
9394
#' if (interactive()) {
9495
#' shinyApp(app$ui, app$server)
9596
#' }
@@ -171,7 +172,7 @@ tm_a_pca <- function(label = "Principal Component Analysis",
171172
)
172173
}
173174

174-
175+
# UI function for the PCA module
175176
ui_a_pca <- function(id, ...) {
176177
ns <- NS(id)
177178
args <- list(...)
@@ -282,6 +283,7 @@ ui_a_pca <- function(id, ...) {
282283
)
283284
}
284285

286+
# Server function for the PCA module
285287
srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, plot_width, ggplot2_args) {
286288
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
287289
with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI")

man/tm_a_pca.Rd

Lines changed: 26 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)