Skip to content

AndersenLab/gene_rename_workflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gene rename workflow

Overview

This document describes the workflow used to assign gene names to the CGC2/CGC3 gene annotation by transferring and, where appropriate, propagating gene names from annotated orthologs in Caenorhabditis briggsae AF16 and/or C. elegans N2.

CGC2

The workflow combines:

  1. OrthoFinder orthogroups to define conserved gene-copy relationships among CGC2, AF16, QX1410, and N2.
  2. Reciprocal best BLAST hits (RBBHs) to identify the most likely transcript-level orthologs within those orthogroups.
  3. Existing AF16 and N2 gene names as naming references.
  4. Explicit rules for direct name transfer and paralog-name propagation.
  5. Post-processing to enforce unique names and propagate longest-isoform assignments to all isoforms of a CGC2 gene.
  6. Export of the renamed annotation in both consequence-annotation and WormBase-style GFF formats.

The main principle is to use the most specific orthology evidence available while avoiding unsupported propagation across ambiguous gene families.

CGC3

This workflow is similar, but much simpler, as it only transfers annotations from N2 to NIC58 (CGC3) - leading to fewer possible orthogroup patterns (1:1, 1:N, N:N)

Input annotations and orthology data

The workflow uses longest-isoform GFF annotations for N2, AF16, QX1410, and CGC2, together with the original full CGC2 annotation so that final names can later be propagated from the representative transcript to all isoforms.

OrthoFinder orthogroups are loaded and the species columns are renamed to concise strain identifiers.

orthos <- readr::read_tsv(
  "../processed_data/orthofinder/briggsae/Orthogroups.tsv"
) %>%
  dplyr::rename(
    QX1410 = c_briggsae.QX1410_20250929.csq.longest.protein,
    CGC2   = CGC2.softMasked.braker.longest.protein,
    AF16   = c_briggsae.PRJNA10731.WS280.protein_coding.longest.prot,
    N2     = N2.WBonly.WS283.PConly.prot
  )

For each species, the number of genes represented in each orthogroup is calculated from the comma-separated transcript list. These copy counts are the basis for classifying orthogroups into different conservation patterns.

Orthogroup copy-number patterns

CGC2

The workflow focuses on orthogroups whose copy numbers are stable across selected taxa. The notation below gives the copy-number relationship in the order:

N2 : CGC2 : AF16 : QX1410

Here, 1 denotes a single-copy gene, N denotes the same multi-copy number among the indicated taxa, and X denotes a strain/species whose copy number is not required to match.

The principal patterns are:

Pattern Interpretation
1:1 Single-copy orthology between CGC2 and a reference species
1:N:N:N N2 is single-copy; CGC2, AF16, and QX1410 share the same multi-copy expansion
1:N:X:N N2 is single-copy; CGC2 and QX1410 share the same multi-copy expansion; AF16 is unconstrained
N:N:N:N All four strains/species have the same multi-copy number
N:N:X:N N2, CGC2, and QX1410 have the same multi-copy number; AF16 is unconstrained
X:N:N:N CGC2, AF16, and QX1410 have the same multi-copy number; N2 is unconstrained

For multi-copy analyses, orthogroups are restricted to at most four CGC2 members. This restriction is important because the paralog-enumeration code searches for unused suffixes within 1:4.

CGC3

The workflow focuses on orthogroups whose copy numbers are stable across selected taxa. The notation below gives the copy-number relationship in the order:

N2 : CGC3

The principal patterns are:

Pattern Interpretation
1:1 Single-copy orthology between CGC3 and N2
1:N N2 is single-copy; CGC3 isn't
N:N N2 and CGC3 have equal copy number.

For multi-copy analyses, orthogroups are restricted to at most four CGC3 and N2 members. This restriction is important because the paralog-enumeration code searches for unused suffixes within 1:4.

Reference gene-name tables

Existing names are extracted separately from AF16 and N2 GFF annotations.

For AF16, the workflow resolves the locus field from the mRNA attributes and removes the Cbr- prefix. AF16 identifiers beginning with CBG are treated as uninformative systematic identifiers rather than informative gene names.

For N2, gene-level aliases are linked back to mRNA IDs so that transcript-level orthology mappings can retrieve the corresponding gene name.

The resulting lookup tables have the conceptual structure:

reference transcript  ->  reference gene/locus name

Transcript-to-orthogroup lookup tables

Because OrthoFinder stores multiple members as comma-separated strings, each species column is converted into a long transcript-to-orthogroup table.

CGC2_tranbyog <- orthos %>%
  select(Orthogroup, CGC2_transcript = CGC2) %>%
  separate_longer_delim(CGC2_transcript, delim = ",") %>%
  mutate(CGC2_transcript = trimws(CGC2_transcript)) %>%
  filter(!is.na(CGC2_transcript), CGC2_transcript != "")

