Skip to contents

Perform MDS on landmarks and project other samples to the same space

Usage

cmdscale_landmarks(dist_2lm, ndim = 3, rescale = TRUE, ...)

Arguments

dist_2lm

Distance matrix between the landmarks and all the samples in original dataset

ndim

The number of dimensions

rescale

Whether or not to rescale the final dimensionality reduction (recommended)

...

Extra params to pass to irlba::irlba()

Value

The dimensionality reduction in the form of a ncol(dist_2lm) by ndim matrix.

Examples

library(Matrix)
x <- as.matrix(iris[,1:4])
dist_2lm <- select_landmarks(x)
cmdscale_landmarks(dist_2lm)
#>              comp_1        comp_2        comp_3
#>   [1,]  0.473359424 -0.2922093333 -0.0640003077
#>   [2,]  0.466358746 -0.1283034109 -0.1325293883
#>   [3,]  0.486851868 -0.1535696609 -0.0711751030
#>   [4,]  0.466539086 -0.0925032554 -0.0785005380
#>   [5,]  0.476306551 -0.2965779590 -0.0332132984
#>   [6,]  0.400364944 -0.3537197289 -0.0164391968
#>   [7,]  0.477368634 -0.1694108709 -0.0185551195
#>   [8,]  0.468675162 -0.2391863999 -0.0716316305
#>   [9,]  0.462463686 -0.0366447458 -0.0855970153
#>  [10,]  0.465347253 -0.1451496777 -0.1248861946
#>  [11,]  0.438975281 -0.3610126436 -0.0643282244
#>  [12,]  0.462101471 -0.1879863429 -0.0483531261
#>  [13,]  0.471657925 -0.1165157800 -0.1270154539
#>  [14,]  0.486894428 -0.0809998623 -0.0654815344
#>  [15,]  0.417000399 -0.4396400237 -0.0652601879
#>  [16,]  0.375851204 -0.4417884598  0.0094811562
#>  [17,]  0.440268671 -0.3972562285 -0.0174718234
#>  [18,]  0.469224572 -0.2882686556 -0.0552062590
#>  [19,]  0.380490464 -0.3603541855 -0.0779014539
#>  [20,]  0.452475373 -0.3373714909 -0.0013276477
#>  [21,]  0.415233303 -0.2631075069 -0.1193523379
#>  [22,]  0.450285933 -0.3132441067 -0.0096424682
#>  [23,]  0.500000000 -0.2451055959 -0.0008539023
#>  [24,]  0.418536940 -0.1813966014 -0.0755357491
#>  [25,]  0.418773887 -0.1423847005 -0.0515191472
#>  [26,]  0.441306674 -0.1199483710 -0.1447589161
#>  [27,]  0.446608365 -0.2151074142 -0.0532633904
#>  [28,]  0.457711969 -0.2966924267 -0.0766734552
#>  [29,]  0.465988788 -0.2818831616 -0.0951459282
#>  [30,]  0.459422191 -0.1204564021 -0.0741681567
#>  [31,]  0.454489377 -0.1125314756 -0.1051880004
#>  [32,]  0.429176403 -0.2819685621 -0.1013679258
#>  [33,]  0.438228692 -0.3908167618  0.0090839750
#>  [34,]  0.419779175 -0.4374548398 -0.0039782625
#>  [35,]  0.463138255 -0.1412586668 -0.1180315833
#>  [36,]  0.484508928 -0.2144747089 -0.1050360854
#>  [37,]  0.447299245 -0.3417821243 -0.1093028482
#>  [38,]  0.480749469 -0.2782116369 -0.0315223893
#>  [39,]  0.475489376 -0.0660873260 -0.0692987426
#>  [40,]  0.463692299 -0.2565610278 -0.0838401446
#>  [41,]  0.480516708 -0.2780831379 -0.0436984954
#>  [42,]  0.423299973  0.0421590451 -0.1648009287
#>  [43,]  0.482296432 -0.1069774721 -0.0387332859
#>  [44,]  0.429762556 -0.2210802043 -0.0192380583
#>  [45,]  0.394228189 -0.2629951965  0.0003202315
#>  [46,]  0.464875674 -0.1083943016 -0.1121312506
#>  [47,]  0.445541014 -0.3281070185 -0.0102038396
#>  [48,]  0.479273824 -0.1261725336 -0.0599714025
#>  [49,]  0.447434401 -0.3518450402 -0.0515632304
#>  [50,]  0.475888132 -0.2235096750 -0.0908095108
#>  [51,] -0.290504286 -0.0706778370 -0.2058607924
#>  [52,] -0.245170277  0.0858688379 -0.0882571638
#>  [53,] -0.326170643 -0.0457878350 -0.1649785583
#>  [54,] -0.089956575  0.4417884598 -0.1923704122
#>  [55,] -0.272563383  0.1355917175 -0.1929418096
#>  [56,] -0.187009029  0.3459381556 -0.0621947794
#>  [57,] -0.274342078  0.0817408455  0.0221043664
#>  [58,]  0.093009555  0.3785801930 -0.1516126812
#>  [59,] -0.261149656  0.0891654991 -0.2437123012
#>  [60,] -0.053464757  0.4077190807 -0.0462432699
#>  [61,]  0.044859438  0.4345629794 -0.2110584871
#>  [62,] -0.165179804  0.2641966395 -0.0550123675
#>  [63,] -0.104114120  0.3451223466 -0.3505653870
#>  [64,] -0.256578747  0.2259276461 -0.0799189621
#>  [65,] -0.021087473  0.2922036276 -0.1269790494
#>  [66,] -0.237842593  0.0307270118 -0.2126855700
#>  [67,] -0.190258441  0.3199990356  0.0608207896
#>  [68,] -0.105446167  0.3335689877 -0.2308629976
#>  [69,] -0.232332110  0.3096031932 -0.2472141434
#>  [70,] -0.065159275  0.3982682263 -0.2315123905
#>  [71,] -0.275347147  0.1913072542  0.1767349840
#>  [72,] -0.132252122  0.2529401661 -0.2178943678
#>  [73,] -0.302766221  0.2269313668 -0.1577893375
#>  [74,] -0.240463185  0.2419124456 -0.1582203554
#>  [75,] -0.202665786  0.1550592991 -0.2340516560
#>  [76,] -0.235678862  0.0760416782 -0.2195708073
#>  [77,] -0.305470660  0.0422297729 -0.2455480599
#>  [78,] -0.349621355  0.0107357253 -0.0663951403
#>  [79,] -0.225312259  0.2604301289 -0.0557137477
#>  [80,]  0.007113099  0.3075023223 -0.2564719364
#>  [81,] -0.041159735  0.4141129538 -0.2340447527
#>  [82,] -0.016513522  0.3952701441 -0.2529475505
#>  [83,] -0.086168159  0.3353149721 -0.2119507558
#>  [84,] -0.317464611  0.2517482335  0.0272958001
#>  [85,] -0.171962273  0.3445099331  0.0928271481
#>  [86,] -0.218840201  0.1399606924  0.0804281238
#>  [87,] -0.292419061  0.0154584510 -0.1558364117
#>  [88,] -0.211040899  0.2784762815 -0.3100078709
#>  [89,] -0.109331579  0.3198524534 -0.0545031184
#>  [90,] -0.089348091  0.4248049695 -0.1584833086
#>  [91,] -0.147437514  0.4087427842 -0.1039953098
#>  [92,] -0.239889255  0.2096090698 -0.0719439039
#>  [93,] -0.104719483  0.3598187400 -0.2254018559
#>  [94,]  0.084408306  0.3881299156 -0.1814468747
#>  [95,] -0.130359963  0.3883183337 -0.1100705350
#>  [96,] -0.127121878  0.3040518973 -0.0853593074
#>  [97,] -0.136528819  0.3314039423 -0.0843592629
#>  [98,] -0.190768644  0.2114673391 -0.1912229556
#>  [99,]  0.126995154  0.3028066233 -0.1582869357
#> [100,] -0.120429826  0.3504435740 -0.1230505581
#> [101,] -0.437421160 -0.0615049893  0.3271076287
#> [102,] -0.316814480  0.2825889356  0.1649854825
#> [103,] -0.462395158 -0.1768623780 -0.0003117653
#> [104,] -0.401027534  0.0729132215  0.1169909090
#> [105,] -0.441359877 -0.0355900218  0.2062129874
#> [106,] -0.492651960 -0.2843873847 -0.1426145866
#> [107,] -0.142298307  0.4408646426  0.0998570110
#> [108,] -0.472150340 -0.2113406312 -0.1455365719
#> [109,] -0.427865340  0.0149282752 -0.0646046990
#> [110,] -0.463218229 -0.2764987978  0.1346201438
#> [111,] -0.365412499  0.0075508853  0.1450980033
#> [112,] -0.383172444  0.1129004010  0.0525931870
#> [113,] -0.427664736 -0.0770262548  0.0947337428
#> [114,] -0.296978162  0.3263426526  0.1392033681
#> [115,] -0.329374652  0.2163148498  0.2819003308
#> [116,] -0.391108088  0.0001642629  0.2748307654
#> [117,] -0.403780482  0.0146065213  0.0869520253
#> [118,] -0.476364883 -0.3698844621 -0.0168729203
#> [119,] -0.500000000 -0.2447632697 -0.1697351404
#> [120,] -0.287676317  0.3200394291 -0.1311408928
#> [121,] -0.447438546 -0.1542023983  0.1561650086
#> [122,] -0.277184292  0.3086019879  0.2121095526
#> [123,] -0.491396988 -0.2687008497 -0.1978533219
#> [124,] -0.324490094  0.1863101643 -0.0154384064
#> [125,] -0.434660856 -0.1180534134  0.1845655819
#> [126,] -0.453996168 -0.2191141838 -0.0653092240
#> [127,] -0.304709339  0.2030369622  0.0187567603
#> [128,] -0.310363878  0.1822982987  0.1132339397
#> [129,] -0.419271331  0.0495690181  0.1588752205
#> [130,] -0.431753231 -0.1670096679 -0.1430693041
#> [131,] -0.466936082 -0.2070537442 -0.1626068273
#> [132,] -0.457806978 -0.3857181588 -0.0732911702
#> [133,] -0.421398202  0.0438625725  0.1830682522
#> [134,] -0.331681824  0.1587851938 -0.0574576841
#> [135,] -0.358044801  0.1776598229 -0.0266526119
#> [136,] -0.474140511 -0.2821198642 -0.1138917140
#> [137,] -0.407500710 -0.0403261062  0.3505653870
#> [138,] -0.396723090  0.0227688586  0.1322742985
#> [139,] -0.288515067  0.2140749136  0.1198294112
#> [140,] -0.418437991 -0.1069663938  0.0776066433
#> [141,] -0.436687480 -0.0883571604  0.2188980897
#> [142,] -0.387501144 -0.0835663807  0.0947707775
#> [143,] -0.316814480  0.2825889356  0.1649854825
#> [144,] -0.458160663 -0.1477061676  0.1788376617
#> [145,] -0.439487931 -0.1268956237  0.2640607443
#> [146,] -0.396500557 -0.0306155024  0.1456111567
#> [147,] -0.338255709  0.2027585219 -0.0162399538
#> [148,] -0.382127549  0.0354052550  0.1207049190
#> [149,] -0.381395406  0.0045703082  0.3429442891
#> [150,] -0.319595525  0.2112429672  0.1842294510
#> attr(,"addend")
#> [1]  0.002413973 -0.230949559 -0.046005043
#> attr(,"multiplier")
#> [1] 1.038658