Skip to content

feat: add circle annotations #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 30 commits into
base: main
Choose a base branch
from
Draft

Conversation

dlaehnemann
Copy link
Member

@dlaehnemann dlaehnemann commented Jun 11, 2025

Summary by CodeRabbit

  • New Features

    • Added new workflow steps for automated genomic annotation retrieval, harmonization, and annotation of circle regions.
    • Introduced environment configurations for annotation tools to ensure reproducible analysis.
    • Included new scripts for generating transcript-to-gene mappings and creating harmonized annotation files.
  • Chores

    • Updated configuration files to use the latest Ensembl release and adjusted chromosome settings for improved flexibility.
  • Refactor

    • Improved data handling in circle region processing for greater consistency and maintainability.

Copy link

coderabbitai bot commented Jun 11, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce new annotation processing capabilities to the workflow, including rules and scripts for retrieving, harmonizing, and annotating genomic and regulatory features. New Conda environments are defined for these steps. Configuration files are updated for Ensembl release version and chromosome handling. Minor code improvements and utility functions are also added.

Changes

File(s) Change Summary
.test/config/config.yaml, config/config.yaml Updated Ensembl release version from 108 to 112; commented out chromosome restriction in test config.
workflow/envs/annotatr.yaml, workflow/envs/biomart.yaml, workflow/envs/rtracklayer.yaml Added new Conda environment YAML files for annotatr, biomart, and rtracklayer with specific dependencies.
workflow/rules/circle_map.smk Added new Snakemake rule annotate_cleaned_circles for annotating cleaned circle TSVs using R script.
workflow/rules/common.smk Added utility function get_bioc_species_name() for species name formatting.
workflow/rules/ref.smk Added five new rules for annotation retrieval, regulatory features, transcript-to-gene mapping, and harmonization.
workflow/scripts/annotate_cleaned_circles.R New R script for annotating circles with overlapping genomic features and exporting per-circle TSVs.
workflow/scripts/create_annotation_gff3.R New R script to harmonize and combine genomic/regulatory annotations into a single GFF3 file.
workflow/scripts/create_transcripts_to_genes_mappings.R New R script to generate transcript-to-gene mappings using biomaRt, with chromosome filtering.
workflow/scripts/clean_circle_map_realign_output.py Refactored DataFrame integer conversion logic for clarity and maintainability.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Snakemake
    participant R_Scripts
    participant Conda_Env

    User->>Snakemake: Trigger workflow
    Snakemake->>Conda_Env: Activate biomart/rtracklayer/annotatr envs as needed
    Snakemake->>R_Scripts: Run create_transcripts_to_genes_mappings.R
    Snakemake->>R_Scripts: Run create_annotation_gff3.R
    Snakemake->>R_Scripts: Run annotate_cleaned_circles.R
    R_Scripts->>Snakemake: Output harmonized annotation files and per-circle TSVs
Loading

Poem

A rabbit hopped through fields of code,
Bringing annotations down the road.
With scripts and rules, environments new,
Genomic secrets came into view.
Circles and genes, now hand in hand—
The workflow blooms across the land!
🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dlaehnemann dlaehnemann marked this pull request as draft June 11, 2025 18:52
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🧹 Nitpick comments (5)
workflow/envs/rtracklayer.yaml (1)

1-7: Normalize YAML formatting and add EOF newline.
Ensure consistent spacing around the = in version specs (e.g., change bioconductor-rtracklayer =1.62 to = 1.62) and add a final newline to satisfy linters.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 7-7: no new line character at the end of file

(new-line-at-end-of-file)

workflow/envs/annotatr.yaml (1)

1-7: Normalize YAML formatting and add EOF newline.
Ensure consistent spacing around the = in version specs (e.g., change bioconductor-annotatr =1.28 to = 1.28) and append a trailing newline for YAML lint compliance.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 7-7: no new line character at the end of file

(new-line-at-end-of-file)

workflow/envs/biomart.yaml (1)

1-7: Normalize YAML formatting and add EOF newline.
Standardize spacing around = in version pins (e.g., bioconductor-biomart = 2.58) and include a final newline to avoid linter errors.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 7-7: no new line character at the end of file

(new-line-at-end-of-file)

.test/config/config.yaml (1)

18-18: Improve comment formatting.
Add a space after # for consistency (change #chromosome: 7 to # chromosome: 7).

workflow/rules/common.smk (1)