Equivalent tables are generated for N2, AF16, and QX1410.

These tables allow each transcript-level similarity hit to be checked against its OrthoFinder orthogroup.

Reciprocal best BLAST hits

Protein BLAST searches were performed in both directions for:

  • CGC2 versus N2
  • CGC2 versus AF16

For each query, the best significant hit is chosen by:

  1. requiring E < 0.05;
  2. sorting by decreasing bitscore and then increasing E-value;
  3. retaining the top hit.

A reciprocal best hit is retained only when the best hit in one direction points back to the original transcript in the reverse search.

N2_to_CGC2_RBBH <- CGC2_to_N2_best %>%
  inner_join(
    N2_to_CGC2_best,
    by = c("query" = "subject", "subject" = "query")
  )

The resulting RBBHs are then joined to the transcript-to-orthogroup tables. A pair is accepted only when the reference transcript and CGC2 transcript belong to the same OrthoFinder orthogroup.

This extra orthogroup requirement prevents a high-scoring reciprocal similarity match from being used when it conflicts with the broader orthology assignment.

Naming hierarchy

The workflow uses a hierarchical naming strategy.

CGC2

  1. Direct one-to-one assignments are preferred whenever a single-copy ortholog is available.
  2. For conserved multi-copy families, AF16 is used first when its gene name is informative and transcript-level RBBHs resolve individual members.
  3. N2 is used when AF16 cannot provide an informative name, especially for 1:N relationships where a single N2 gene corresponds to a CGC2 expansion.
  4. Gene-name propagation is restricted to orthogroups where the family structure supports a common gene root.
  5. Residual RBBHs are appended after the structured orthogroup-based naming procedure.
  6. Systematic AF16 CBG... identifiers are retained only as a fallback.

CGC3

  1. Direct one-to-one assignments are preferred whenever a single-copy ortholog is available.
  2. Gene-name propagation is restricted to orthogroups where the family structure supports a common N2 gene root.
  3. For conserved multi-copy families, N2 is used when transcript-level RBBHs resolve individual members.
  4. Residual RBBHs are appended after the structured orthogroup-based naming procedure.

Metadata attributes

Each final assignment records:

  • name: assigned CGC2/3 name;
  • name_source: reference annotation used (AF16 or N2);
  • name_method: rule that produced the assignment;
  • pattern: orthogroup copy-number pattern;
  • mapped_transcript: reference transcript supporting the assignment;
  • propagate_source: CGC2/3 transcript(s) whose directly mapped name was used as the source for propagation, where available;
  • match_identity: protein percent identity of the relevant CGC2/3-to-reference match, where available.

Naming single-copy genes

Single-copy CGC2/3 genes are assigned names directly from one-to-one orthologs.

N2 or AF16 single-copy ortholog tables are joined to their reference name lookup tables. Informative AF16 names are used where available; AF16 CBG... systematic identifiers are not treated as informative names at this stage.

These assignments are marked:

pattern     = 1.1
name_method = direct_1to1

Naming 1:N:N:N orthogroups

In 1:N:N:N orthogroups, N2 contains one gene while CGC2, AF16, and QX1410 contain the same number of paralogs.

The first attempt is to resolve individual CGC2 paralogs using AF16 RBBHs.

All AF16 orthologs have informative names

When every AF16 member of an orthogroup is recovered by RBBH and every mapped AF16 locus has an informative name, names are transferred directly to the corresponding CGC2 transcripts.

name_source = AF16
name_method = direct_map_NN

No propagation is required.

Mixed informative and CBG AF16 names

If all AF16 members are mapped but only some have informative names, the workflow asks whether the informative names support treating the orthogroup as a paralogous family.

Existing paralog suffixes

If one or more informative AF16 names already contain suffixes such as:

gene.1
gene.2

the existing suffix scheme is expanded to unnamed family members.

Alphabetical suffixes are normalized to their alphabetic positions before expansion:

A/a -> 1
B/b -> 2
...

Unused integers from the allowed suffix range are then assigned to the remaining members.

For example:

sec-61.A   -> sec-61.1
CBG30478   -> sec-61.2

Assignments from this rule are marked:

name_method = propagate_NN_ex

The propagate_source field lists the CGC2 transcript(s) whose AF16 orthologs supplied the informative family name.

One unique informative family name

If no existing suffix system is present, but the orthogroup contains exactly one unique non-CBG AF16 locus, that name is treated as the family root.

The directly supported member receives .1, and the remaining paralogs receive .2, .3, etc.

For example:

gene
CBGxxxxx
CBGyyyyy

becomes:

gene.1
gene.2
gene.3

This rule is marked:

name_method = propagate_NN

Multiple incompatible informative names

