View source: R/dimensionality_reduction.R
tof_reduce_pca | R Documentation |
This function calculates principal components using single-cell data from a 'tof_tibble'.
tof_reduce_pca(
tof_tibble,
pca_cols = where(tof_is_numeric),
num_comp = 5,
threshold = NA,
center = TRUE,
scale = TRUE,
return_recipe = FALSE
)
tof_tibble |
A 'tof_tbl' or 'tibble'. |
pca_cols |
Unquoted column names indicating which columns in 'tof_tibble' to use for computing the principal components. Defaults to all numeric columns. Supports tidyselect helpers. |
num_comp |
The number of PCA components to calculate. Defaults
to 5. See |
threshold |
A double between 0 and 1 representing the fraction of total
variance that should be covered by the components returned in the output. See
|
center |
A boolean value indicating if each column should be centered to mean 0 before PCA analysis. Defaults to TRUE. |
scale |
A boolean value indicating if each column should be scaled to standard deviation = 1 before PCA analysis. Defaults to TRUE. |
return_recipe |
A boolean value indicating if instead of the UMAP result, a
prepped |
A tibble with the same number of rows as 'tof_tibble', each representing a single cell. Each of the ‘num_comp' columns represents each cell’s embedding in the calculated principal component space.
Other dimensionality reduction functions:
tof_reduce_dimensions()
,
tof_reduce_tsne()
,
tof_reduce_umap()
# simulate single-cell data
sim_data <-
dplyr::tibble(
cd45 = rnorm(n = 200),
cd38 = rnorm(n = 200),
cd34 = rnorm(n = 200),
cd19 = rnorm(n = 200)
)
new_data <-
dplyr::tibble(
cd45 = rnorm(n = 50),
cd38 = rnorm(n = 50),
cd34 = rnorm(n = 50),
cd19 = rnorm(n = 50)
)
# calculate pca
tof_reduce_pca(tof_tibble = sim_data, num_comp = 2)
# return recipe instead of embeddings
pca_recipe <- tof_reduce_pca(tof_tibble = sim_data, return_recipe = TRUE)
# apply recipe to new data
recipes::bake(pca_recipe, new_data = new_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.