This function performs Kernel local Fisher discriminant analysis. The function provided here allows users to carry out the KLFDA using other input datasets. We used the gaussan matrix as example. Users can input the

KLFDA(kdata, y, r, sigma = 0.5, metric = c("weighted", "orthonormalized", "plain"),tol=1e-5,knn = 6, reg = 0.001)

Arguments

kdata

The input dataset (kernel matrix). The input data can be a genotype matrix, dataframe, species occurence matrix, or principal components. The dataset have to convert to a kernel matrix before feed into this function.

y

The group lables

r

Number of reduced features

sigma

The sigma used to estimate gaussan matrix.

metric

Type of metric in the embedding space (default: 'weighted') 'weighted' - weighted eigenvectors 'orthonormalized' - orthonormalized 'plain' - raw eigenvectors

knn

The number of nearest neighbours

reg

The regularization parameter

Details

Value

Z

The reduced features

Tr

The transformation matrix

%% ...

References

Tang, Y., & Li, W. (2019). lfda: Local Fisher Discriminant Analysis inR. Journal of Open Source Software, 4(39), 1572.

See also

KLFDAPC

Examples

kmat <- kmatrixGauss(iris[, -5],sigma=1) zklfda=KLFDA(kmat, iris[, 5], r=3,tol=1e-5, metric = "plain")
#> Loading required package: lfda
#> #> Attaching package: 'lfda'
#> The following object is masked from 'package:KLFDAPC': #> #> kmatrixGauss
print(zklfda$Z)
#> [,1] [,2] [,3] #> [1,] 0.6908338 0.095090710 -0.191334747 #> [2,] 0.6824067 0.094187260 0.571348918 #> [3,] 0.6943664 0.095087983 0.583339669 #> [4,] 0.6932426 0.095860399 0.730796046 #> [5,] 0.6879262 0.095019874 -0.193264218 #> [6,] 0.6982340 0.094559284 -0.785792135 #> [7,] 0.6783580 0.092430986 0.423157782 #> [8,] 0.6928782 0.094517089 0.012655628 #> [9,] 0.6908126 0.095594938 1.039179687 #> [10,] 0.6779629 0.093205013 0.464475350 #> [11,] 0.6968818 0.095965287 -0.654051661 #> [12,] 0.6831238 0.093240973 0.204720094 #> [13,] 0.6850108 0.093561850 0.682466028 #> [14,] 0.6559715 0.091951747 1.031838112 #> [15,] 0.6373753 0.093241128 -0.935566720 #> [16,] 0.6483029 0.089939033 -0.956691253 #> [17,] 0.6850558 0.096430328 -0.801616015 #> [18,] 0.6945448 0.095201610 -0.208963733 #> [19,] 0.6782177 0.092041893 -0.833149483 #> [20,] 0.6937609 0.094834058 -0.507126055 #> [21,] 0.6521781 0.091492650 -0.374947719 #> [22,] 0.6953573 0.094485387 -0.433296556 #> [23,] 0.5920554 0.090732121 0.270729902 #> [24,] 0.6458672 0.098833070 -0.062418083 #> [25,] 0.6231089 0.093023864 0.137763308 #> [26,] 0.6540081 0.095678011 0.423944801 #> [27,] 0.6842566 0.095949732 -0.039041722 #> [28,] 0.6916774 0.094611185 -0.301675483 #> [29,] 0.6816435 0.093688245 -0.184211760 #> [30,] 0.6833746 0.095354247 0.516749795 #> [31,] 0.6804888 0.096836621 0.524741556 #> [32,] 0.6646690 0.092034984 -0.403367673 #> [33,] 0.6572613 0.093605324 -0.735149109 #> [34,] 0.6726902 0.096801974 -0.937992890 #> [35,] 0.6854014 0.095334749 0.450678360 #> [36,] 0.6678239 0.092535440 0.280845490 #> [37,] 0.6517243 0.091371563 -0.535134069 #> [38,] 0.6715975 0.093371475 -0.068468775 #> [39,] 0.6908337 0.094655641 0.986764599 #> [40,] 0.6899658 0.094325534 -0.093027152 #> [41,] 0.6857848 0.094975330 -0.088573323 #> [42,] 0.6157049 0.088976476 1.136904823 #> [43,] 0.6755074 0.092841281 0.816821550 #> [44,] 0.6576875 0.093194435 -0.174934062 #> [45,] 0.6465236 0.091076697 -0.493653754 #> [46,] 0.6923704 0.096479454 0.653101237 #> [47,] 0.6882298 0.093542935 -0.493030515 #> [48,] 0.6945230 0.094729895 0.656217550 #> [49,] 0.6989909 0.096140622 -0.580711362 #> [50,] 0.6896011 0.094325804 0.141532639 #> [51,] -0.2401565 0.177695401 0.010064908 #> [52,] -0.2439961 0.182304554 0.010885886 #> [53,] -0.2445434 0.129564781 0.011470037 #> [54,] -0.2476853 0.274184789 0.015292133 #> [55,] -0.2494239 0.164325615 0.010437617 #> [56,] -0.2396570 0.228940396 0.014718378 #> [57,] -0.2402420 0.143565727 0.010357575 #> [58,] -0.2371402 0.309180398 0.019728469 #> [59,] -0.2504032 0.198257507 0.009035036 #> [60,] -0.2604747 0.271596006 0.007909957 #> [61,] -0.2404199 0.292580391 0.010310359 #> [62,] -0.2422215 0.234161340 0.017555960 #> [63,] -0.2283096 0.271584547 0.017221551 #> [64,] -0.2450493 0.176488829 0.010717701 #> [65,] -0.2400155 0.284082696 0.001055781 #> [66,] -0.2451196 0.197088200 0.009942058 #> [67,] -0.2401496 0.207872985 0.015073863 #> [68,] -0.2368332 0.288809507 0.016890917 #> [69,] -0.2320483 0.172232748 0.011705885 #> [70,] -0.2512459 0.306431759 0.015627754 #> [71,] -0.2403907 0.102070767 0.011815840 #> [72,] -0.2423685 0.246992366 0.018004507 #> [73,] -0.2487661 0.108286958 0.010612319 #> [74,] -0.2411349 0.201626990 0.009677974 #> [75,] -0.2466864 0.222348412 0.012549580 #> [76,] -0.2474797 0.198870383 0.010519766 #> [77,] -0.2488332 0.157767332 0.009780238 #> [78,] -0.2459626 0.063663258 0.012545048 #> [79,] -0.2452294 0.194763540 0.014024668 #> [80,] -0.2364583 0.288703012 0.005497467 #> [81,] -0.2559695 0.312988152 0.012919970 #> [82,] -0.2534174 0.318089638 0.011746163 #> [83,] -0.2479731 0.286476583 0.017275556 #> [84,] -0.2475060 0.051103932 0.011717472 #> [85,] -0.2372713 0.200519032 0.014851939 #> [86,] -0.2316395 0.188381908 0.011912644 #> [87,] -0.2480978 0.155704247 0.010162361 #> [88,] -0.2387480 0.214949014 0.011629018 #> [89,] -0.2413712 0.282032159 0.015589995 #> [90,] -0.2540548 0.283336718 0.015896500 #> [91,] -0.2361880 0.241686373 0.015494235 #> [92,] -0.2439084 0.196325973 0.011370997 #> [93,] -0.2480341 0.285368807 0.018571947 #> [94,] -0.2441053 0.315580284 0.019890904 #> [95,] -0.2470542 0.268503149 0.017664128 #> [96,] -0.2365231 0.280490736 0.015622056 #> [97,] -0.2436209 0.271441936 0.017219254 #> [98,] -0.2456551 0.234362403 0.014301435 #> [99,] -0.1944262 0.298422890 0.025937177 #> [100,] -0.2475623 0.277926122 0.017954562 #> [101,] -0.2291203 -0.049803043 0.012891009 #> [102,] -0.2478004 0.003599145 0.013049102 #> [103,] -0.2456533 -0.088500821 0.014031725 #> [104,] -0.2397209 -0.049603340 0.014986169 #> [105,] -0.2419907 -0.077214880 0.014438033 #> [106,] -0.2557926 -0.100831782 0.014796130 #> [107,] -0.2236223 0.045994333 0.013094244 #> [108,] -0.2401130 -0.100433761 0.013006277 #> [109,] -0.2328953 -0.055791706 0.015090829 #> [110,] -0.2386028 -0.086921338 0.013990814 #> [111,] -0.2430997 -0.010436094 0.013629104 #> [112,] -0.2445893 -0.026571898 0.014211704 #> [113,] -0.2421210 -0.067509773 0.015062854 #> [114,] -0.2405449 -0.007017748 0.013671421 #> [115,] -0.2350586 -0.042186248 0.012821301 #> [116,] -0.2437303 -0.065119321 0.014400042 #> [117,] -0.2409437 -0.040808658 0.014967753 #> [118,] -0.2353990 -0.084198949 0.014663092 #> [119,] -0.2243250 -0.073855461 0.014057532 #> [120,] -0.2416147 0.076117198 0.011633029 #> [121,] -0.2441265 -0.088165742 0.014437359 #> [122,] -0.2438752 0.024293387 0.013718876 #> [123,] -0.2416040 -0.096748701 0.014359064 #> [124,] -0.2441306 0.051617653 0.012019909 #> [125,] -0.2419586 -0.081718557 0.015027076 #> [126,] -0.2405941 -0.089589413 0.014022156 #> [127,] -0.2440560 0.071831902 0.012162587 #> [128,] -0.2453541 0.063992070 0.011894159 #> [129,] -0.2426208 -0.067530802 0.014900079 #> [130,] -0.2302114 -0.050204390 0.014508272 #> [131,] -0.2391761 -0.088497025 0.013361865 #> [132,] -0.2324169 -0.087109034 0.013924865 #> [133,] -0.2413974 -0.069736565 0.014530661 #> [134,] -0.2465994 0.072096757 0.011098653 #> [135,] -0.2322474 -0.013624440 0.013834281 #> [136,] -0.2389662 -0.088611461 0.014015309 #> [137,] -0.2402206 -0.067131564 0.014418773 #> [138,] -0.2381605 -0.038438963 0.014510631 #> [139,] -0.2444254 0.085913930 0.012307548 #> [140,] -0.2408193 -0.057148029 0.015066583 #> [141,] -0.2412745 -0.084076398 0.014162300 #> [142,] -0.2270529 -0.049280965 0.013789512 #> [143,] -0.2478004 0.003599145 0.013049102 #> [144,] -0.2449401 -0.087569760 0.013926455 #> [145,] -0.2407897 -0.083858421 0.014025020 #> [146,] -0.2333727 -0.062764041 0.013982291 #> [147,] -0.2382102 0.016688570 0.012402665 #> [148,] -0.2441418 -0.027855211 0.014096075 #> [149,] -0.2411002 -0.053533824 0.014139919 #> [150,] -0.2448585 0.034668728 0.011798894