--- title: "Getting started with the tna package" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Getting started with the tna package} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, fig.width = 6, fig.height = 4, dev = "svg", fig.ext = "svg", dpi = 50, out.width = "100%", dpi = 100, comment = "#>" ) suppressPackageStartupMessages({ library("tna") library("tibble") library("dplyr") library("gt") }) ``` This vignette showcases some basic usage of the `tna` package. First we load the package that we will use for this example. ```{r, eval = FALSE} library("tna") library("tibble") library("dplyr") library("gt") ``` We also load the `group_regulation` data available in the package (see `?group_regulation` for further information) ```{r} data("group_regulation", package = "tna") ``` We build a TNA model using this data with the `tna()` function . ```{r} tna_model <- tna(group_regulation) ``` To visualize the model, we can use the standard `plot()` function. ```{r, fig.width=5, fig.height=5} plot(tna_model, cut = 0.2, minimum = 0.05, edge.label.position= 0.8, edge.label.cex = 0.7) ``` The initial state probabilities are ```{r} data.frame(`Initial prob.` = tna_model$inits, check.names = FALSE) |> rownames_to_column("Action") |> arrange(desc(`Initial prob.`)) |> gt() |> fmt_percent() ``` and the transitions probabilities are ```{r} tna_model$weights |> data.frame() |> rownames_to_column("From\\To") |> gt() |> fmt_percent() ``` The function `centralities()` can be used to compute various centrality measures (see `?centralities` for more information). These measures can also be visualized with the `plot()` function. ```{r} centrality_measures <- c("BetweennessRSP", "Closeness", "InStrength", "OutStrength") cents_withoutloops <- centralities( tna_model, measures = centrality_measures, loops = FALSE, normalize = TRUE ) plot(cents_withoutloops, ncol = 2, model = tna_model) ```