86-90: get_bioc_species_name() produces the desired abbreviation but is fragile

– Fails hard if config["ref"]["species"] is missing the expected single underscore (e.g. "drosophila_melanogaster", "pan_troglodytes" are fine, but "yeast" is not).
– Upper-/lower-case is preserved; Bioconductor dataset names expect e.g. Hsapiens, Mmusculus, etc. If config["ref"]["species"] starts all-lower-case ("homo_sapiens"), the function will return hsapiens, which will not match package names.

Consider adding minimal validation & normalisation:

+def get_bioc_species_name():
+    parts = config["ref"]["species"].split("_")
+    if len(parts) != 2:
+        raise ValueError("`ref.species` must be of the form 'Genus_species'")
+    genus, species = parts
+    return f"{genus[0].upper()}{species.lower()}"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 545be19 and dd80d0b.

📒 Files selected for processing (12)
  • .test/config/config.yaml (1 hunks)
  • config/config.yaml (1 hunks)
  • workflow/envs/annotatr.yaml (1 hunks)
  • workflow/envs/biomart.yaml (1 hunks)
  • workflow/envs/rtracklayer.yaml (1 hunks)
  • workflow/rules/circle_map.smk (1 hunks)
  • workflow/rules/common.smk (1 hunks)
  • workflow/rules/ref.smk (1 hunks)
  • workflow/scripts/annotate_cleaned_circles.R (1 hunks)
  • workflow/scripts/clean_circle_map_realign_output.py (1 hunks)
  • workflow/scripts/create_annotation_gff3.R (1 hunks)
  • workflow/scripts/create_transcripts_to_genes_mappings.R (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.test/config/config.yaml

[error] 15-15: trailing spaces

(trailing-spaces)

workflow/envs/biomart.yaml

[error] 7-7: no new line character at the end of file

(new-line-at-end-of-file)

workflow/envs/annotatr.yaml

[error] 7-7: no new line character at the end of file

(new-line-at-end-of-file)

workflow/envs/rtracklayer.yaml

[error] 7-7: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (11)
workflow/envs/rtracklayer.yaml (1)

1-4: Verify the nodefaults channel usage.
Confirm that your Conda parser supports nodefaults to disable default channels, or consider using the no_default_channels: true directive for compatibility.

workflow/envs/annotatr.yaml (1)

1-4: Verify the nodefaults channel usage.
Make sure nodefaults is recognized by your environment resolver or switch to the standard no_default_channels flag if needed.

workflow/envs/biomart.yaml (1)

1-4: Verify the nodefaults channel usage.
Double-check that nodefaults is a valid mechanism to disable defaults in your Conda setup, or prefer no_default_channels: true for clarity.

config/config.yaml (1)

12-12: Updated Ensembl release to 112.
The release version was bumped to 112 to align with new annotation rules and scripts—please confirm compatibility across downstream Snakemake rules and R scripts.

.test/config/config.yaml (1)

12-12: Align test config with main release version.
Test configuration now uses release: 112; ensure test fixtures and CI pipelines are updated accordingly.

workflow/scripts/create_annotation_gff3.R (4)

1-4: LGTM!

Proper logging setup for capturing both standard output and error messages.


5-9: LGTM!

Good practice to enable global error tracing with rlang::global_entrace() for better debugging capabilities.


84-115: LGTM!

Well-structured data transformation with proper handling of empty values and filtering of incomplete entries.


193-196: LGTM!

Proper sorting of genomic ranges before export ensures consistent output.

workflow/rules/ref.smk (2)

116-116:

❓ Verification inconclusive

Verify wrapper version compatibility.

The new rules use wrapper version v3.13.6 while existing rules use v1.21.x. This significant version jump may introduce compatibility issues.

Please verify that:

  1. The newer wrapper version is compatible with your Snakemake version
  2. The version jump is intentional and tested
  3. Consider updating all wrapper versions consistently across the workflow

Also applies to: 130-130


🏁 Script executed:

#!/bin/bash
# Check all wrapper versions in the workflow
echo "Wrapper versions used in the workflow:"
rg -A1 'wrapper:' --no-heading | grep -E 'v[0-9]+\.[0-9]+\.[0-9]+' | sort | uniq -c

Length of output: 1337


Verify wrapper version consistency and compatibility

The workflow currently mixes wrapper versions across rules:

  • workflow/rules/ref.smk (lines 116–117):
    • "v3.13.6/bio/reference/ensembl-annotation"
    • "v3.13.6/bio/reference/ensembl-regulation"
  • workflow/rules/datavzrd.smk:
    • "v3.8.0/utils/datavzrd"
  • All other rules (circle_map.smk, mapping.smk, trimming.smk, utils.smk, ref.smk):
    • v1.21.x wrappers (e.g., "v1.21.2/bio/samtools/sort", "v1.21.1/bio/bwa/index")

Please confirm that:

  1. Your Snakemake version supports wrappers from both the v3.x and v1.x branches.
  2. The jump to v3.13.6 for the Ensembl annotation/regulation wrappers is intentional and has been tested.
  3. You’ve evaluated whether you want to standardize on a single wrapper major version (or explicitly pin mixed versions) to reduce maintenance risk.

158-159: ⚠️ Potential issue

Fix missing comma after log file path.

Missing comma after the log file path will cause a Snakemake syntax error.

     log:
-        "logs/all_annotations.harmonized.gff3.log"
+        "logs/all_annotations.harmonized.gff3.log",
     conda:

Likely an incorrect or invalid review comment.

Comment on lines 35 to 37
# turn int cols into int
circles.loc[:, int_cols] = circles.loc[:, int_cols].round(0).applymap(lambda v: int(v) if not pd.isna(v) else pd.NA)
circles[int_cols] = circles[int_cols].round(0).map(lambda v: int(v) if not pd.isna(v) else pd.NA)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

.map() on a DataFrame raises AttributeError – use .applymap() or column-wise logic

DataFrame objects do not implement .map; only Series do.
This line will therefore crash before any output is written.

-circles[int_cols] = circles[int_cols].round(0).map(lambda v: int(v) if not pd.isna(v) else pd.NA)
+# convert each value to integer while keeping NA
+circles[int_cols] = (
+    circles[int_cols]
+        .round(0)
+        .applymap(lambda v: pd.NA if pd.isna(v) else int(v))
+)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# turn int cols into int
circles.loc[:, int_cols] = circles.loc[:, int_cols].round(0).applymap(lambda v: int(v) if not pd.isna(v) else pd.NA)
circles[int_cols] = circles[int_cols].round(0).map(lambda v: int(v) if not pd.isna(v) else pd.NA)
# turn int cols into int
# convert each value to integer while keeping NA
circles[int_cols] = (
circles[int_cols]
.round(0)
.applymap(lambda v: pd.NA if pd.isna(v) else int(v))
)
🤖 Prompt for AI Agents
In workflow/scripts/clean_circle_map_realign_output.py around lines 35 to 37,
the code incorrectly uses .map() on a DataFrame, which causes an AttributeError
because .map() is only available on Series. To fix this, replace .map() with
.applymap() to apply the lambda function element-wise across the DataFrame, or
alternatively apply the lambda function column-wise to each Series in int_cols.

Comment on lines 81 to 96
rule annotate_cleaned_circles:
input:
all_annotations="resources/all_annotations.harmonized.gff3.gz",
tsv="results/circle-map/{sample}.circles.cleaned.tsv",
output:
tsvs=directory(
"results/circle-map/{sample}.circles.cleaned.annotated/"
),
log:
"logs/circle-map/{sample}.circles.cleaned.annotated.logs",
conda:
"../envs/annotatr.yaml"
params:
build=config["ref"]["build"],
script:
"../scripts/annotate_cleaned_circles.R"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Output directory declared, but the R script never writes to it

annotate_cleaned_circles.R creates files in the current working directory via file.path(...), yet the rule’s declared output is
results/circle-map/{sample}.circles.cleaned.annotated/.

Snakemake will mark the rule as incomplete because the declared directory is still empty.
Pass the directory path to the script and create it there, e.g.:

 output:
-    tsvs=directory("results/circle-map/{sample}.circles.cleaned.annotated/")
+    outdir=directory("results/circle-map/{sample}.circles.cleaned.annotated/")
 ...
 params:
     build=config["ref"]["build"],
+    outdir=lambda wc: f"results/circle-map/{wc.sample}.circles.cleaned.annotated",
 script:
     "../scripts/annotate_cleaned_circles.R"

and in the R script use snakemake@params[["outdir"]] + dir.create(outdir, recursive=TRUE).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
rule annotate_cleaned_circles:
input:
all_annotations="resources/all_annotations.harmonized.gff3.gz",
tsv="results/circle-map/{sample}.circles.cleaned.tsv",
output:
tsvs=directory(
"results/circle-map/{sample}.circles.cleaned.annotated/"
),
log:
"logs/circle-map/{sample}.circles.cleaned.annotated.logs",
conda:
"../envs/annotatr.yaml"
params:
build=config["ref"]["build"],
script:
"../scripts/annotate_cleaned_circles.R"
rule annotate_cleaned_circles:
input:
all_annotations="resources/all_annotations.harmonized.gff3.gz",
tsv="results/circle-map/{sample}.circles.cleaned.tsv",
output:
outdir=directory("results/circle-map/{sample}.circles.cleaned.annotated/"),
log:
"logs/circle-map/{sample}.circles.cleaned.annotated.logs",
conda:
"../envs/annotatr.yaml"
params:
build=config["ref"]["build"],
outdir=lambda wc: f"results/circle-map/{wc.sample}.circles.cleaned.annotated",
script:
"../scripts/annotate_cleaned_circles.R"
🤖 Prompt for AI Agents
In workflow/rules/circle_map.smk around lines 81 to 96, the rule declares an
output directory results/circle-map/{sample}.circles.cleaned.annotated/ but the
R script annotate_cleaned_circles.R does not write files there, causing
Snakemake to see the output as missing. Fix this by passing the output directory
path as a parameter to the R script via params (e.g., add outdir=params.build or
a new param outdir with the output directory path), then modify the R script to
read this parameter using snakemake@params[["outdir"]], create the directory if
needed with dir.create(outdir, recursive=TRUE), and write all output files into
this directory.

Comment on lines 98 to 108
group_walk(
~ write_tsv(
.x,
file = file.path(
str_c(
str_replace_all(.y$circle_region, "[:-]", "_"),
".tsv"
)
)
)
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Files written outside the declared output directory

The call

file = file.path(str_c(str_replace_all(.y$circle_region, "[:-]", "_"), ".tsv"))

creates files in getwd(). The Snakemake rule expects them under the output directory.

Add:

outdir <- snakemake@params[["outdir"]]
dir.create(outdir, recursive = TRUE, showWarnings = FALSE)
...
file = file.path(outdir,
                 str_c(str_replace_all(.y$circle_region, "[:-]", "_"), ".tsv"))
🤖 Prompt for AI Agents
In workflow/scripts/annotate_cleaned_circles.R around lines 98 to 108, the code
writes output files directly to the working directory instead of the Snakemake
output directory. To fix this, retrieve the output directory path from
snakemake@params[["outdir"]], create the directory if it doesn't exist using
dir.create with recursive=TRUE and showWarnings=FALSE, and update the file path
in write_tsv to write files inside this output directory by prepending outdir to
the file path.

Comment on lines +17 to +23
circles_gr <- GRanges(
seqnames = pull(circles, region),
ecDNA_status = "ecDNA"
)

genome(circles_gr) <- genome_build

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

GRanges construction is missing start/end coordinates → runtime error

GRanges() requires a ranges argument (IRanges). Supplying only seqnames will throw
argument "ranges" is missing, with no default”.

Parse the region column first:

-regions = pull(circles, region),
-ecDNA_status = "ecDNA"
+seqnames = sub(":.*", "", circles$region),
+ranges   = IRanges(
+    start = as.integer(sub(".*:(\\d+)-.*", "\\1", circles$region)),
+    end   = as.integer(sub(".*-(\\d+)$", "\\1", circles$region))
+),
+ecDNA_status = "ecDNA"

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In workflow/scripts/annotate_cleaned_circles.R around lines 17 to 23, the
GRanges object is constructed without specifying the required start and end
coordinates, causing a runtime error. Extract the start and end positions from
the 'region' column (which likely contains genomic coordinates) and create an
IRanges object to pass as the 'ranges' argument in GRanges. This will fix the
missing argument error and correctly define the genomic ranges.

Comment on lines 16 to 26
if (wanted_build == "GRCh37") {
grch <- "37"
version <- NULL
cli_warn(c(
"As you specified build 'GRCH37' in your configuration yaml, biomart forces",
"us to ignore the release you specified ('{release}')."
))
} else {
grch <- NULL
version <- wanted_release
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

cli_warn() references undefined variable {release}

{release} is not in scope (should be {wanted_release}), causing glue evaluation to fail.

-cli_warn(c(
-  "As you specified build 'GRCH37' in your configuration yaml, biomart forces",
-  "us to ignore the release you specified ('{release}')."
-))
+cli_warn(c(
+  "As you specified build 'GRCh37' in your configuration yaml, biomart forces",
+  "us to ignore the release you specified ('{wanted_release}')."
+))
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (wanted_build == "GRCh37") {
grch <- "37"
version <- NULL
cli_warn(c(
"As you specified build 'GRCH37' in your configuration yaml, biomart forces",
"us to ignore the release you specified ('{release}')."
))
} else {
grch <- NULL
version <- wanted_release
}
if (wanted_build == "GRCh37") {
grch <- "37"
version <- NULL
cli_warn(c(
"As you specified build 'GRCh37' in your configuration yaml, biomart forces",
"us to ignore the release you specified ('{wanted_release}')."
))
} else {
grch <- NULL
version <- wanted_release
}
🤖 Prompt for AI Agents
In workflow/scripts/create_transcripts_to_genes_mappings.R around lines 16 to
26, the cli_warn() call references an undefined variable {release} which causes
glue evaluation to fail. Replace {release} with the correctly scoped variable
{wanted_release} in the warning message to fix the issue.

Comment on lines 42 to 50
if (retrieved_build != build) {
cli_abort(c(
"Ensembl release and genome build number in your configuration are not compatible.",
"x" = "Genome build '{build}' not available via biomart for Ensembl release '{release}''.",
"i" = "Ensembl release '{release}' only provides build '{retrieved_build}'.",
" " = "Please fix your configuration yaml file's reference entry, you have two options:",
"*" = "Change the build entry to '{retrieved_build}'.",
"*" = "Change the release entry to one that provides build '{build}'. You have to determine this from biomart by yourself."
))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

cli_abort() strings also reference missing variable release

Inside get_mart() only version is available, not release; this will error at runtime.

-      "x" = "Genome build '{build}' not available via biomart for Ensembl release '{release}''.",
-      "i" = "Ensembl release '{release}' only provides build '{retrieved_build}'.",
+      "x" = "Genome build '{build}' not available via biomart for Ensembl release '{version}'.",
+      "i" = "Ensembl release '{version}' only provides build '{retrieved_build}'.",
🤖 Prompt for AI Agents
In workflow/scripts/create_transcripts_to_genes_mappings.R around lines 42 to
50, the cli_abort() call references a variable named release which is not
defined or available in this scope; only version is accessible inside
get_mart(). To fix this, replace all instances of release in the cli_abort()
message with version or ensure the correct variable holding the Ensembl release
number is used consistently to avoid runtime errors.

Comment on lines 188 to 190
dplyr::rename(
ensemble_id = id
) |>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix typo in column name.

The column name should be ensembl_id instead of ensemble_id. Ensembl is the name of the genomic database.

   dplyr::rename(
-    ensemble_id = id
+    ensembl_id = id
   ) |>
🤖 Prompt for AI Agents
In workflow/scripts/create_annotation_gff3.R around lines 188 to 190, there is a
typo in the column rename operation where the column is renamed to "ensemble_id"
instead of the correct "ensembl_id". Change the rename argument from ensemble_id
= id to ensembl_id = id to correctly reflect the genomic database name.

Comment on lines +47 to +62
separate_wider_delim(
ID,
delim = ":",
names = c("id_type", "id")
) |>
dplyr::select(-id_type) |>
unnest(
Parent,
keep_empty = TRUE
) |>
separate_wider_delim(
Parent,
delim = ":",
names = c("parent_type", "parent_id")
) |>
dplyr::rename(name = Name)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add validation for ID and Parent format assumptions.

The code assumes IDs and Parents contain a ":" delimiter. Consider adding validation or error handling for cases where this format is not present.

Add validation before the separation:

+  # Validate ID format
+  if (!all(str_detect(.$ID, ":"))) {
+    warning("Some IDs do not contain ':' delimiter, these will be handled incorrectly")
+  }
   separate_wider_delim(
     ID,
     delim = ":",
     names = c("id_type", "id")
   ) |>

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In workflow/scripts/create_annotation_gff3.R around lines 47 to 62, the code
assumes that the ID and Parent fields contain a ":" delimiter for separation,
but this may not always be true. Add validation checks before calling
separate_wider_delim to confirm that these fields contain the ":" delimiter. If
the delimiter is missing, handle the case gracefully by either logging a
warning, skipping the separation, or providing a default value to avoid errors
during processing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant