The circularNet package provides tools for estimating circular graphical models using node-wise regression approaches. Circular data arise naturally in many scientific fields, including chronobiology, directional statistics, environmental sciences, and gene-expression studies involving periodic or cyclic processes.
The package implements two complementary approaches for network estimation:
The package includes functions for:
Circular variables are measured on a periodic scale where values wrap around after a full revolution. Typical examples include angles measured in radians within the interval
\[ [-\pi,\pi] \]
Specialized statistical methods are required because standard Euclidean methods do not account for circular topology.
The likelihood-based method estimates conditional relationships
between nodes using node-wise circular regression models. Parameters are
estimated through numerical optimization using the optim()
function.
Estimated regression coefficients are assembled into a coefficient matrix, which is subsequently thresholded to obtain an adjacency matrix representing the network structure.
The package also supports network estimation based on Circular Mean Squared Error (CMSE). This approach measures discrepancies using circular distances and can be used for network construction, model fitting, and variable selection in circular data settings.
The following example illustrates a complete workflow using simulated circular data.
# Simulated example data
set.seed(1)
data <- matrix(runif(200, -pi, pi), ncol = 5)
# Fit the model
fit <- fit_circular_model(data)
# Build adjacency matrix
network <- build_network(fit)
# Display network structure
network
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0 0 0 0 0
#> [2,] 0 0 1 1 1
#> [3,] 0 0 0 1 0
#> [4,] 1 0 1 0 0
#> [5,] 1 1 1 1 0The resulting adjacency matrix summarizes the estimated network structure obtained from the simulated circular data.
The estimated adjacency matrix can be visualized directly.
Nodes represent variables and edges represent estimated associations identified by the circular graphical model.
When a reference network (ground-truth) is available, the estimated network can be evaluated using standard performance metrics.
true_network <- matrix(
sample(0:1, 25, replace = TRUE),
ncol = 5
)
results <- evaluate_network(
network,
true_network
)
results
#> $TP
#> [1] 1
#>
#> $TN
#> [1] 3
#>
#> $FP
#> [1] 3
#>
#> $FN
#> [1] 3
#>
#> $accuracy
#> [1] 0.4
#>
#> $precision
#> [1] 0.25
#>
#> $recall
#> [1] 0.25
#>
#> $specificity
#> [1] 0.5
#>
#> $MCC
#> [1] -0.25
#>
#> $F_score
#> [1] 0.25The package can also be applied to real biological datasets. The following example uses a small gene-expression dataset included with the package and demonstrates the complete workflow from data loading to network estimation and visualization.
gene_file <- system.file(
"extdata",
"gene_expression_subset.csv",
package = "circularNet"
)
gene_data <- read.csv(
gene_file,
check.names = FALSE
)
# Remove gene identifier column if present
if (!is.numeric(gene_data[[1]])) {
gene_data <- gene_data[, -1]
}
gene_data <- as.matrix(gene_data)
# Convert from genes × samples to observations × variables
gene_data <- t(gene_data)
# Use a small subset of genes for faster vignette execution
gene_data_small <- gene_data[, 1:min(5, ncol(gene_data))]
# Fit circular graphical model
fit_gene <- fit_circular_model(gene_data_small)
# Display estimated coefficient matrix
round(fit_gene, 3)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1.000 -0.160 0.109 0.209 -0.333
#> [2,] -0.223 1.000 0.240 -0.051 -0.112
#> [3,] 0.166 0.237 1.000 -0.026 -0.118
#> [4,] 0.725 -0.190 -0.122 1.000 0.270
#> [5,] -0.445 -0.104 -0.114 0.133 1.000
# Build adjacency matrix
network_gene <- build_network(
fit_gene,
threshold = 0.2
)
# Display estimated network
network_gene
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0 0 0 1 1
#> [2,] 1 0 1 0 0
#> [3,] 0 1 0 0 0
#> [4,] 1 0 0 0 1
#> [5,] 1 0 0 0 0
# Visualize estimated network
plot_network(network_gene)The estimated adjacency matrix contains several non-zero entries, indicating potential associations among the selected genes. The network visualization represents genes as nodes and estimated associations as edges. In this example, connections are observed among multiple gene pairs, resulting in a sparse but non-empty network structure. This example is intended to demonstrate the package workflow and should not be interpreted as a biological conclusion. The number of detected edges depends on the selected threshold value, with lower thresholds generally producing denser networks. generally producing denser networks.
The package is suitable for both simulated and real-world circular datasets. Potential applications include:
Input data should be provided as a matrix where:
Dar, E. D. (2023). A Non-Parametric Circular Network Construction Via Simulations and a Hidden Markov Model for the HIV-1 Protease Cleavage Site Detection. Doctoral Dissertation, Middle East Technical University, Türkiye.
Available at: https://open.metu.edu.tr/handle/11511/102577
The circularNet package provides a flexible framework for estimating and analyzing circular graphical models. By combining likelihood-based and CMSE-based methodologies, the package supports both methodological research and applied network analysis for circular data.