hd_umap()
runs a UMAP analysis on the provided data. If data contain missing values,
the function imputes them using the k-nearest neighbors algorithm (k = 5). The number of components
to be calculated is defined by the user. The function returns a tibble with the UMAP results.
Arguments
- dat
An HDAnalyzeR object or a dataset in wide format and sample ID as its first column.
- by_sample
If TRUE, points represent samples. If FALSE, points represent features. Default is TRUE.
- components
The number of components to be calculated. Default is 10.
- seed
The seed to be used in the UMAP analysis. Default is 123.
Examples
# Create the HDAnalyzeR object providing the data and metadata
hd_object <- hd_initialize(example_data, example_metadata)
# Run the UMAP analysis
hd_umap(hd_object, components = 2, by_sample = TRUE, seed = 123)
#> $umap_res
#> # A tibble: 586 × 3
#> DAid UMAP1 UMAP2
#> <fct> <dbl> <dbl>
#> 1 DA00001 -2.39 -0.211
#> 2 DA00002 1.42 2.15
#> 3 DA00003 -1.07 -2.34
#> 4 DA00004 -1.57 -2.31
#> 5 DA00005 -2.71 -0.450
#> 6 DA00006 1.88 -0.286
#> 7 DA00007 -2.90 -1.75
#> 8 DA00008 -0.300 1.73
#> 9 DA00009 -0.803 0.0411
#> 10 DA00010 1.03 2.13
#> # ℹ 576 more rows
#>
#> $by_sample
#> [1] TRUE
#>
#> attr(,"class")
#> [1] "hd_umap"
# Run the UMAP analysis by feature
hd_umap(hd_object, components = 2, by_sample = FALSE, seed = 123)
#> $umap_res
#> # A tibble: 100 × 3
#> Assay UMAP1 UMAP2
#> <fct> <dbl> <dbl>
#> 1 AARSD1 3.31 -2.38
#> 2 ABL1 1.52 -1.85
#> 3 ACAA1 0.238 -1.50
#> 4 ACAN -0.289 1.69
#> 5 ACE2 -0.307 -0.731
#> 6 ACOX1 -2.58 1.23
#> 7 ACP5 1.00 0.229
#> 8 ACP6 1.35 -0.122
#> 9 ACTA2 1.71 -0.962
#> 10 ACTN4 -2.06 0.455
#> # ℹ 90 more rows
#>
#> $by_sample
#> [1] FALSE
#>
#> attr(,"class")
#> [1] "hd_umap"