Extract hexagonal bin mean and related information from non-linear dimensionality reduction data.
Source:R/2D.R
extract_hexbin_mean.Rd
Extract hexagonal bin mean and related information from non-linear dimensionality reduction data.
Arguments
- nldr_df
A data frame containing 2D embeddings.
- num_bins
Number of bins along the x-axis for hexagon binning.
- shape_val
The value of the shape parameter for hexagon binning.
- x
The name of the column that contains first 2D embeddings component.
- y
The name of the column that contains second 2D embeddings component.
Examples
# Example usage of extract_hexbin_mean function
num_bins_x <- 4
shape_value <- 1.833091
result <- extract_hexbin_mean(nldr_df = s_curve_noise_umap,
num_bins = num_bins_x, shape_val = shape_value, x = "UMAP1", y = "UMAP2")
hexdf_data <- result$hexdf_data
hb_data <- result$hb_data
print(hexdf_data)
#> # A tibble: 16 × 5
#> hexID x y counts std_counts
#> <int> <dbl> <dbl> <int> <dbl>
#> 1 1 -2.71 -5.38 2 0.222
#> 2 2 -2.21 -5.52 6 0.667
#> 3 6 -2.82 -4.20 7 0.778
#> 4 7 -1.44 -4.32 5 0.556
#> 5 11 -3.03 -3.66 2 0.222
#> 6 12 -2.13 -3.48 2 0.222
#> 7 13 -0.831 -2.83 2 0.222
#> 8 17 -0.431 -1.70 1 0.111
#> 9 18 0.222 -1.45 8 0.889
#> 10 24 0.973 -0.107 7 0.778
#> 11 28 0.863 0.619 1 0.111
#> 12 29 1.38 0.943 6 0.667
#> 13 38 0.662 4.13 2 0.222
#> 14 39 1.64 3.95 8 0.889
#> 15 44 1.14 5.36 9 1
#> 16 45 2.23 4.93 7 0.778
print(str(hb_data))
#> Formal class 'hexbin' [package "hexbin"] with 16 slots
#> ..@ cell : int [1:16] 1 2 6 7 11 12 13 17 18 24 ...
#> ..@ count : int [1:16] 2 6 7 5 2 2 2 1 8 7 ...
#> ..@ xcm : num [1:16] -2.71 -2.21 -2.82 -1.44 -3.03 ...
#> ..@ ycm : num [1:16] -5.38 -5.52 -4.2 -4.32 -3.66 ...
#> ..@ xbins : num 4
#> ..@ shape : num 1.83
#> ..@ xbnds : num [1:2] -3.27 2.46
#> ..@ ybnds : num [1:2] -5.74 5.82
#> ..@ dimen : num [1:2] 10 5
#> ..@ n : int 75
#> ..@ ncells: int 16
#> ..@ call : language hexbin::hexbin(x = dplyr::pull(nldr_df, { { ...
#> ..@ xlab : chr [1:5] "dplyr::pull(nldr_df, {" " {" " x" " }" ...
#> ..@ ylab : chr [1:5] "dplyr::pull(nldr_df, {" " {" " y" " }" ...
#> ..@ cID : int [1:75] 6 24 29 2 12 44 24 18 24 45 ...
#> ..@ cAtt : int(0)
#> NULL