Package: NAIR 1.0.4

Brian Neal

NAIR: Network Analysis of Immune Repertoire

Pipelines for studying the adaptive immune repertoire of T cells and B cells via network analysis based on receptor sequence similarity. Relate clinical outcomes to immune repertoires based on their network properties, or to particular clusters and clones within a repertoire. Yang et al. (2023) <doi:10.3389/fimmu.2023.1181825>.

Authors:Brian Neal [aut, cre], Hai Yang [aut], Daniil Matveev [aut], Phi Long Le [aut], Li Zhang [cph, aut]

NAIR_1.0.4.tar.gz
NAIR_1.0.4.tar.gz(r-4.5-noble)NAIR_1.0.4.tar.gz(r-4.4-noble)
NAIR_1.0.4.tgz(r-4.4-emscripten)NAIR_1.0.4.tgz(r-4.3-emscripten)
NAIR.pdf |NAIR.html
NAIR/json (API)
NEWS

# Install 'NAIR' in R:
install.packages('NAIR', repos = 'https://cloud.r-project.org')

Bug tracker:https://github.com/mlizhangx/network-analysis-for-repertoire-sequencing-/issues1 issues

Pkgdown site:https://mlizhangx.github.io

Uses libs:
  • c++– GNU Standard C++ Library v3
  • openmp– GCC OpenMP (GOMP) support library

On CRAN:

Conda:

cppopenmp

3.48 score 184 downloads 40 exports 54 dependencies

Last updated 1 years agofrom:64e5f129c5. Checks:3 OK. Indexed: no.

TargetResultLatest binary
Doc / VignettesOKMar 28 2025
R-4.5-linux-x86_64OKMar 28 2025
R-4.4-linux-x86_64OKMar 28 2025

Exports:addClusterLabelsaddClusterMembershipaddClusterStatsaddGraphLabelsaddNodeNetworkStatsaddNodeStatsaddPlotsaggregateIdenticalClonesbuildAssociatedClusterNetworkbuildNetbuildPublicClusterNetworkbuildPublicClusterNetworkByRepresentativebuildRepSeqNetworkchooseNodeStatscombineSamplesexclusiveNodeStatsextractLayoutfilterInputDatafindAssociatedClonesfindAssociatedSeqsfindAssociatedSeqs2findPublicClustersgenerateAdjacencyMatrixgenerateNetworkFromAdjacencyMatgenerateNetworkGraphgenerateNetworkGraphPlotsgenerateNetworkObjectsgetClusterStatsgetNeighborhoodhamDistBoundedlabelClusterslabelNodeslevDistBoundedloadDataFromFileListnode_stat_settingsplotNetworkGraphsaveNetworksaveNetworkPlotssimulateToyDatasparseAdjacencyMatFromSeqs

Dependencies:cachemclicolorspacecpp11dplyrfansifarverfastmapgenericsggforceggplot2ggraphggrepelgluegraphlayoutsgridExtragtableigraphisobandjsonlitelabelinglatticelifecyclemagrittrMASSMatrixmemoisemgcvmunsellnlmepillarpkgconfigpolyclippurrrR6RColorBrewerRcppRcppArmadilloRcppEigenrlangscalesstringistringrsystemfontstibbletidygraphtidyrtidyselecttweenrutf8vctrsviridisviridisLitewithr

buildRepSeqNetwork()/buildNet()

Rendered frombuildRepSeqNetwork.Rmdusingknitr::rmarkdownon Mar 28 2025.

Last update: 2023-09-14
Started: 2023-09-14

Cluster Analysis

Rendered fromcluster_analysis.Rmdusingknitr::rmarkdownon Mar 28 2025.

Last update: 2023-09-14
Started: 2023-09-14

Dual-Chain Network Analysis

Rendered fromdual_chain.Rmdusingknitr::rmarkdownon Mar 28 2025.

Last update: 2023-09-14
Started: 2023-09-14

Introduction to the NAIR package

Rendered fromNAIR.Rmdusingknitr::rmarkdownon Mar 28 2025.

Last update: 2023-09-27
Started: 2023-09-14

Node-Level Network Properties

Rendered fromnode_properties.Rmdusingknitr::rmarkdownon Mar 28 2025.

Last update: 2023-09-14
Started: 2023-09-14

Supplementary Functions

Rendered fromsupplementary.Rmdusingknitr::rmarkdownon Mar 28 2025.

Last update: 2023-09-14
Started: 2023-09-14

Citation

To cite package ‘NAIR’ in publications use:

Neal B, Yang H, Matveev D, Le P, Zhang L (2024). NAIR: Network Analysis of Immune Repertoire. R package version 1.0.4, https://CRAN.R-project.org/package=NAIR.

Corresponding BibTeX entry:

  @Manual{,
    title = {NAIR: Network Analysis of Immune Repertoire},
    author = {Brian Neal and Hai Yang and Daniil Matveev and Phi Long
      Le and Li Zhang},
    year = {2024},
    note = {R package version 1.0.4},
    url = {https://CRAN.R-project.org/package=NAIR},
  }

Readme and manuals

NAIR: Network Analysis of Immune Repertoire

NAIR is an R package for analyzing the adaptive immune repertoire using network analysis based on similarities among receptor sequences. It implements methods from the following paper:

Hai Yang, Jason Cham, Brian Neal, Zenghua Fan, Tao He and Li Zhang. (2023). NAIR: Network Analysis of Immune Repertoire. Frontiers in Immunology, vol. 14. https://doi.org/10.3389/fimmu.2023.1181825

NAIR allows users to perform network analysis on Adaptive Immune Receptor Repertoire Sequencing (AIRR-Seq) data, including computing local and global network properties of nodes and clusters, which can provide insights into the structural organization of the immune repertoire network.

NAIR also enables users to search across multiple AIRR-Seq samples for clones/clusters associated with subject characteristics, disease conditions or clinical outcomes, as well as identify public clones/clusters. This can help researchers identify potentially important TCR/BCR clones.

To aid in interpretation of the immune repertoire network, NAIR includes convenient functionality for generating customized network visualizations.

What data does NAIR support?NAIR

NAIR supports bulk and single-cell immune repertoire sequence data for T-cell or B-cell receptors (TCR or BCR).

  • Single-cell data: Each row is a single cell
  • Bulk data: Each row is a distinct TCR/BCR clone (unique combination of V-D-J genes and nucleotide sequence) and typically includes a corresponding measurement of clonal abundance (e.g., clone count and clone frequency/fraction)
How does NAIR model the immune repertoire as a network?NAIR
  • Each cell (single-cell data) or clone (bulk data) is modeled as a node (vertex) in the network
  • For each node, we consider the corresponding receptor sequence (nucleotide or amino acid)
  • For each pair of nodes, we measure the similarity in their receptor sequences (using the Hamming or Levenshtein distance)
  • An edge is drawn between two nodes if the distance is below a specified threshold
    • For single-cell data, sequences from two chains (e.g., alpha chain and beta chain) can be jointly used to determine similarity between cells, considering cells as similar when the sequences for both chains are similar (i.e., when the distance for each chain is below the threshold)
  • Clustering analysis is used to partition the network graph into clusters (densely-connected subgraphs)
    • Many clustering algorithms are available, with each seeking to identify the “best” configuration of clusters according to different graph criteria
  • Network statistics characterize the repertoire in terms of the local and global structural properties of its graph
  • Customized visual plots of the network graph are generated, with nodes colored according to desired metadata (e.g., disease status, sample, cluster, clonal abundance, etc.)

Installation

To install the latest release version of NAIR, use the following command:

install.packages("NAIR")

To install the latest development version of NAIR from source (which requires compilation), use the following command:

devtools::install_github(
  "mlizhangx/Network-Analysis-for-Repertoire-Sequencing-",
  dependencies = TRUE, 
  build_vignettes = TRUE
)

Getting Started

Main Function

General network analysis on AIRR-Seq data is performed using buildRepSeqNetwork() or its convenient alias buildNet(). This function does the following:

  • Filters the AIRR-Seq data according to user specifications
  • Builds the network graph for the immune repertoire
  • Performs additional network analysis, which can include:
    • Cluster analysis
    • Network properties
    • Customizable visual plots of the network graph
  • Returns (and optionally saves) the following output:
    • The network graph (as igraph and adjacency matrix)
    • Metadata for the network
    • Metadata for the nodes in the network
    • Metadata for the clusters in the network
    • Plots of the network graph

See this vignette for a tutorial.

Searching for Associated Clusters

Given multiple samples of bulk AIRR-Seq data, NAIR can be used to search for TCR/BCR clusters associated with a binary variable of interest, such as a disease condition, treatment or clinical outcome. See this article for a tutorial.

Searching for Public Clusters

The NAIR package includes a set of functions that facilitate searching for public TCR/BCR clusters across multiple samples of bulk AIRR-seq data. In this context, a public cluster consists of similar TCR/BCR clones (e.g., those whose CDR3 amino acid sequences differ by at most one amino acid) that are shared across samples (e.g., across individuals or across time points for a single individual). See this article for a tutorial.

Additional Resources

Visualization

This article provides an introduction to the creation and customization of network visualizations using NAIR.

Network Properties and Cluster Analysis

This vignette provides an introduction to computing node-level network properties with NAIR.

This vignette explains how to perform cluster analysis with NAIR.

Supplementary Functions

This vignette provides an overview of NAIR utility functions that supplement the main function buildNet().

Help Manual

Help pageTopics
NAIR: Network Analysis of Immune RepertoireNAIR-package NAIR
Partition a Network Graph Into ClustersaddClusterMembership
Compute Cluster-Level Network PropertiesaddClusterStats
Compute Node-Level Network PropertiesaddNodeNetworkStats
Compute Node-Level Network PropertiesaddNodeStats
Generate Plots of a Network GraphaddPlots generateNetworkGraphPlots
Aggregate Counts/Frequencies for Clones With Identical Receptor SequencesaggregateIdenticalClones
Build Global Network of Associated TCR/BCR ClustersbuildAssociatedClusterNetwork
Build Global Network of Public TCR/BCR ClustersbuildPublicClusterNetwork
Build Global Network of Public TCR/BCR Clusters Using Representative ClonesbuildPublicClusterNetworkByRepresentative
Network Analysis of Immune RepertoirebuildNet buildRepSeqNetwork
Specify Node-level Network Properties to ComputechooseNodeStats exclusiveNodeStats node_stat_settings
Load and Combine Data From Multiple SamplescombineSamples loadDataFromFileList
Get Coordinate Layout From Graph PlotextractLayout
Filter Data Rows and Subset Data ColumnsfilterInputData
Identify TCR/BCR Clones in a Neighborhood Around Each Associated SequencefindAssociatedClones
Identify TCR/BCR Sequences Associated With a Binary VariablefindAssociatedSeqs findAssociatedSeqs2
Find Public Clusters Among RepSeq SamplesfindPublicClusters
Compute Graph Adjacency Matrix for Immune Repertoire NetworkgenerateAdjacencyMatrix sparseAdjacencyMatFromSeqs
Generate the 'igraph' for a Network Adjacency MatrixgenerateNetworkFromAdjacencyMat generateNetworkGraph
Generate Basic Output for an Immune Repertoire NetworkgenerateNetworkObjects
Compute Cluster-Level Network PropertiesgetClusterStats
Identify Cells or Clones in a Neighborhood Around a Target SequencegetNeighborhood
Bounded Computation of Hamming DistancehamDistBounded
Label Clusters in a Network Graph PlotaddClusterLabels labelClusters
Label Nodes in a Network Graph PlotaddGraphLabels labelNodes
Bounded Computation of Levenshtein DistancelevDistBounded
Plot the Graph of an Immune Repertoire NetworkplotNetworkGraph
Save List of Network ObjectssaveNetwork
Write Plots to a PDFsaveNetworkPlots
Generate Toy AIRR-Seq DatasimulateToyData