Collects a set of principal variables, reducing the number of not important variables to analyse. Dimensionality reduction makes data analysis algorithms work faster and sometimes more accurate, since it also reduces noise in the data. Currently available methods are:
- immunr_pca performs PCA (Principal Component Analysis) using prcomp;
- immunr_mds performs MDS (Multi-Dimensional Scaling) using isoMDS;
- immunr_tsne performs tSNE (t-Distributed Stochastic Neighbour Embedding) using Rtsne.
immunr_pca(.data, .scale = default_scale_fun, .raw = TRUE, .orig = FALSE, .dist = FALSE)
immunr_mds(.data, .scale = default_scale_fun, .raw = TRUE, .orig = FALSE, .dist = TRUE)
immunr_tsne(.data, .perp = 1, .dist = TRUE, ...)A matrix or a data frame with features, distance matrix or output from repOverlapAnalysis or geneUsageAnalysis functions.
A function to apply to your data before passing it to any of dimensionality reduction algorithms. There is no scaling by default.
If TRUE then returns the non-processed output from dimensionality reduction algorithms. Pass FALSE if you want to visualise results.
If TRUE then returns the original result from algorithms. Pass FALSE if you want to visualise results.
If TRUE then assumes that ".data" is a distance matrix.
The perplexity parameter for Rtsne. Sepcifies the number of neighbours each data point must have in the resulting plot.
Other parameters passed to Rtsne.
immunr_pca - an output from prcomp.
immunr_mds - an output from isoMDS.
immunr_tsne - an output from Rtsne.
vis.immunr_pca for visualisations.
data(immdata)
gu <- geneUsage(immdata$data)
gu[is.na(gu)] <- 0
gu <- t(as.matrix(gu[, -1]))
immunr_pca(gu)
#> Standard deviations (1, .., p=12):
#> [1] 3.631709e+00 3.196007e+00 2.328286e+00 2.069586e+00 1.827896e+00
#> [6] 1.740118e+00 1.568858e+00 1.493067e+00 1.305664e+00 1.128147e+00
#> [11] 9.245962e-01 8.041748e-16
#>
#> Rotation (n x k) = (48 x 12):
#> PC1 PC2 PC3 PC4 PC5
#> [1,] -0.034197200 0.11890907 0.102184229 0.337051326 -0.0004301153
#> [2,] -0.155248223 0.11008628 0.021300422 0.291138092 -0.0173125004
#> [3,] 0.004603059 0.20559263 -0.003966471 0.274392673 0.0172462689
#> [4,] -0.106659451 0.02605975 0.011764270 -0.184827051 0.1226537330
#> [5,] -0.194298480 -0.06192070 0.123874384 0.073143661 -0.0055155674
#> [6,] -0.113234991 0.19657020 0.160696491 -0.118967005 -0.0575552712
#> [7,] -0.082192204 0.23622040 -0.080015472 -0.052899601 -0.0610220259
#> [8,] -0.208282703 -0.00934285 0.162923919 0.202218062 -0.1483661863
#> [9,] -0.078954728 -0.03391247 0.359203719 -0.127120646 -0.1395922858
#> [10,] -0.191930050 -0.16219529 -0.084691508 -0.024054324 -0.1849452986
#> [11,] -0.152505875 -0.04980929 -0.247684603 0.046522764 0.1468102443
#> [12,] -0.165927455 -0.14910574 -0.007460287 -0.009361819 -0.1037193678
#> [13,] -0.197238571 -0.14092741 -0.196981539 -0.102933513 -0.0282308465
#> [14,] -0.240584196 -0.09132669 0.010327042 0.023104605 -0.0502359710
#> [15,] -0.165219817 -0.15404537 0.005739252 0.014257446 -0.2389551124
#> [16,] -0.114634773 0.07792101 -0.197642527 -0.187447307 0.1749548997
#> [17,] -0.155689426 -0.17284156 0.057060626 0.079007789 -0.1737856510
#> [18,] -0.208218229 -0.14451935 0.057385627 -0.062227359 0.1011160269
#> [19,] -0.181580347 0.18955418 0.059724679 -0.112818571 -0.0060219817
#> [20,] 0.041862783 -0.14158279 0.144624202 0.104936410 -0.0315577460
#> [21,] -0.097965157 -0.01772842 0.149451614 -0.059293710 0.1649176565
#> [22,] -0.073386264 -0.13418787 -0.130515262 -0.341396032 -0.1559850687
#> [23,] 0.139899167 -0.04242638 -0.074978403 -0.153782907 -0.0820752523
#> [24,] -0.205692335 -0.06335076 -0.016733441 -0.012167606 -0.2939825011
#> [25,] -0.226468715 -0.04650661 -0.136630831 0.184443991 0.0124607890
#> [26,] 0.038602294 0.23913527 -0.075899112 -0.089254172 -0.0983536527
#> [27,] 0.146885100 0.17122790 0.169784936 0.006672227 -0.1419677821
#> [28,] 0.034325881 -0.16369356 0.293971329 -0.103848193 0.1878421051
#> [29,] -0.127892072 0.13388180 -0.294341738 -0.080524763 -0.1158748998
#> [30,] -0.201607244 0.11725295 -0.057250012 -0.019838145 0.2003669007
#> [31,] -0.184930241 0.16227623 -0.065425153 0.037318195 -0.0182216760
#> [32,] -0.145911482 0.19175409 -0.089582485 -0.179452972 0.1676860582
#> [33,] -0.133991554 0.06711262 0.028801844 -0.095990401 0.1727953547
#> [34,] -0.167035806 0.15627000 -0.139771958 0.022285556 -0.0711360357
#> [35,] 0.001412424 -0.15662225 0.097523974 0.014091955 0.3272087656
#> [36,] 0.007755805 0.21914810 0.135040644 0.056013215 0.1094407346
#> [37,] 0.005746089 0.28174909 -0.004299562 0.055997067 0.1628696250
#> [38,] -0.223061162 0.05040923 0.099001337 0.101459231 -0.0168676342
#> [39,] -0.073271189 -0.07548116 -0.053677826 0.335197220 -0.0131411323
#> [40,] -0.177140198 -0.12201183 -0.020534882 -0.013653015 0.2344136065
#> [41,] 0.060517256 -0.22462044 0.036407759 -0.064705029 0.2777855319
#> [42,] -0.046744945 0.22497912 0.150993106 -0.242426201 -0.0494681285
#> [43,] -0.085774244 -0.06156615 -0.011068747 0.227618069 0.2881524371
#> [44,] -0.132250623 0.21184401 0.113960219 -0.014649068 0.0299373411
#> [45,] -0.111848882 0.14219526 0.283997094 -0.052528580 -0.0196511677
#> [46,] -0.204599932 -0.01770538 0.037122868 -0.034849500 0.1921021566
#> [47,] -0.197098008 -0.06732129 0.116430020 -0.163910463 0.0432799854
#> [48,] -0.089243222 -0.04855577 0.356331250 -0.087638436 -0.0787965670
#> PC6 PC7 PC8 PC9 PC10
#> [1,] 0.142386718 -0.151877197 0.051279946 0.277181770 0.09224779
#> [2,] -0.050631264 -0.130124854 -0.009219081 0.287315825 0.02803594
#> [3,] 0.086325320 0.283575115 -0.048178960 0.061738323 0.05335362
#> [4,] 0.389598515 0.235198510 -0.013002330 0.010982048 -0.06528658
#> [5,] 0.185967618 -0.203174854 -0.010609296 0.188823645 -0.25639570
#> [6,] -0.218883504 0.128127850 0.053380945 0.122514367 -0.03503720
#> [7,] -0.084562652 0.136453287 -0.043693514 -0.092112099 -0.29378370
#> [8,] -0.007366248 -0.006609190 0.076418904 -0.015250171 -0.12470211
#> [9,] -0.084329667 0.042760997 0.036409479 -0.066474085 0.09309295
#> [10,] -0.069865576 0.012381579 0.175000013 0.019946758 0.02963299
#> [11,] -0.178923866 -0.203762032 0.079013141 0.067812826 0.16090448
#> [12,] 0.294171911 0.100728812 0.150188313 0.114718591 0.10187435
#> [13,] 0.028600084 -0.011933867 -0.078817280 0.014726114 -0.05360435
#> [14,] -0.024767574 -0.062164763 0.175971843 0.139855274 0.14353321
#> [15,] 0.071317213 0.015379520 -0.131631052 0.106793612 -0.32143421
#> [16,] -0.030386374 0.196042896 0.154111097 0.126474451 0.04112697
#> [17,] -0.185663594 0.185377054 -0.031631898 0.033940649 0.16609262
#> [18,] 0.020983856 0.111586597 -0.084484212 -0.039164284 0.17936940
#> [19,] 0.187315236 -0.015703738 -0.082856657 -0.005095490 0.03041171
#> [20,] -0.035017333 0.441690612 0.072936668 0.167250470 -0.19356319
#> [21,] 0.206072629 0.016169702 0.364358502 0.271985574 0.16438248
#> [22,] 0.010871152 -0.016459377 -0.042638878 0.117250879 0.15067276
#> [23,] -0.250972243 0.170494651 -0.083475059 0.370451931 0.15768065
#> [24,] -0.021286780 0.074501088 0.053933549 -0.090407150 -0.23927387
#> [25,] 0.029704703 0.097278451 -0.042214455 -0.025655357 0.01115750
#> [26,] 0.100219887 0.136287771 0.259942480 0.006301798 -0.11829694
#> [27,] -0.076310438 0.080300555 0.184854167 -0.095281482 0.03617765
#> [28,] -0.113021696 -0.040027724 -0.023615337 0.012435093 -0.08701607
#> [29,] -0.064635792 -0.086670605 -0.032900688 0.090565446 -0.03480849
#> [30,] 0.185625975 -0.130341774 -0.059905140 -0.078532860 -0.04447787
#> [31,] -0.166956950 -0.140499619 -0.193371508 0.076975707 -0.10489929
#> [32,] -0.029645000 0.039776434 0.164287288 -0.011584965 0.01741600
#> [33,] -0.184274622 -0.206171353 0.336405609 -0.072288308 -0.20670453
#> [34,] -0.190180391 0.150738874 0.143230215 -0.061805280 -0.11638330
#> [35,] -0.151910454 0.002663285 -0.205645184 0.267333459 -0.19536855
#> [36,] -0.082351092 0.260502660 -0.138163988 0.253605649 0.04659994
#> [37,] -0.044178724 -0.003435601 0.078014263 0.171187829 -0.11200939
#> [38,] 0.039224233 -0.046575478 -0.296564925 -0.023272662 0.07210496
#> [39,] -0.268712403 0.064528409 0.134447485 -0.181425038 0.19277506
#> [40,] 0.130695710 0.203005428 -0.056911238 -0.120552120 0.20572195
#> [41,] -0.112572782 -0.064714173 0.074458390 0.089035015 -0.24542963
#> [42,] -0.041649429 -0.002199646 -0.156874250 -0.045043644 0.05540021
#> [43,] 0.032334017 0.201862147 0.045786575 -0.360586880 -0.15750794
#> [44,] 0.029628552 0.021753289 -0.241767380 -0.161688387 0.19389642
#> [45,] -0.046156529 -0.232529249 0.029618047 -0.053678888 0.14919733
#> [46,] -0.289427852 0.065624366 0.049916834 -0.103190649 0.12751054
#> [47,] -0.145121248 0.070248141 -0.243792189 -0.008071605 -0.11796392
#> [48,] -0.005231829 -0.054677128 0.207963042 -0.107409381 -0.03158828
#> PC11 PC12
#> [1,] 0.190820049 0.09594784
#> [2,] -0.023088305 -0.13116892
#> [3,] 0.100415596 0.28401876
#> [4,] 0.226634993 0.03832547
#> [5,] 0.081591915 -0.13245422
#> [6,] -0.080522841 -0.10307857
#> [7,] -0.316709028 0.14566994
#> [8,] -0.031806383 -0.04365363
#> [9,] -0.170024384 -0.02485409
#> [10,] 0.073022890 0.24040560
#> [11,] -0.016011425 -0.17913847
#> [12,] -0.016123920 -0.26999375
#> [13,] 0.076040036 -0.04300064
#> [14,] -0.012663650 0.04863983
#> [15,] 0.015148152 0.28308109
#> [16,] -0.375250816 -0.06156446
#> [17,] 0.043150670 -0.01455138
#> [18,] 0.253158533 0.14911533
#> [19,] -0.029920269 -0.05665791
#> [20,] -0.141556297 -0.31469647
#> [21,] -0.259382191 0.11979051
#> [22,] 0.131521069 0.04346743
#> [23,] 0.173716601 0.04998030
#> [24,] -0.045116629 0.13033618
#> [25,] -0.163339397 -0.05092987
#> [26,] 0.251133360 -0.28491258
#> [27,] 0.276457318 -0.04597309
#> [28,] -0.169064055 0.09992997
#> [29,] -0.107170172 -0.00509422
#> [30,] 0.056282836 -0.01835350
#> [31,] 0.103852038 -0.07643977
#> [32,] 0.032289926 0.16941526
#> [33,] 0.242945214 -0.01542559
#> [34,] 0.162942071 -0.06385481
#> [35,] 0.074067928 0.07411837
#> [36,] 0.127100271 0.03490689
#> [37,] -0.036203394 0.17094568
#> [38,] -0.083897059 0.06934479
#> [39,] 0.033449164 -0.09174153
#> [40,] 0.098998319 -0.01985596
#> [41,] 0.050432042 -0.15248563
#> [42,] 0.061054984 0.03493927
#> [43,] 0.058029936 0.01276954
#> [44,] -0.108455685 -0.22185568
#> [45,] -0.063132341 -0.11733784
#> [46,] 0.007849834 0.21336149
#> [47,] 0.154027098 -0.29868818
#> [48,] 0.069562806 0.14558902
immunr_mds(dist(gu))
#> Standard deviations (1, .., p=4):
#> [1] 0 0 0 0
#>
#> Rotation (n x k) = (12 x 2):
#> [,1] [,2]
#> A2-i129 233.88293 -107.06672
#> A2-i131 -145.53408 50.75250
#> A2-i133 -343.68122 -292.27878
#> A2-i132 -323.82099 -80.54790
#> A4-i191 -203.42611 211.63501
#> A4-i192 -278.19595 113.60611
#> MS1 -70.02373 16.25948
#> MS2 383.69473 -402.72176
#> MS3 -73.92883 134.97146
#> MS4 344.35982 -113.71333
#> MS5 -67.39896 114.26628
#> MS6 544.07239 354.83764
immunr_tsne(dist(gu))
#> DimI DimII
#> [1,] -77.80779 -185.14862
#> [2,] 31.50776 22.14340
#> [3,] 76.94507 280.41511
#> [4,] 72.01300 281.44789
#> [5,] 45.36288 39.97587
#> [6,] 18.23736 25.38784
#> [7,] 38.56694 36.17055
#> [8,] -90.19681 -182.49052
#> [9,] 25.10311 35.15328
#> [10,] -82.73509 -187.29123
#> [11,] 27.31462 30.25974
#> [12,] -84.31104 -196.02331
#> attr(,"class")
#> [1] "immunr_tsne" "matrix" "array"