Method to compute 'TL-tsne' and 'group-TL-tsne' layouts and save it as node attributes of the focal network.

attach_layout(
  metanetwork,
  g = NULL,
  beta = 0.1,
  mode = "TL-tsne",
  TL_tsne.config = TL_tsne.default,
  res = NULL,
  group_layout.config = group_layout.default
)

# S3 method for metanetwork
attach_layout(
  metanetwork,
  g = NULL,
  beta = 0.1,
  mode = "TL-tsne",
  TL_tsne.config = TL_tsne.default,
  res = NULL,
  group_layout.config = group_layout.default
)

Arguments

metanetwork

object of class 'metanetwork'

g

character indicating the name of the network for which the 'TL-tsne' layout is computed, default is 'metaweb'

beta

the diffusion parameter of the diffusion kernel, a positive scalar controlling the squeezing of the network, default is 0.1

mode

'TL-tsne' or 'group-TL-tsne', default is 'TL-tsne'.

TL_tsne.config

configuration list for mode 'TL-tsne', default is TL_tsne.default

res

resolution for the 'group-TL-tsne' layout

group_layout.config

configuration list for mode 'group-TL-tsne', default is group_layout.default

Value

an object of class 'metanetwork', with the computed layout added as node attribute of the considered network

NULL

Details

The 'TL-tsne' layout is a diffusion based layout algorithm specifically designed for trophic networks. In metanetwork, first axis is the trophic level (see compute_TL method) whereas the second axis is computed using a diffusion graph kernel (Kondor & Lafferty 2002) and tsne dimension reduction algorithm to (see van der Maaten & Hinton (2008) and 'tsne' R package). Let \(A\) be the adjacency matrix of the considered network and \(D\) its degree diagonal matrix. The Laplacian matrix of the symmetrised network is defined by:

$$L = D - A - t(A)$$

The diffusion graph kernel is:

$$K = exp(-beta*L)$$

It is a similarity matrix between nodes according to a diffusion process. beta is the diffusion constant,it must be provided by the user. beta parameter influences the layout by grouping together similar paths (see pyramid vignette). Each node of the focal network has an attribute layout_beta_VALUE. If this function is run several times for a given beta value, repetitions of the layout algorithm will be stored as node attributes.

The 'group-TL-tsne' layout is a variation of 'TL-tsne layout. For a focal network, it mixes 'TL-tsne' layout at the desired aggregated level with the layout_with_graphopt function from igraph. It clusters nodes belonging to the same group. 'group-TL-tsne' layout is recommended for large networks since you only need to compute 'TL-tsne' at the aggregated network that is much smaller than the focal network. group_layout.config allows controlling the overall size of the groups.

References

Kondor, R. I., & Lafferty, J. (2002, July). Diffusion kernels on graphs and other discrete structures. In Proceedings of the 19th international conference on machine learning (Vol. 2002, pp. 315-322). Van der Maaten, L., & Hinton, G. (2008). Visualizing data using t-SNE. Journal of machine learning research, 9(11).

Examples

library(metanetwork)
library(igraph)
#> 
#> Attaching package: ‘igraph’
#> The following objects are masked from ‘package:stats’:
#> 
#>     decompose, spectrum
#> The following object is masked from ‘package:base’:
#> 
#>     union
# on angola dataset (metaweb)
data("meta_angola")
meta_angola = attach_layout(meta_angola,beta = 0.05)
#> attaching TL-tsne layout for metaweb_Species
#> 
#>                   beta = 0.05
#> beta = 0.05
#> Epoch: Iteration #100 error is: 907.410775020654
#> Epoch: Iteration #200 error is: 217.110128493546
#> Epoch: Iteration #300 error is: 217.236109920637
V(meta_angola$metaweb)$layout_beta0.05
#>  [1] -22.9414802  -6.0994143   4.9594423  -4.1281724 -14.2013399  15.3619913
#>  [7]  30.0598299   7.2834431  20.9454738  23.0397159  11.3357604  26.4009774
#> [13]  -8.3537814 -18.0145967 -26.3438149  -1.8507144 -20.3205830   2.5556471
#> [19]   0.3954457  17.8918993 -10.6969826 -31.0165226   9.3785720  13.3728007
#> [25] -15.9951749 -12.5295511 -10.1007625  19.6118919