\name{get_nrads}
\alias{get_nrads}
\title{Compute Normalized Rank Abundance Distributions (NRADs)}
\description{
This function NRADs for a given community occupancy matrix. It performs 
normalization using the \code{RADnormalization_matrix} function implemented
in \code{RADanalysis}.
}

\details{
The function computes the NRADs by ranking the community abundances in 
each sample (repertoire), determining the maximum rank, and normalizing 
the abundances using the \code{RADnormalization_matrix} function. The 
result is returned as a melted data frame containing the normalized abundances 
for each sample and rank. This enables comparison of community structures 
across repertoires with different depths (numbers of clonotypes).

The parameter \code{B} specifies the number of bootstrap iterations used in 
the normalization process. A higher value of \code{B} increases the stability 
and reliability of the normalized abundances but also increases computation 
time. The default value is 1000, which is a common choice for balancing 
accuracy and computational efficiency.
}

\usage{
  get_nrads(community_occupancy_matrix, B = 1000)
}

\arguments{
  \item{community_occupancy_matrix}{A matrix where rows represent communities 
  and columns represent samples (generated by \code{detect_communities}). 
  Entries are the abundances of communities in each sample (column).}
  \item{B}{A positive integer specifying the number of iterations for 
  averaging during normalization. Default is 1000.}
}

\value{
  A data frame containing the normalized abundances for each sample and rank. 
  The data frame has the following columns:
  \itemize{
    \item{sample: The sample identifier.}
    \item{rank: The rank of the abundance.}
    \item{norm.abundance: The normalized abundance at the given rank.}
  }
}

\examples{
  # Example usage:
  # Create a sample community occupancy matrix
  community_occupancy_matrix <- matrix(rpois(100, lambda = 10),nrow=20,ncol=5)
  
  # Compute normalized RADs
  nrads <- get_nrads(community_occupancy_matrix, B = 100)
  
  # Display the first few rows of the result
  head(nrads)
}
