Skip to contents

This function fits a high-dimensional model using hexagonal bins and provides options to customize the modeling process, including the choice of bin centroids or bin means, removal of low-density hexagons, and averaging of high-dimensional data.

Usage

fit_highd_model(highd_data, nldr_data, b1 = 4, q = 0.1, benchmark_highdens = 5)

Arguments

highd_data

A tibble that contains the high-dimensional data with a unique identifier.

nldr_data

A tibble that contains the embedding with a unique identifier.

b1

(default: 4) A numeric value representing the number of bins along the x axis.

q

(default: 0.1) A numeric value representing the buffer amount as proportion of data range.

benchmark_highdens

(default: 5) A numeric value using to filter high-density hexagons.

Value

A list containing a list of a tibble contains scaled first and second columns of NLDR data, and numeric vectors representing the limits of the original NLDR data (nldr_obj), a object that contains hexagonal binning information (hb_obj), a tibble with high-dimensional model (model_highd) and a tibble containing hexagonal bin centroids in 2-D (model_2d), and a tibble that contains the edge information (trimesh_data).

Examples

fit_highd_model(highd_data = scurve, nldr_data = scurve_umap, b1 = 4,
q = 0.1, benchmark_highdens = 5)
#>  Model generated successfully!!!
#> $nldr_obj
#> $nldr_obj$scaled_nldr
#> # A tibble: 1,000 × 3
#>     emb1  emb2    ID
#>    <dbl> <dbl> <int>
#>  1 0.277 0.913     1
#>  2 0.697 0.538     2
#>  3 0.779 0.399     3
#>  4 0.173 0.953     4
#>  5 0.218 0.983     5
#>  6 0.593 1.05      6
#>  7 0.180 0.210     7
#>  8 0.976 0.571     8
#>  9 0.803 0.829     9
#> 10 0.932 0.410    10
#> # ℹ 990 more rows
#> 
#> $nldr_obj$lim1
#> [1] -9.146398  8.552211
#> 
#> $nldr_obj$lim2
#> [1] -10.36686  10.10691
#> 
#> 
#> $hb_obj
#> $a1
#> [1] 0.3962013
#> 
#> $a2
#> [1] 0.3431204
#> 
#> $bins
#> [1] 4 5
#> 
#> $start_point
#> [1] -0.1000000 -0.1156801
#> 
#> $centroids
#> # A tibble: 20 × 3
#>        h     c_x    c_y
#>    <int>   <dbl>  <dbl>
#>  1     1 -0.1    -0.116
#>  2     2  0.296  -0.116
#>  3     3  0.692  -0.116
#>  4     4  1.09   -0.116
#>  5     5  0.0981  0.227
#>  6     6  0.494   0.227
#>  7     7  0.891   0.227
#>  8     8  1.29    0.227
#>  9     9 -0.1     0.571
#> 10    10  0.296   0.571
#> 11    11  0.692   0.571
#> 12    12  1.09    0.571
#> 13    13  0.0981  0.914
#> 14    14  0.494   0.914
#> 15    15  0.891   0.914
#> 16    16  1.29    0.914
#> 17    17 -0.1     1.26 
#> 18    18  0.296   1.26 
#> 19    19  0.692   1.26 
#> 20    20  1.09    1.26 
#> 
#> $hex_poly
#>      h           x            y
#> 1    1 -0.10000000  0.113066785
#> 2    1 -0.29810065 -0.001306679
#> 3    1 -0.29810065 -0.230053606
#> 4    1 -0.10000000 -0.344427070
#> 5    1  0.09810065 -0.230053606
#> 6    1  0.09810065 -0.001306679
#> 7    2  0.29620130  0.113066785
#> 8    2  0.09810065 -0.001306679
#> 9    2  0.09810065 -0.230053606
#> 10   2  0.29620130 -0.344427070
#> 11   2  0.49430195 -0.230053606
#> 12   2  0.49430195 -0.001306679
#> 13   3  0.69240260  0.113066785
#> 14   3  0.49430195 -0.001306679
#> 15   3  0.49430195 -0.230053606
#> 16   3  0.69240260 -0.344427070
#> 17   3  0.89050325 -0.230053606
#> 18   3  0.89050325 -0.001306679
#> 19   4  1.08860390  0.113066785
#> 20   4  0.89050325 -0.001306679
#> 21   4  0.89050325 -0.230053606
#> 22   4  1.08860390 -0.344427070
#> 23   4  1.28670455 -0.230053606
#> 24   4  1.28670455 -0.001306679
#> 25   5  0.09810065  0.456187177
#> 26   5 -0.10000000  0.341813713
#> 27   5 -0.10000000  0.113066785
#> 28   5  0.09810065 -0.001306679
#> 29   5  0.29620130  0.113066785
#> 30   5  0.29620130  0.341813713
#> 31   6  0.49430195  0.456187177
#> 32   6  0.29620130  0.341813713
#> 33   6  0.29620130  0.113066785
#> 34   6  0.49430195 -0.001306679
#> 35   6  0.69240260  0.113066785
#> 36   6  0.69240260  0.341813713
#> 37   7  0.89050325  0.456187177
#> 38   7  0.69240260  0.341813713
#> 39   7  0.69240260  0.113066785
#> 40   7  0.89050325 -0.001306679
#> 41   7  1.08860390  0.113066785
#> 42   7  1.08860390  0.341813713
#> 43   8  1.28670455  0.456187177
#> 44   8  1.08860390  0.341813713
#> 45   8  1.08860390  0.113066785
#> 46   8  1.28670455 -0.001306679
#> 47   8  1.48480520  0.113066785
#> 48   8  1.48480520  0.341813713
#> 49   9 -0.10000000  0.799307568
#> 50   9 -0.29810065  0.684934104
#> 51   9 -0.29810065  0.456187177
#> 52   9 -0.10000000  0.341813713
#> 53   9  0.09810065  0.456187177
#> 54   9  0.09810065  0.684934104
#> 55  10  0.29620130  0.799307568
#> 56  10  0.09810065  0.684934104
#> 57  10  0.09810065  0.456187177
#> 58  10  0.29620130  0.341813713
#> 59  10  0.49430195  0.456187177
#> 60  10  0.49430195  0.684934104
#> 61  11  0.69240260  0.799307568
#> 62  11  0.49430195  0.684934104
#> 63  11  0.49430195  0.456187177
#> 64  11  0.69240260  0.341813713
#> 65  11  0.89050325  0.456187177
#> 66  11  0.89050325  0.684934104
#> 67  12  1.08860390  0.799307568
#> 68  12  0.89050325  0.684934104
#> 69  12  0.89050325  0.456187177
#> 70  12  1.08860390  0.341813713
#> 71  12  1.28670455  0.456187177
#> 72  12  1.28670455  0.684934104
#> 73  13  0.09810065  1.142427959
#> 74  13 -0.10000000  1.028054495
#> 75  13 -0.10000000  0.799307568
#> 76  13  0.09810065  0.684934104
#> 77  13  0.29620130  0.799307568
#> 78  13  0.29620130  1.028054495
#> 79  14  0.49430195  1.142427959
#> 80  14  0.29620130  1.028054495
#> 81  14  0.29620130  0.799307568
#> 82  14  0.49430195  0.684934104
#> 83  14  0.69240260  0.799307568
#> 84  14  0.69240260  1.028054495
#> 85  15  0.89050325  1.142427959
#> 86  15  0.69240260  1.028054495
#> 87  15  0.69240260  0.799307568
#> 88  15  0.89050325  0.684934104
#> 89  15  1.08860390  0.799307568
#> 90  15  1.08860390  1.028054495
#> 91  16  1.28670455  1.142427959
#> 92  16  1.08860390  1.028054495
#> 93  16  1.08860390  0.799307568
#> 94  16  1.28670455  0.684934104
#> 95  16  1.48480520  0.799307568
#> 96  16  1.48480520  1.028054495
#> 97  17 -0.10000000  1.485548350
#> 98  17 -0.29810065  1.371174887
#> 99  17 -0.29810065  1.142427959
#> 100 17 -0.10000000  1.028054495
#> 101 17  0.09810065  1.142427959
#> 102 17  0.09810065  1.371174887
#> 103 18  0.29620130  1.485548350
#> 104 18  0.09810065  1.371174887
#> 105 18  0.09810065  1.142427959
#> 106 18  0.29620130  1.028054495
#> 107 18  0.49430195  1.142427959
#> 108 18  0.49430195  1.371174887
#> 109 19  0.69240260  1.485548350
#> 110 19  0.49430195  1.371174887
#> 111 19  0.49430195  1.142427959
#> 112 19  0.69240260  1.028054495
#> 113 19  0.89050325  1.142427959
#> 114 19  0.89050325  1.371174887
#> 115 20  1.08860390  1.485548350
#> 116 20  0.89050325  1.371174887
#> 117 20  0.89050325  1.142427959
#> 118 20  1.08860390  1.028054495
#> 119 20  1.28670455  1.142427959
#> 120 20  1.28670455  1.371174887
#> 
#> $data_hb_id
#> # A tibble: 1,000 × 4
#>     emb1  emb2    ID     h
#>    <dbl> <dbl> <int> <int>
#>  1 0.277 0.913     1    13
#>  2 0.697 0.538     2    11
#>  3 0.779 0.399     3    11
#>  4 0.173 0.953     4    13
#>  5 0.218 0.983     5    13
#>  6 0.593 1.05      6    14
#>  7 0.180 0.210     7     5
#>  8 0.976 0.571     8    12
#>  9 0.803 0.829     9    15
#> 10 0.932 0.410    10     7
#> # ℹ 990 more rows
#> 
#> $std_cts
#> # A tibble: 13 × 3
#>        h   n_h   w_h
#>    <int> <int> <dbl>
#>  1     2    30 0.03 
#>  2     3    14 0.014
#>  3     5    75 0.075
#>  4     6   137 0.137
#>  5     7   132 0.132
#>  6    10    12 0.012
#>  7    11   132 0.132
#>  8    12    37 0.037
#>  9    13   140 0.14 
#> 10    14   176 0.176
#> 11    15    67 0.067
#> 12    17     4 0.004
#> 13    18    44 0.044
#> 
#> $b
#> [1] 20
#> 
#> $m
#> [1] 13
#> 
#> $pts_bins
#> # A tibble: 13 × 2
#>        h pts_list   
#>    <int> <list>     
#>  1     2 <int [30]> 
#>  2     3 <int [14]> 
#>  3     5 <int [75]> 
#>  4     6 <int [137]>
#>  5     7 <int [132]>
#>  6    10 <int [12]> 
#>  7    11 <int [132]>
#>  8    12 <int [37]> 
#>  9    13 <int [140]>
#> 10    14 <int [176]>
#> 11    15 <int [67]> 
#> 12    17 <int [4]>  
#> 13    18 <int [44]> 
#> 
#> attr(,"class")
#> [1] "hex_bin_obj"
#> 
#> $model_highd
#> # A tibble: 12 × 8
#>        h     x1    x2      x3        x4        x5       x6         x7
#>    <int>  <dbl> <dbl>   <dbl>     <dbl>     <dbl>    <dbl>      <dbl>
#>  1     2  0.621 0.145  1.73    0.000811  0.00129  -0.0148  -0.00142  
#>  2     3 -0.472 1.60   1.87   -0.00204   0.00591   0.0136   0.00319  
#>  3     5  0.874 1.07   1.42   -0.00307   0.00218  -0.00370  0.000263 
#>  4     6 -0.185 0.655  1.82   -0.00151   0.00135   0.00135  0.00123  
#>  5     7 -0.890 1.29   1.04    0.000368  0.000266  0.00151  0.000278 
#>  6    10  0.279 0.713 -0.722   0.00382  -0.00440  -0.0265   0.00181  
#>  7    11  0.145 0.537 -0.0960 -0.000434  0.000514  0.00394  0.000941 
#>  8    12 -0.132 1.68   0.0457  0.00109  -0.000500 -0.0108  -0.00110  
#>  9    13 -0.686 0.824 -1.57    0.000626 -0.000342  0.00253  0.000273 
#> 10    14  0.620 1.02  -1.63   -0.000149 -0.000135 -0.00418 -0.000195 
#> 11    15  0.833 1.54  -0.553   0.000130  0.000263  0.00686  0.0000105
#> 12    18 -0.345 1.77  -1.85    0.00135   0.00260  -0.0106   0.000976 
#> 
#> $model_2d
#>     h        c_x        c_y n_h   w_h
#> 1   2 0.29620130 -0.1156801  30 0.030
#> 2   3 0.69240260 -0.1156801  14 0.014
#> 3   5 0.09810065  0.2274402  75 0.075
#> 4   6 0.49430195  0.2274402 137 0.137
#> 5   7 0.89050325  0.2274402 132 0.132
#> 6  10 0.29620130  0.5705606  12 0.012
#> 7  11 0.69240260  0.5705606 132 0.132
#> 8  12 1.08860390  0.5705606  37 0.037
#> 9  13 0.09810065  0.9136810 140 0.140
#> 10 14 0.49430195  0.9136810 176 0.176
#> 11 15 0.89050325  0.9136810  67 0.067
#> 12 18 0.29620130  1.2568014  44 0.044
#> 
#> $trimesh_data
#> # A tibble: 23 × 8
#>     from    to x_from y_from  x_to  y_to from_count to_count
#>    <int> <int>  <dbl>  <dbl> <dbl> <dbl>      <dbl>    <dbl>
#>  1     3     4 0.0981  0.227 0.494 0.227         75      137
#>  2     3     6 0.0981  0.227 0.296 0.571         75       12
#>  3     2     4 0.692  -0.116 0.494 0.227         14      137
#>  4     4     5 0.494   0.227 0.891 0.227        137      132
#>  5     4     7 0.494   0.227 0.692 0.571        137      132
#>  6     6    10 0.296   0.571 0.494 0.914         12      176
#>  7     6     7 0.296   0.571 0.692 0.571         12      132
#>  8     7     8 0.692   0.571 1.09  0.571        132       37
#>  9     7    11 0.692   0.571 0.891 0.914        132       67
#> 10     9    12 0.0981  0.914 0.296 1.26         140       44
#> # ℹ 13 more rows
#>