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.191  -0.963   1.35   1.42  -0.605 -0.406 -2.06   -0.424  
#>  2  0.438   1.33    0.302  0.816  1.13  -1.05  -0.0668 -0.686  
#>  3  0.500  -0.873  -0.397  1.68   0.602 -0.295 -1.78    0.941  
#>  4  0.0635  0.342   1.30   0.295 -0.356 -0.856 -0.406  -0.870  
#>  5  0.0171  0.0653 -0.481 -0.798 -0.165  0.141  0.771   0.478  
#>  6 -0.433   0.416   1.42  -1.05  -1.16  -0.369  0.703  -1.10   
#>  7  0.161   1.02   -1.23  -1.49   0.478  0.155  2.03    0.551  
#>  8 -2.32   -0.144  -0.121 -1.34  -0.974  2.17   0.877  -0.851  
#>  9 -1.45   -0.621  -0.255 -1.40  -1.17   1.59   0.770  -0.00738
#> 10  0.484  -1.11   -2.13   0.483  0.740  0.653 -0.512   2.27   
#> # ℹ 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.191  -0.963   1.35   1.42  -0.938 -3.24 
#>  2  0.438   1.33    0.302  0.816  1.99   0.843
#>  3  0.500  -0.873  -0.397  1.68   1.05  -2.99 
#>  4  0.0635  0.342   1.30   0.295  0.608  1.10 
#>  5  0.0171  0.0653 -0.481 -0.798 -0.599  0.616
#>  6 -0.433   0.416   1.42  -1.05  -4.55   2.18 
#>  7  0.161   1.02   -1.23  -1.49   5.14   1.04 
#>  8 -2.32   -0.144  -0.121 -1.34  -5.13  -1.14 
#>  9 -1.45   -0.621  -0.255 -1.40  -4.38  -1.02 
#> 10  0.484  -1.11   -2.13   0.483  2.86  -3.96 
#> # ℹ 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.191  -0.963   1.35   1.42   0.677  0.278
#>  2  0.438   1.33    0.302  0.816  1.27   4.12 
#>  3  0.500  -0.873  -0.397  1.68   1.13   2.12 
#>  4  0.0635  0.342   1.30   0.295 -0.367  0.436
#>  5  0.0171  0.0653 -0.481 -0.798 -1.13  -1.05 
#>  6 -0.433   0.416   1.42  -1.05   2.76  -3.41 
#>  7  0.161   1.02   -1.23  -1.49  -3.88  -4.09 
#>  8 -2.32   -0.144  -0.121 -1.34  -1.74  -2.65 
#>  9 -1.45   -0.621  -0.255 -1.40  -1.12  -2.23 
#> 10  0.484  -1.11   -2.13   0.483 -2.45  -0.498
#> # ℹ 90 more rows