NITPicker

Daphne Ezer

2018-06-27

Often, researchers will conduct a few high-resolution time course experiments (or densely sample points along a spatial axis), but then they must select a subset of points to sample in follow-up experiments due to financial constraints. NITPicker is a tool to select the best points to subsample. We present three different definitions of what constitutes a `good’ set of time points:

Please note that this is not a very fast value to compute– it may take a few hours to complete on a large dataset. The precise definition and motivation for these three criteria can be found at: https://doi.org/10.1101/301796

Please note that this package relies heavily on the fdasrvf package, which is used to generate probability distributions of curves, based on a set of example functions.

References

Please cite the following if you use this R package:

Ezer, D. and Keir J.C. Selection of time points for costly experiments: a comparison between human intuition and computer-aided experimental design. bioarxiv, :10.1101/301796 (2018).


It might also be advisable to cite this paper, which presents the fdasrvf package which is an important part of this project:

Tucker, J. D., Wu, W., Srivastava, A., Generative Models for Function Data using Phase and Amplitude Separation, Computational Statistics and Data Analysis (2012), 10.1016/j.csda.2012.12.001.

For more background on why it might be useful to minimise the L2-error for finding optimal time points to sample, please see:

Michael Kleyman, Emre Sefer, Teodora Nicola, Celia Espinoza, Divya Chhabra, James S Hagood, Naftali Kaminski, Namasivayam Ambalavanan, Ziv Bar-Joseph. Selecting the most appropriate time points to profile in high-throughput studies. eLife 2017;6:e18541 (2017).

Demo of F1

In this example, we try to find 4 months to subsample that will let us estimate the shape of the curves as accurately as possible (minimise L2-error). In this case, we sample only 3 example curves from the distribution of curves when estimating the integral– this should be much higher (100 curves is usually suitable), but we make it 3 here to speed up loading the vignette.

Note that the tables that are printed as the evaluation are the optimisation tables that are used as part of the NITPicker algorithm’s dynamic programming algorithm.

library(fda)
#> Loading required package: splines
#> Loading required package: Matrix
#> 
#> Attaching package: 'fda'
#> The following object is masked from 'package:graphics':
#> 
#>     matplot
library(NITPicker)
#> Loading required package: fdasrvf
#> Loading required package: fda.usc
#> Loading required package: MASS
#> Loading required package: mgcv
#> Loading required package: nlme
#> This is mgcv 1.8-23. For overview type 'help("mgcv-package")'.
#> Loading required package: rpart
 mat=CanadianWeather$monthlyTemp #load data - a matrix with 12 rows, representing months (time); and 35 columns, representing cities (experiments)
 a=findPathF1(c(1:12), mat, 4, numPerts=500) #find a set of points that help predict the shape of the curve
#> lambda =   0.0 
#> 
#> Initializing...
#> Computing Karcher mean of 35 functions in SRSF space...
#> updating step: r=1
#> updating step: r=2
#> updating step: r=3
#> updating step: r=4
#> updating step: r=5
#> updating step: r=6
#> updating step: r=7
#> updating step: r=8
#> updating step: r=9
#> updating step: r=10
#> updating step: r=11
#> updating step: r=12
#> updating step: r=13
#> updating step: r=14
#> updating step: r=15
#> updating step: r=16
#> updating step: r=17
#> updating step: r=18
#> [1] 12  1
#>      [,1]
#> [1,]    0
#> [2,]  Inf
#> [3,]  Inf
#> [4,]  Inf
#> [5,]  Inf
#>          [,1] [,2]
#> [1,] 94119.21  Inf
#> [2,]      Inf    0
#> [3,]      Inf  Inf
#> [4,]      Inf  Inf
#> [5,]      Inf  Inf
#>         [,1]     [,2]     [,3]
#> [1,] 7227618      Inf      Inf
#> [2,]     Inf 395438.2 94119.21
#> [3,]     Inf      Inf     0.00
#> [4,]     Inf      Inf      Inf
#> [5,]     Inf      Inf      Inf
#>          [,1]    [,2]     [,3]       [,4]
#> [1,] 54302055     Inf      Inf        Inf
#> [2,]      Inf 2759868 270921.9 7227618.08
#> [3,]      Inf     Inf 176802.6   94119.21
#> [4,]      Inf     Inf      Inf       0.00
#> [5,]      Inf     Inf      Inf        Inf
#>           [,1]    [,2]     [,3]       [,4]        [,5]
#> [1,] 162631616     Inf      Inf        Inf         Inf
#> [2,]       Inf 5511374 444956.9 7232202.59 54302054.87
#> [3,]       Inf     Inf 350837.7   98703.72   270921.86
#> [4,]       Inf     Inf      Inf    4584.51    94119.21
#> [5,]       Inf     Inf      Inf        Inf        0.00
#>           [,1]    [,2]     [,3]      [,4]        [,5]         [,6]
#> [1,] 310482479     Inf      Inf       Inf         Inf          Inf
#> [2,]       Inf 5752868 351909.8 7545230.9 54382889.07 162631616.49
#> [3,]       Inf     Inf 257790.6  411732.0   351756.05    444956.87
#> [4,]       Inf     Inf      Inf  317612.8   174953.40     98703.72
#> [5,]       Inf     Inf      Inf       Inf    80834.19      4584.51
#>           [,1]    [,2]    [,3]     [,4]     [,5]        [,6]         [,7]
#> [1,] 426724724     Inf     Inf      Inf      Inf         Inf          Inf
#> [2,]       Inf 4555736 3155093 10879139 55772283 162862863.2 310482479.10
#> [3,]       Inf     Inf 3060974  3745641  1741150    676203.5    351909.84
#> [4,]       Inf     Inf     Inf  3651521  1564347    329950.4    257790.63
#> [5,]       Inf     Inf     Inf      Inf  1470228    235831.2     98703.72
#>           [,1]     [,2]     [,3]     [,4]     [,5]      [,6]        [,7]
#> [1,] 391589760      Inf      Inf      Inf      Inf       Inf         Inf
#> [2,]       Inf 21653899 28434775 32224711 67200690 166965369 311175729.0
#> [3,]       Inf      Inf 28340656 25091213 13169557   4778709   1045159.7
#> [4,]       Inf      Inf      Inf 24997093 12992755   4432456    951040.5
#> [5,]       Inf      Inf      Inf      Inf 12898635   4338337    791953.6
#>             [,8]
#> [1,]         Inf
#> [2,] 426724724.5
#> [3,]   3155093.1
#> [4,]    351909.8
#> [5,]    257790.6
#>           [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]
#> [1,] 244781356       Inf       Inf       Inf       Inf       Inf       Inf
#> [2,]       Inf 112045310 121546437 105804433 111044479 187340235 317485475
#> [3,]       Inf       Inf 121452318  98670934  57013346  25153575   7354906
#> [4,]       Inf       Inf       Inf  98576815  56836544  24807322   7260787
#> [5,]       Inf       Inf       Inf       Inf  56742424  24713203   7101700
#>             [,8]        [,9]
#> [1,]         Inf         Inf
#> [2,] 427432129.4 391589760.3
#> [3,]   3862498.0  21653899.0
#> [4,]   1059314.8   1045159.7
#> [5,]    965195.6    351909.8
#>           [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]
#> [1,] 197005323       Inf       Inf       Inf       Inf       Inf       Inf
#> [2,]       Inf 294282876 291730500 236611435 191490147 227385872 331864344
#> [3,]       Inf       Inf 291636381 229477936 137459014  65199212  21733775
#> [4,]       Inf       Inf       Inf 229383816 137282211  64852959  21639656
#> [5,]       Inf       Inf       Inf       Inf 137188092  64758840  21480569
#>           [,8]        [,9]     [,10]
#> [1,]       Inf         Inf       Inf
#> [2,] 430019521 391678775.7 244781356
#> [3,]   6449890  21742914.5 105804433
#> [4,]   3646706   1134175.2   3862498
#> [5,]   3552587    440925.3   1045160
#>           [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]
#> [1,] 372393353       Inf       Inf       Inf       Inf       Inf       Inf
#> [2,]       Inf 577239411 544573843 428902219 311790819 289822504 356410748
#> [3,]       Inf       Inf 544479724 421768720 257759686 127635844  46280179
#> [4,]       Inf       Inf       Inf 421674601 257582883 127289591  46186059
#> [5,]       Inf       Inf       Inf       Inf 257488764 127195472  46026972
#>           [,8]      [,9]     [,10]     [,11]
#> [1,]       Inf       Inf       Inf       Inf
#> [2,] 435808921 392307481 244837631 197005323
#> [3,]  12239290  22371619 105860708 191490147
#> [4,]   9436107   1762880   3918773   6449890
#> [5,]   9341987   1069630   1101434   1134175
#>           [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]
#> [1,] 790227866       Inf       Inf       Inf       Inf       Inf       Inf
#> [2,]       Inf 900569372 826195050 638471938 440874878 355556661 381536894
#> [3,]       Inf       Inf 826100931 631338439 386843745 193370002  71406324
#> [4,]       Inf       Inf       Inf 631244320 386666942 193023749  71312205
#> [5,]       Inf       Inf       Inf       Inf 386572823 192929629  71153118
#>           [,8]      [,9]     [,10]     [,11]     [,12]
#> [1,]       Inf       Inf       Inf       Inf       Inf
#> [2,] 441375516 392797147 244847819 197015173 372393353
#> [3,]  17805885  22861286 105870896 191499997 197005323
#> [4,]  15002702   2252546   3928961   6459739  12239290
#> [5,]  14908583   1559297   1111623   1144025   1762880
#>      [,1]       [,2]      [,3]      [,4]      [,5]      [,6]      [,7]
#> [1,]    0        Inf       Inf       Inf       Inf       Inf       Inf
#> [2,]  Inf 1050478970 866032049 511769682 247411261 245398925 419493658
#> [3,]  Inf        Inf 865937930 504636183 193380128  83212266 109363089
#> [4,]  Inf        Inf       Inf 504542064 193203325  82866013 109268970
#> [5,]  Inf        Inf       Inf       Inf 193109206  82771893 109109883
#>           [,8]      [,9]     [,10]     [,11]     [,12]     [,13]
#> [1,]       Inf       Inf       Inf       Inf       Inf       Inf
#> [2,] 590258388 537181322 314503729 215989651 373458779 790227866
#> [3,] 166688756 167245461 175526806 210474475 198070750 197015173
#> [4,] 163885573 146636722  73584871  25434217  13304716  17805885
#> [5,] 163791454 145943472  70767533  20118503   2828306   2252546
#>       [,1] [,2] [,3] [,4] [,5]
#>  [1,]    0    0    0    0    0
#>  [2,]    0    1    0    0    0
#>  [3,]    0    2    2    0    0
#>  [4,]    0    2    3    3    0
#>  [5,]    0    2    3    3    4
#>  [6,]    0    2    2    5    5
#>  [7,]    0    2    6    6    6
#>  [8,]    0    1    6    7    7
#>  [9,]    0    3    7    8    8
#> [10,]    0    4    7    8    8
#> [11,]    0   10    7    8    8
#> [12,]    0   10    7    8    9
#> [13,]    0   10    5   11   12
#>               [,1]         [,2]        [,3]        [,4]       [,5]
#>  [1,]         0.00          Inf         Inf         Inf        Inf
#>  [2,]     94119.21         0.00         Inf         Inf        Inf
#>  [3,]   7227618.08     94119.21        0.00         Inf        Inf
#>  [4,]  54302054.87    270921.86    94119.21        0.00        Inf
#>  [5,] 162631616.49    444956.87    98703.72     4584.51       0.00
#>  [6,] 310482479.10    351909.84   257790.63    98703.72    4584.51
#>  [7,] 426724724.48   3155093.06   351909.84   257790.63   98703.72
#>  [8,] 391589760.30  21653899.02  1045159.73   351909.84  257790.63
#>  [9,] 244781356.33 105804433.15  3862497.98  1045159.73  351909.84
#> [10,] 197005323.27 191490147.02  6449889.52  1134175.16  440925.28
#> [11,] 372393352.54 197005323.27 12239289.74  1762880.09 1069630.21
#> [12,] 790227865.58 197015172.78 17805885.06  2252546.49 1111622.65
#> [13,]         0.00 215989650.90 83212265.80 13304716.11 2252546.49
 print(a) #indices of months to select for follow-up experiments
#> [1]  2  6  8 12
 print(rownames(CanadianWeather$monthlyTemp)[a]) #month names selected
#> [1] "Feb" "Jun" "Aug" "Dec"

Demo of F2

In this example, we consider Canadian cities to be different experimental conditions, and we consider Resolute, Canada to be the control condition. We want to find a set of points that will enable us to estimate the profile of the difference in temperature between Resolute and other cities in Canada. In this case, we sample only 3 example curves from the distribution of curves when estimating the integral– this should be much higher (100 curves is usually suitable), but we make it 3 here to speed up loading the vignette.

Note that the tables that are printed as the evaluation are the optimisation tables that are used as part of the NITPicker algorithm’s dynamic programming algorithm.

library(fda)
library(NITPicker)
mat=CanadianWeather$monthlyTemp #load data - a matrix with 12 rows, representing months (time); and 35 columns, representing cities (experiments)
 y=CanadianWeather$monthlyTemp[,"Resolute"]
a=findPathF2(c(1:12), y, mat, 4, numPerts=500) #find a set of points that help predict the shape of the curve
#> lambda =   0.0 
#> 
#> Initializing...
#> Computing Karcher mean of 35 functions in SRSF space...
#> updating step: r=1
#> updating step: r=2
#> updating step: r=3
#> updating step: r=4
#> updating step: r=5
#> updating step: r=6
#> updating step: r=7
#> updating step: r=8
#> updating step: r=9
#> updating step: r=10
#> updating step: r=11
#> updating step: r=12
#> updating step: r=13
#> updating step: r=14
#> updating step: r=15
#> updating step: r=16
#> updating step: r=17
#> updating step: r=18
#> [1] 12  1
#>      [,1]
#> [1,]    0
#> [2,]  Inf
#> [3,]  Inf
#> [4,]  Inf
#> [5,]  Inf
#>          [,1] [,2]
#> [1,] 166747.5  Inf
#> [2,]      Inf    0
#> [3,]      Inf  Inf
#> [4,]      Inf  Inf
#> [5,]      Inf  Inf
#>         [,1]     [,2]     [,3]
#> [1,] 3896413      Inf      Inf
#> [2,]     Inf 21803.31 166747.5
#> [3,]     Inf      Inf      0.0
#> [4,]     Inf      Inf      Inf
#> [5,]     Inf      Inf      Inf
#>         [,1]    [,2]     [,3]       [,4]
#> [1,] 3221102     Inf      Inf        Inf
#> [2,]     Inf 1192634 797388.2 3896413.20
#> [3,]     Inf     Inf 630640.7   21803.31
#> [4,]     Inf     Inf      Inf       0.00
#> [5,]     Inf     Inf      Inf        Inf
#>          [,1]     [,2]    [,3]    [,4]       [,5]
#> [1,] 16516905      Inf     Inf     Inf        Inf
#> [2,]      Inf 17625001 9072491 5088276 3221102.24
#> [3,]      Inf      Inf 8905744 1213666  797388.18
#> [4,]      Inf      Inf     Inf 1191863   21803.31
#> [5,]      Inf      Inf     Inf     Inf       0.00
#>          [,1]     [,2]     [,3]    [,4]       [,5]        [,6]
#> [1,] 74589747      Inf      Inf     Inf        Inf         Inf
#> [2,]      Inf 40631572 19465838 6350294 3245040.22 16516904.61
#> [3,]      Inf      Inf 19299090 2475684  821326.16  3221102.24
#> [4,]      Inf      Inf      Inf 2453881   45741.29   797388.18
#> [5,]      Inf      Inf      Inf     Inf   23937.97    21803.31
#>           [,1]     [,2]     [,3]    [,4]    [,5]     [,6]        [,7]
#> [1,] 105552558      Inf      Inf     Inf     Inf      Inf         Inf
#> [2,]       Inf 44530574 18845609 5633819 4981716 16970796 74589746.59
#> [3,]       Inf      Inf 18678862 1759209 2558002  3674994  3245040.22
#> [4,]       Inf      Inf      Inf 1737406 1782418  1251280   821326.16
#> [5,]       Inf      Inf      Inf     Inf 1760614   475695    45741.29
#>          [,1]     [,2]     [,3]     [,4]     [,5]     [,6]       [,7]
#> [1,] 79345757      Inf      Inf      Inf      Inf      Inf        Inf
#> [2,]      Inf 35136073 15167245 11610343 14990762 20650357 74964333.5
#> [3,]      Inf      Inf 15000498  7735733 12567048  7354555  3619627.1
#> [4,]      Inf      Inf      Inf  7713929 11791463  4930841  1195913.1
#> [5,]      Inf      Inf      Inf      Inf 11769659  4155256   420328.2
#>             [,8]
#> [1,]         Inf
#> [2,] 105552557.9
#> [3,]   4981716.4
#> [4,]   1759209.2
#> [5,]    821326.2
#>          [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]
#> [1,] 54139862      Inf      Inf      Inf      Inf      Inf      Inf
#> [2,]      Inf 32412714 19716015 26930568 32096174 27180841 75873330
#> [3,]      Inf      Inf 19549268 23055958 29672460 13885038  4528624
#> [4,]      Inf      Inf      Inf 23034155 28896875 11461324  2104910
#> [5,]      Inf      Inf      Inf      Inf 28875071 10685739  1329325
#>             [,8]     [,9]
#> [1,]         Inf      Inf
#> [2,] 105560987.1 79345757
#> [3,]   4990145.7 11610343
#> [4,]   1767638.5  3619627
#> [5,]    829755.4  1195913
#>          [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]
#> [1,] 42095449      Inf      Inf      Inf      Inf      Inf      Inf
#> [2,]      Inf 43458597 41901618 63156561 66617657 42422099 79581544
#> [3,]      Inf      Inf 41734871 59281952 64193943 29126297  8236838
#> [4,]      Inf      Inf      Inf 59260148 63418359 26702583  5813124
#> [5,]      Inf      Inf      Inf      Inf 63396555 25926998  5037539
#>           [,8]     [,9]    [,10]
#> [1,]       Inf      Inf      Inf
#> [2,] 106115193 79487773 54139862
#> [3,]   5544352 11752358 19716015
#> [4,]   2321844  3761642  4528624
#> [5,]   1383961  1337928  1767638
#>          [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]
#> [1,] 56439254      Inf      Inf      Inf      Inf      Inf      Inf
#> [2,]      Inf 53563786 57971766 87985589 89138500 50322728 80349975
#> [3,]      Inf      Inf 57805018 84110979 86714786 37026925  9005268
#> [4,]      Inf      Inf      Inf 84089176 85939201 34603211  6581554
#> [5,]      Inf      Inf      Inf      Inf 85917398 33827626  5805970
#>           [,8]     [,9]    [,10]    [,11]
#> [1,]       Inf      Inf      Inf      Inf
#> [2,] 105923550 79444393 54292435 42095449
#> [3,]   5352708 11708978 19868588 41901618
#> [4,]   2130201  3718263  4681197  5544352
#> [5,]   1192318  1294549  1920212  2321844
#>          [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]
#> [1,] 41358411      Inf      Inf      Inf      Inf      Inf      Inf
#> [2,]      Inf 40943793 41199224 69947404 73657089 40562669 79723102
#> [3,]      Inf      Inf 41032477 66072795 71233375 27266866  8378395
#> [4,]      Inf      Inf      Inf 66050991 70457791 24843152  5954681
#> [5,]      Inf      Inf      Inf      Inf 70435987 24067568  5179096
#>           [,8]     [,9]    [,10]    [,11]    [,12]
#> [1,]       Inf      Inf      Inf      Inf      Inf
#> [2,] 111019466 84557237 58233886 42874727 56439254
#> [3,]  10448625 16821823 23810039 42680897 42095449
#> [4,]   7226117  8831107  8622648  6323630  5352708
#> [5,]   6288234  6407393  5861663  3101123  2130201
#>      [,1]     [,2]     [,3]      [,4]      [,5]     [,6]     [,7]
#> [1,]    0      Inf      Inf       Inf       Inf      Inf      Inf
#> [2,]  Inf 41324407 62190171 146071608 135335338 41725175 93547814
#> [3,]  Inf      Inf 62023424 142196998 132911624 28429373 22203107
#> [4,]  Inf      Inf      Inf 142175194 132136039 26005659 19779393
#> [5,]  Inf      Inf      Inf       Inf 132114236 25230074 19003808
#>           [,8]     [,9]    [,10]    [,11]    [,12]    [,13]
#> [1,]       Inf      Inf      Inf      Inf      Inf      Inf
#> [2,] 137789880 99656274 63743239 42561751 56577039 41358411
#> [3,]  37219038 31920859 29319392 42367920 42233234 40562669
#> [4,]  33996531 23930144 14132000  6010654  5490494  8378395
#> [5,]  33058648 21506430 11371015  2788147  2267986  5352708
#>       [,1] [,2] [,3] [,4] [,5]
#>  [1,]    0    0    0    0    0
#>  [2,]    0    1    0    0    0
#>  [3,]    0    1    2    0    0
#>  [4,]    0    2    3    3    0
#>  [5,]    0    4    4    4    4
#>  [6,]    0    4    4    4    5
#>  [7,]    0    4    3    6    6
#>  [8,]    0    3    6    6    6
#>  [9,]    0    2    6    7    7
#> [10,]    0    2    7    7    8
#> [11,]    0   10    7    7    7
#> [12,]    0    5    6   11   11
#> [13,]    0    1    6   11   11
#>              [,1]        [,2]        [,3]       [,4]       [,5]
#>  [1,]         0.0         Inf         Inf        Inf        Inf
#>  [2,]    166747.5        0.00         Inf        Inf        Inf
#>  [3,]   3896413.2    21803.31        0.00        Inf        Inf
#>  [4,]   3221102.2   797388.18    21803.31       0.00        Inf
#>  [5,]  16516904.6  3221102.24   797388.18   21803.31       0.00
#>  [6,]  74589746.6  3245040.22   821326.16   45741.29   21803.31
#>  [7,] 105552557.9  4981716.43  1759209.21  821326.16   45741.29
#>  [8,]  79345757.5 11610342.60  3619627.14 1195913.09  420328.22
#>  [9,]  54139861.9 19716015.11  4528623.74 1767638.46  829755.42
#> [10,]  42095448.9 41901618.24  5544351.58 2321844.35 1337928.32
#> [11,]  56439254.0 42095448.88  5352708.12 2130200.89 1192317.84
#> [12,]  41358411.3 40562668.84  8378395.29 5352708.12 2130200.89
#> [13,]         0.0 41324407.30 22203107.16 5490493.53 2267986.31
print(a) #indices of months to select for follow-up experiments
#> [1]  1  3  7 11
print(rownames(CanadianWeather$monthlyTemp)[a])
#> [1] "Jan" "Mar" "Jul" "Nov"

Demo of F3

In this example, we try to identify points that can predict the shape of the curve of the difference between the temperatures of Canadian cities that are along the Atlantic with those that are Continental– however, we don’t care too much about sampling time points where there is lots of noise, so we normalise this by the variance at each point.

In this case, we sample only 3 example curves from the distribution of curves when estimating the integral– this should be much higher (100 curves is usually suitable), but we make it 3 here to speed up loading the vignette.

Note that the tables that are printed as the evaluation are the optimisation tables that are used as part of the NITPicker algorithm’s dynamic programming algorithm.

library(fda)
library(NITPicker)
#Set up data:
atlanticCities=which(CanadianWeather$region[as.character(colnames(CanadianWeather$monthlyTemp))]=="Atlantic")
 matAtlantic=CanadianWeather$monthlyTemp[, names(atlanticCities)]
 
 continentalCities=which(CanadianWeather$region[as.character(colnames(CanadianWeather$monthlyTemp))]=="Continental")
 matContinental=CanadianWeather$monthlyTemp[, names(continentalCities)]
 
 #find a set of points that helps capture the difference between Atlantic and Continental cities, normalised by the variance
 a=findPathF3(c(1:12),  matAtlantic,  matContinental, 4, numPerts=500) #find a set of points that help predict the shape of the curve
#> lambda =   0.0 
#> 
#> Initializing...
#> Computing Karcher mean of 15 functions in SRSF space...
#> updating step: r=1
#> updating step: r=2
#> updating step: r=3
#> updating step: r=4
#> updating step: r=5
#> updating step: r=6
#> updating step: r=7
#> updating step: r=8
#> updating step: r=9
#> updating step: r=10
#> updating step: r=11
#> lambda =   0.0 
#> 
#> Initializing...
#> Computing Karcher mean of 12 functions in SRSF space...
#> updating step: r=1
#> updating step: r=2
#> updating step: r=3
#> updating step: r=4
#> updating step: r=5
#> updating step: r=6
#> [1] 12  1
#>      [,1]
#> [1,]    0
#> [2,]  Inf
#> [3,]  Inf
#> [4,]  Inf
#> [5,]  Inf
#>         [,1] [,2]
#> [1,] 1805.35  Inf
#> [2,]     Inf    0
#> [3,]     Inf  Inf
#> [4,]     Inf  Inf
#> [5,]     Inf  Inf
#>          [,1]     [,2]    [,3]
#> [1,] 6055.183      Inf     Inf
#> [2,]      Inf 1692.906 1805.35
#> [3,]      Inf      Inf    0.00
#> [4,]      Inf      Inf     Inf
#> [5,]      Inf      Inf     Inf
#>          [,1]     [,2]     [,3]     [,4]
#> [1,] 93997.03      Inf      Inf      Inf
#> [2,]      Inf 1922.912 4722.562 6055.183
#> [3,]      Inf      Inf 2917.212 1692.906
#> [4,]      Inf      Inf      Inf    0.000
#> [5,]      Inf      Inf      Inf      Inf
#>          [,1]     [,2]     [,3]     [,4]      [,5]
#> [1,] 209946.7      Inf      Inf      Inf       Inf
#> [2,]      Inf 1310.847 4181.313 7135.119 93997.028
#> [3,]      Inf      Inf 2375.963 2772.841  1922.912
#> [4,]      Inf      Inf      Inf 1079.936  1692.906
#> [5,]      Inf      Inf      Inf      Inf     0.000
#>          [,1]     [,2]     [,3]     [,4]      [,5]       [,6]
#> [1,] 181418.1      Inf      Inf      Inf       Inf        Inf
#> [2,]      Inf 21761.75 13726.70 22545.43 96325.788 209946.719
#> [3,]      Inf      Inf 11921.35 18183.15  4251.671   1310.847
#> [4,]      Inf      Inf      Inf 16490.25  4021.665   1922.912
#> [5,]      Inf      Inf      Inf      Inf  2328.759   1079.936
#>          [,1]     [,2]     [,3]     [,4]      [,5]       [,6]       [,7]
#> [1,] 104971.1      Inf      Inf      Inf       Inf        Inf        Inf
#> [2,]      Inf 110548.1 65873.06 69141.66 107619.40 210587.939 181418.116
#> [3,]      Inf      Inf 64067.71 64779.38  15545.28   1952.067  13726.695
#> [4,]      Inf      Inf      Inf 63086.48  15315.27   2564.131   1310.847
#> [5,]      Inf      Inf      Inf      Inf  13622.37   1721.155   1922.912
#>          [,1]     [,2]     [,3]     [,4]      [,5]       [,6]       [,7]
#> [1,] 121147.4      Inf      Inf      Inf       Inf        Inf        Inf
#> [2,]      Inf 278635.5 168293.1 149018.4 130623.23 213341.357 181546.937
#> [3,]      Inf      Inf 166487.7 144656.1  38549.11   4705.484  13855.517
#> [4,]      Inf      Inf      Inf 142963.2  38319.11   5317.549   1439.669
#> [5,]      Inf      Inf      Inf      Inf  36626.20   4474.573   2051.733
#>            [,8]
#> [1,]        Inf
#> [2,] 104971.142
#> [3,]  65873.063
#> [4,]   1952.067
#> [5,]   1310.847
#>          [,1]     [,2]     [,3]     [,4]      [,5]      [,6]       [,7]
#> [1,] 480461.1      Inf      Inf      Inf       Inf       Inf        Inf
#> [2,]      Inf 616890.4 386154.4 312250.4 191397.61 228356.32 185097.684
#> [3,]      Inf      Inf 384349.1 307888.1  99323.50  19720.45  17406.264
#> [4,]      Inf      Inf      Inf 306195.2  99093.49  20332.51   4990.416
#> [5,]      Inf      Inf      Inf      Inf  97400.58  19489.54   5602.480
#>            [,8]       [,9]
#> [1,]        Inf        Inf
#> [2,] 105689.731 121147.444
#> [3,]  66591.653 104971.142
#> [4,]   2670.656   4705.484
#> [5,]   2029.437   1439.669
#>          [,1]     [,2]     [,3]     [,4]      [,5]      [,6]       [,7]
#> [1,] 578579.8      Inf      Inf      Inf       Inf       Inf        Inf
#> [2,]      Inf 691096.5 411397.5 321843.8 177374.00 219736.63 184888.254
#> [3,]      Inf      Inf 409592.2 317481.5  85299.88  11100.75  17196.833
#> [4,]      Inf      Inf      Inf 315788.6  85069.88  11712.82   4780.985
#> [5,]      Inf      Inf      Inf      Inf  83376.97  10869.84   5393.050
#>            [,8]       [,9]      [,10]
#> [1,]        Inf        Inf        Inf
#> [2,] 109045.224 124786.484 480461.076
#> [3,]  69947.146 108610.182 105689.731
#> [4,]   6026.149   8344.524  17406.264
#> [5,]   5384.930   5078.709   2670.656
#>         [,1]    [,2]     [,3]     [,4]     [,5]      [,6]      [,7]
#> [1,] 2042185     Inf      Inf      Inf      Inf       Inf       Inf
#> [2,]     Inf 1326369 833448.1 632931.4 309871.6 260889.56 197031.08
#> [3,]     Inf     Inf 831642.7 628569.1 217797.5  52253.69  29339.66
#> [4,]     Inf     Inf      Inf 626876.2 217567.5  52865.75  16923.81
#> [5,]     Inf     Inf      Inf      Inf 215874.6  52022.78  17535.88
#>            [,8]       [,9]     [,10]      [,11]
#> [1,]        Inf        Inf       Inf        Inf
#> [2,] 112806.301 126913.321 488376.51 578579.778
#> [3,]  73708.223 110737.018 113605.17 109045.224
#> [4,]   9787.226  10471.361  25321.70  11100.755
#> [5,]   9146.007   7205.545  10586.09   4780.985
#>         [,1]    [,2]     [,3]     [,4]     [,5]      [,6]      [,7]
#> [1,] 1331458     Inf      Inf      Inf      Inf       Inf       Inf
#> [2,]     Inf 1019380 587255.2 436436.1 207423.4 241625.43 215532.80
#> [3,]     Inf     Inf 585449.9 432073.8 115349.3  32989.56  47841.38
#> [4,]     Inf     Inf      Inf 430380.9 115119.3  33601.62  35425.54
#> [5,]     Inf     Inf      Inf      Inf 113426.4  32758.64  36037.60
#>           [,8]      [,9]     [,10]     [,11]       [,12]
#> [1,]       Inf       Inf       Inf       Inf         Inf
#> [2,] 141092.70 152294.15 495792.96 598250.69 2042184.691
#> [3,] 101994.63 136117.85 121021.62 128716.14  112806.301
#> [4,]  38073.63  35852.19  32738.15  30771.67   29339.659
#> [5,]  37432.41  32586.38  18002.54  24451.90    9787.226
#>      [,1]     [,2]     [,3]     [,4]     [,5]      [,6]     [,7]     [,8]
#> [1,]    0      Inf      Inf      Inf      Inf       Inf      Inf      Inf
#> [2,]  Inf 839090.2 412346.1 369184.8 611792.2 1021578.5 922147.8 599818.4
#> [3,]  Inf      Inf 410540.8 364822.5 519718.1  812942.6 754456.4 560720.3
#> [4,]  Inf      Inf      Inf 363129.6 519488.1  813554.7 742040.6 496799.3
#> [5,]  Inf      Inf      Inf      Inf 517795.2  812711.7 742652.6 496158.1
#>          [,9]     [,10]     [,11]      [,12]      [,13]
#> [1,]      Inf       Inf       Inf        Inf        Inf
#> [2,] 382343.3 543884.77 626678.77 2042983.32 1331458.35
#> [3,] 366167.0 169113.42 157144.22  113604.93  141092.70
#> [4,] 265901.4  80829.96  59199.75   30138.29   32989.56
#> [5,] 262635.6  66094.35  52879.98   10585.86   29339.66
#>       [,1] [,2] [,3] [,4] [,5]
#>  [1,]    0    0    0    0    0
#>  [2,]    0    1    0    0    0
#>  [3,]    0    1    2    0    0
#>  [4,]    0    1    3    3    0
#>  [5,]    0    1    4    3    4
#>  [6,]    0    2    5    5    5
#>  [7,]    0    2    5    6    5
#>  [8,]    0    7    5    6    7
#>  [9,]    0    7    6    7    8
#> [10,]    0    7    5    6    9
#> [11,]    0    7    6    7   10
#> [12,]    0    7    5   11   11
#> [13,]    0    3   11   11   11
#>              [,1]       [,2]       [,3]      [,4]      [,5]
#>  [1,]       0.000        Inf        Inf       Inf       Inf
#>  [2,]    1805.350      0.000        Inf       Inf       Inf
#>  [3,]    6055.183   1692.906      0.000       Inf       Inf
#>  [4,]   93997.028   1922.912   1692.906     0.000       Inf
#>  [5,]  209946.719   1310.847   1922.912  1079.936     0.000
#>  [6,]  181418.116  13726.695   1310.847  1922.912  1079.936
#>  [7,]  104971.142  65873.063   1952.067  1310.847  1721.155
#>  [8,]  121147.444 104971.142   4705.484  1439.669  1310.847
#>  [9,]  480461.076 105689.731  17406.264  2670.656  1439.669
#> [10,]  578579.778 109045.224  11100.755  4780.985  2670.656
#> [11,] 2042184.691 112806.301  29339.659  9787.226  4780.985
#> [12,] 1331458.352 141092.705  32989.556 29339.659  9787.226
#> [13,]       0.000 369184.768 113604.931 30138.289 10585.856
 print(a) #indices of months to select for follow-up experiments
#> [1]  1  5  7 11
 print(rownames(CanadianWeather$monthlyTemp)[a]) #month names selected
#> [1] "Jan" "May" "Jul" "Nov"