Skip to contents

This function is a wrapper around tidytof's tof_reduce_* function family. It performs dimensionality reduction on single-cell data using a user-specified method (of 3 choices) and each method's corresponding input parameters

Usage

tof_reduce_dimensions(
  tof_tibble,
  ...,
  augment = TRUE,
  method = c("pca", "tsne", "umap")
)

Arguments

tof_tibble

A `tof_tbl` or `tibble`.

...

Arguments to be passed to the tof_reduce_* function corresponding to the embedding method. See tof_reduce_pca, tof_reduce_tsne, and tof_reduce_umap.

augment

A boolean value indicating if the output should column-bind the dimensionality-reduced embedding vectors of each cell as a new column in `tof_tibble` (TRUE, the default) or if a tibble including only the low-dimensionality embeddings should be returned (FALSE).

method

A method of dimensionality reduction. Currently, PCA, tSNE, and UMAP embedding are supported.

Value

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 embedding space.

See also

Other dimensionality reduction functions: tof_reduce_pca(), tof_reduce_tsne(), tof_reduce_umap()

Examples

# simulate single-cell data
sim_data <-
    dplyr::tibble(
        cd45 = rnorm(n = 100),
        cd38 = rnorm(n = 100),
        cd34 = rnorm(n = 100),
        cd19 = rnorm(n = 100)
    )

# calculate pca
tof_reduce_dimensions(tof_tibble = sim_data, method = "pca")
#> # A tibble: 100 × 8
#>       cd45    cd38    cd34   cd19    .pc1    .pc2   .pc3   .pc4
#>      <dbl>   <dbl>   <dbl>  <dbl>   <dbl>   <dbl>  <dbl>  <dbl>
#>  1 -0.541  -0.317   0.240   1.31   0.121  -1.09   -0.765 -0.734
#>  2  0.832   1.19   -0.428  -0.860  0.907   1.55    0.176  0.410
#>  3 -0.302   0.311   1.04   -0.824 -0.0755 -0.218   0.411  1.08 
#>  4 -0.0564 -0.654   0.377   0.383 -0.205  -0.741   0.214 -0.592
#>  5 -0.0441 -1.57    0.698  -1.01  -1.39   -0.670   1.45  -0.321
#>  6  0.746   1.16   -0.378  -0.323  1.09    1.20   -0.102  0.191
#>  7  0.922  -0.688   0.0483 -0.255  0.0164  0.0635  1.05  -0.841
#>  8 -1.93   -0.411  -0.635  -1.45  -2.23    0.542  -0.680  0.544
#>  9 -0.266   0.561  -0.649  -2.09  -0.811   1.77    0.250  0.872
#> 10 -1.11   -0.0166 -0.117  -1.23  -1.23    0.453  -0.231  0.690
#> # ℹ 90 more rows

# calculate tsne
tof_reduce_dimensions(tof_tibble = sim_data, method = "tsne")
#> # A tibble: 100 × 6
#>       cd45    cd38    cd34   cd19  .tsne1 .tsne2
#>      <dbl>   <dbl>   <dbl>  <dbl>   <dbl>  <dbl>
#>  1 -0.541  -0.317   0.240   1.31  -1.61   -1.34 
#>  2  0.832   1.19   -0.428  -0.860 -0.728   3.35 
#>  3 -0.302   0.311   1.04   -0.824  2.85   -2.19 
#>  4 -0.0564 -0.654   0.377   0.383  0.0177 -1.22 
#>  5 -0.0441 -1.57    0.698  -1.01   2.61   -0.365
#>  6  0.746   1.16   -0.378  -0.323 -1.07    3.14 
#>  7  0.922  -0.688   0.0483 -0.255  0.277   0.844
#>  8 -1.93   -0.411  -0.635  -1.45   3.57    1.64 
#>  9 -0.266   0.561  -0.649  -2.09   2.64    3.29 
#> 10 -1.11   -0.0166 -0.117  -1.23   2.96    1.58 
#> # ℹ 90 more rows

# calculate umap
tof_reduce_dimensions(tof_tibble = sim_data, method = "umap")
#> # A tibble: 100 × 6
#>       cd45    cd38    cd34   cd19 .umap1 .umap2
#>      <dbl>   <dbl>   <dbl>  <dbl>  <dbl>  <dbl>
#>  1 -0.541  -0.317   0.240   1.31   2.05  -1.03 
#>  2  0.832   1.19   -0.428  -0.860 -3.22  -1.71 
#>  3 -0.302   0.311   1.04   -0.824  5.13   2.33 
#>  4 -0.0564 -0.654   0.377   0.383  1.26  -0.329
#>  5 -0.0441 -1.57    0.698  -1.01  -0.460  1.10 
#>  6  0.746   1.16   -0.378  -0.323 -3.09  -1.83 
#>  7  0.922  -0.688   0.0483 -0.255 -0.512 -1.83 
#>  8 -1.93   -0.411  -0.635  -1.45  -4.90   0.456
#>  9 -0.266   0.561  -0.649  -2.09  -5.51   1.05 
#> 10 -1.11   -0.0166 -0.117  -1.23  -4.51   0.299
#> # ℹ 90 more rows