\name{get_cdr3_motifs}
\alias{get_cdr3_motifs}
\title{Generate CDR3 motif for communities}
\description{
This function extracts CDR3 motifs from the node summary of clonotypes in a 
specific community, and generates motif logos for each chain using sequence 
alignment and amino acid frequency calculations. It allows the removal of 
gaps in the alignment based on a user-defined probability threshold.
}
\details{
The function performs the following steps:
\enumerate{
  \item Extracts CDR3 sequences for each chain from the node summary.
  \item Aligns the CDR3 sequences using Clustal Omega and computes 
  position-specific amino acid frequencies.
  \item Generates motif logos for each chain, with the option to remove gaps 
  based on the specified threshold.
  \item The motif logos are arranged in a single row using the `patchwork` 
  package.
}
}
\usage{
get_cdr3_motifs(node_summary, community_id, gap_remove_prob = 0.8)
}
\arguments{
\item{node_summary}{A data frame containing node information generated by
the function \code{detect_communities}. The rows represent clonotypes, and 
the columns include chains (e.g., `CDR3a`, `CDR3b`) and other attributes 
such as `clone_size`.}
\item{community_id}{A numeric or character value representing the community 
ID for which CDR3 motifs should be extracted.}
\item{gap_remove_prob}{A numeric value between 0 and 1 specifying the 
probability threshold for removing gaps in the sequence alignment. The 
default is 0.8. Positions with a gap frequency above this threshold will 
have gaps excluded.}
}
\value{
A `ggplot2` object that displays a series of motif logos for each chain in the 
specified community. The logos show the amino acid frequency at each position 
in the CDR3 sequence, with optional gap removal based on the `gap_remove_prob`.
}
\examples{
# Create a mock node summary data frame
node_summary <- data.frame(
  community = rep(1, 4),
  CDR3a = c("CASSLAGTDTQYF", "CASSLAGTDTQYF", "CASSLAGTDTQYF", "CASSLAGTDTQYF"),
  CDR3b = c("CASSLAGTDTQYF", "CASSLAGTDTQYF", "CASSLAGTDTQYF", "CASSLAGTDTQYF"),
  clone_size = c(100, 150, 200, 50)
)

# Call the function to generate motif logos for community 1
motifs <- get_cdr3_motifs(node_summary, community_id = 1, gap_remove_prob = 0.8)

# Display the resulting motif logos
plot(motifs)
}