If multiple distinct informative AF16 names occur in the same orthogroup and they cannot be reconciled as a single paralog family, names are not propagated across the group.

Only the directly supported mappings are retained.

name_method = direct_NN_partial

AF16 cannot provide a name: use N2

For remaining 1:N:N:N families, the workflow uses the single N2 ortholog as the family name and propagates that name across all CGC2 members.

Members are enumerated in the CGC2 orthogroup:

gene.1
gene.2
...
gene.N

These assignments are marked:

name_source = N2
name_method = propagate_1N

The N2-supported CGC2 transcript is stored in propagate_source.

Naming 1:N:X:N orthogroups

The 1:N:X:N category captures expansions shared by CGC2 and QX1410 where AF16 copy number is not stable.

Because N2 remains single-copy, the N2 RBBH is used as the naming anchor and its gene name is propagated across the CGC2 copies.

name_source = N2
name_method = propagate_1N_unkAF

This is conceptually similar to the N2 fallback used for 1:N:N:N, but the method label records that AF16 copy number was not part of the stable pattern.

Naming N:N:N:N orthogroups

For orthogroups with equal multi-copy numbers in all four taxa, the workflow again attempts AF16 first.

The same hierarchy is used:

  1. all AF16 members named -> direct transfer;
  2. mixed names with an existing suffix system -> expand the suffix system;
  3. exactly one informative family root -> generate a new .1, .2, ... series;
  4. multiple incompatible informative roots -> retain only direct assignments.

The corresponding method labels include:

direct_map_NNN
propagate_NNN_ex
propagate_NNN
direct_NN_partial

If AF16 does not resolve the orthogroup, N2 RBBHs are examined. When all N2 members are represented and named, the N2 names are transferred directly.

Naming N:N:X:N orthogroups

These orthogroups have equal copy number in N2, CGC2, and QX1410 but not necessarily AF16.

The workflow tests N2 RBBHs. In the analyzed CGC2 dataset, the alternative partial-mapping situations anticipated for this category were not encountered, and no additional propagation scheme was applied.

Thus this category is intentionally conservative: unresolved families remain unnamed rather than forcing a name across an uncertain orthology relationship.

Naming X:N:N:N orthogroups

These orthogroups have stable copy number among CGC2, AF16, and QX1410, while N2 is unconstrained.

AF16 is therefore used as the main reference. The same AF16 multi-copy decision tree used for N:N:N:N is applied:

  • direct transfer when all members have informative names;
  • expansion of an existing suffix scheme;
  • creation of a new suffix scheme when one unique informative family root is present;
  • partial direct assignment when multiple incompatible roots occur.

Combining structured naming results

The named subsets from each orthogroup pattern are combined into a common table and labeled by their copy-number pattern:

X.N.N.N
1.N.N.N
N.N.X.N
1.N.X.N
N.N.N.N

Direct one-to-one assignments are then combined with the multi-copy assignments.

Appending residual RBBH assignments

After the structured orthogroup naming rules have been applied, remaining RBBHs are considered as a fallback.

The priority is:

  1. unused N2 RBBHs;
  2. unused informative AF16 RBBHs;
  3. unused AF16 CBG... assignments;
  4. unused AF16 RBBH CBG... assignments.

These assignments receive method labels such as:

rbbh_append
CBG_append
rbbh_CBG_append

This step maximizes annotation coverage while ensuring that structured, copy-number-aware assignments take priority.

Resolving duplicate names

After all naming sources are combined, the workflow checks whether the same assigned name occurs more than once.

Some apparent duplicates arise because N2 transcript identifiers encode transcript variants using trailing letters. Where possible, this transcript letter is appended to the gene name to distinguish otherwise duplicated assignments.

The resulting table is checked for two invariants:

  1. one final name per CGC2 representative transcript;
  2. one CGC2 representative transcript per final name.

These checks are important because duplicated gene names would make the resulting GFF annotation ambiguous.

Propagating names to all CGC2 isoforms

Orthology and naming are initially performed on the longest representative isoform of each CGC2 gene.

The final representative-transcript assignments are therefore joined back to the original CGC2 GFF using transcript-to-parent relationships.

Within each CGC2 gene (Parent), annotation fields are filled upward and downward so that all transcript isoforms inherit the same gene-level naming information.

L2_newatt <- cgc2_gff_ori %>%
  filter(type == "mRNA") %>%
  ... %>%
  group_by(Parent) %>%
  tidyr::fill(
    mapped_transcript,
    name,
    name_source,
    pattern,
    name_method,
    propagate_source,
    identity,
    .direction = "downup"
  ) %>%
  ungroup()

The provenance fields are converted into GFF attributes:

name_source=
name_pattern=
name_method=
propagate_source=
mapped_transcript=
match_identity=

Genes for which no orthology-supported name was obtained retain a CGC2 systematic name derived from the BRAKER gene identifier.

