Skip to content

Reconstruct clone-level immunoglobulin germlines

Source code

Description

[Experimental]

B cells in the same clone come from one starting cell, but their antibody sequences can gain different mutations over time. To study these mutations, we need a shared sequence to compare them with.

The method annotates each clone and locus with a representative germline sequence from references – usually IMGT germline table.

The result can be used as the reference for somatic hypermutation analysis with annotate_ig_shm().

Usage

annotate_ig_germlines(
  idata,
  references,
  species = NULL,
  by = "<auto>",
  sequence_id_col = "sequence_id",
  sequence_col = "sequence_alignment",
  v_col = "v_call",
  j_col = "j_call",
  v_start_col = "v_germline_start",
  v_end_col = "v_germline_end",
  j_start_col = "j_germline_start",
  j_end_col = "j_germline_end",
  germline_col = "germline_alignment"
)

Arguments

idata immundata::ImmunData. AIRR data to annotate.
references A table returned by read_germline_references() containing IMGT-gapped reconstruction references. These are not the ungapped reference files used to build an IgBLAST database; see Assumptions and reference compatibility.
species Character scalar, or NULL to use the sole reference species.
by Character vector or "<auto>". Clone grouping columns. Automatic grouping uses clone_id, with subject_id when available. Locus is always added.
sequence_id_col, sequence_col, v_col, j_col Character scalars selecting the sequence ID, IMGT-gapped aligned sequence, V-call, and J-call columns.
v_start_col, v_end_col, j_start_col, j_end_col Character scalars selecting the closed, IMGT-gapped germline-coordinate columns.
germline_col Character scalar naming the reconstructed output column.

Value

immundata::ImmunData with one clone/locus germline assigned to each input row. Groups which cannot be reconstructed receive NA.

Assumptions and reference compatibility

This function reconstructs germlines by indexing directly into the supplied reference strings. It does not insert IMGT numbering gaps, convert coordinates, or otherwise align the input sequences and references. Consequently, all of the following assumptions must hold:

  • sequence_col contains IMGT-gapped alignments, including the standard . numbering spacers.
  • The germline start and end columns use the same IMGT-gapped coordinate system as sequence_col and references.
  • V references in references contain IMGT numbering gaps. In particular, do not supply the ungapped FASTA files used to build an IgBLAST database.
  • The reference alleles and release match those used during assignment of the V and J calls. Missing or different alleles cannot be reconstructed safely.

An Immcantation-style workflow normally maintains two representations of the same reference release: ungapped sequences for the IgBLAST database and IMGT-gapped sequences for germline reconstruction. This function requires the latter. Matching references therefore means the same allele set and release, not the literal ungapped FASTA passed to IgBLAST.

read_germline_references() preserves gaps that are already present in a FASTA file, but neither it nor this function converts ungapped references to IMGT-gapped references. Supplying incompatible ungapped data can produce a plausible-length but incorrectly shifted germline without an error.

The reconstructed value corresponds conceptually to Dowser's germline_alignment_d_mask: the retained V and J portions surround an N-masked middle region. This function does not reconstruct a full V(D)J germline or infer a D segment.

Preparing the input

To create the BCR repertoire, first you need to run IgBlast either standalone or through immundapter::tool_igblast() with an IMGT database on your FASTQ files or 10XGenomics contigs files. immundapter automatically prepares the alignment and V positions for IMGT-gapped references. Then, read V and J references from the same IMGT release with read_germline_references(). See the "Ig tutorial" on the website for the detailed workflow – it is a bit complicated, as per usual with BCR analysis.

Other AIRR data can be used when its alignment and V/J positions match the supplied IMGT-gapped references. But please mind that raw IgBlast AIRR output has not been prepared this way. This function does not convert positions or add gaps, so mismatched input can give an incorrect sequence without an error.

Output

This is a D-masked germline, not a complete ancestral receptor sequence. By default, it replaces an existing germline_alignment column. Use germline_col to keep that column.