This function calculates the mean density of hexagonal bins based on their neighboring bins.
Arguments
- df_bin_centroids
A tibble that contains information about hexagonal bin centroids, including the hexagon ID and the standard normalized counts (
std_counts
).- bin1
The number of bins along the x-axis for the hexagonal grid.
Value
A tibble contains hexagonal IDs and the mean density of each hexagonal bin based on its neighboring bins.
Examples
r2 <- diff(range(s_curve_noise_umap$UMAP2))/diff(range(s_curve_noise_umap$UMAP1))
num_bins_x <- 4
hb_obj <- hex_binning(data = s_curve_noise_umap_scaled, bin1 = num_bins_x,
r2 = r2)
all_centroids_df <- hb_obj$centroids
counts_df <- hb_obj$std_cts
df_bin_centroids <- extract_hexbin_centroids(centroids_df = all_centroids_df,
counts_df = counts_df) |>
dplyr::filter(drop_empty == FALSE)
compute_mean_density_hex(df_bin_centroids, bin1 = num_bins_x)
#> # A tibble: 11 × 2
#> hb_id mean_density
#> <int> <dbl>
#> 1 5 0.286
#> 2 6 0.714
#> 3 9 0.690
#> 4 10 0.443
#> 5 14 0.393
#> 6 15 0.619
#> 7 19 0.357
#> 8 23 0.690
#> 9 27 0.429
#> 10 28 0.464
#> 11 31 0.643