Rebuilding the GFF hierarchy

The annotation is reconstructed at three feature levels:

  • L1: gene
  • L2: mRNA/transcript
  • L3: exon and CDS

The newly assigned gene name and provenance fields are attached at the gene and transcript levels. Exons and CDS features inherit the appropriate gene name but do not carry the full orthology provenance metadata.

Two output conventions are generated.

Consequence-annotation format

The consequence-annotation GFF uses identifiers such as:

ID=gene:CGC2...
ID=transcript:CGC2...
ID=exon:CGC2...
ID=CDS:CGC2...

and stores the assigned name as:

sequence_name=

The final annotation is written as:

CGC2.softMasked.July2026.braker.named.csq.gff

and:

c_tropicalis.NIC58_20260722.named.csq.gff

WormBase-style format

A second GFF is generated with WormBase-like attributes including:

Name=
locus=
sequence_name=
Alias=

For genes with an informative biological name, aliases include both the assigned locus and the CGC2 systematic identifier. For unnamed genes, the systematic CGC2 identifier is retained.

The final WormBase-style annotation is written as:

CGC2.softMasked.July2026.braker.named.WB_fmt.gff

and:

c_tropicalis.NIC58_20260722.named.WB_fmt.gff

Interpretation of provenance fields

The output GFF retains explicit information about how each name was assigned.

Field Meaning
name_source Reference species from which the name originated (AF16 or N2)
name_pattern Orthogroup copy-number pattern used during assignment
name_method Specific naming rule used
mapped_transcript Reference transcript directly associated with the CGC2 assignment
propagate_source CGC2 transcript(s) whose direct orthology-supported name was propagated to other family members
match_identity Protein percent identity of the supporting CGC2-reference match

These fields make the renaming process auditable and allow direct mappings to be distinguished from inferred paralog-family propagation.

Summary of naming methods

CGC2

name_method Interpretation
direct_1to1 Direct name transfer from a single-copy ortholog
direct_map_NN Direct AF16-to-CGC2 mapping in a stable multi-copy family
direct_map_NNN Direct transfer in a fully resolved equal-copy multi-gene family
propagate_1N Single N2 name propagated across a CGC2 expansion
propagate_1N_unkAF Single N2 name propagated when AF16 copy number is unconstrained
propagate_NN_ex Existing paralog suffix series expanded to unnamed members
propagate_NNN_ex Existing suffix series expanded in an N-copy stable family
propagate_NN New numbered paralog series generated from one informative family root
propagate_NNN New numbered paralog series generated in an N-copy stable family
direct_NN_partial Ambiguous multi-name family; retain direct mappings without propagation
rbbh_append Residual informative RBBH added after structured naming
CBG_append AF16 systematic CBG identifier added as fallback
rbbh_CBG_append Residual RBBH to an AF16 CBG identifier added as fallback

CGC3

name_method Interpretation
direct_1to1 Direct name transfer from a single-copy ortholog
propagate_1N Single N2 name propagated across a CGC3 expansion
direct_map_NN Direct N2-to-CGC3 mapping in a stable multi-copy family
rbbh_append Residual informative RBBH added after structured naming

Important assumptions and limitations

The current implementation makes several explicit assumptions.

First, suffix completion for selected multi-copy families assumes no more than four members because available suffixes are drawn from 1:4.

Second, AF16 loci beginning with CBG are treated as lacking an informative biological gene name. This distinction drives the propagation logic.

Third, gene-name propagation is allowed only when the orthogroup provides evidence for a common family root. If multiple distinct informative roots are present, the workflow avoids forcing all members into a single numbered family.

Fourth, RBBHs are required to agree with OrthoFinder orthogroup membership. The procedure therefore combines local sequence similarity with gene-family context rather than relying on BLAST alone.

Finally, numbering of newly propagated paralogs is a naming convention and should not be interpreted as evidence of evolutionary order, genomic order, or ancestral/derived status unless that ordering has been established independently.

Suggested validation

Before release, the final annotation should be checked for:

# No representative transcript receives multiple names
final_names_longest_iso %>%
  count(CGC2_transcript) %>%
  filter(n > 1)

# No final name is assigned to multiple representative transcripts
final_names_longest_iso %>%
  count(name) %>%
  filter(n > 1)

# Review propagated assignments
final_names_longest_iso %>%
  filter(!is.na(propagate_source)) %>%
  arrange(Orthogroup, name)

# Summarize naming provenance
final_names_longest_iso %>%
  count(name_source, name_method, pattern)

Additional manual review is especially useful for propagated multi-copy families, low-identity RBBHs, and orthogroups receiving fallback CBG identifiers.

About

Combine OrthoFinder and Reciprocal Best Blast Hits to annotate gene names across Caenorhabditis species

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors