Skip to content

fix: Add support for Drosophila melanogaster #142

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

Merged
merged 2 commits into from
Mar 11, 2025

Conversation

DanielM812
Copy link
Contributor

@DanielM812 DanielM812 commented Mar 10, 2025

I noticed two errors that occured while working with RNA-Seq data from Drosophila melanogaster and tried to fix them:

1. Gene names for the fruit fly can sometimes have a colon in them, when belonging to a gene family (e.g. His4:CG33869 and His4:CG31611). This leads to an error when selecting the correct name and value in postprocess_go_enrichment.py as they are also separated by a colon. The separation then results in three parts (His4, CG33869, 0.73842) instead of two parts.
2. For Drosophila melanogaster the "ensembl_transcript_id_version" attribute from the Ensembl mart does not exist. This attribute is part of the 3-prime attributes which (I assume?) are not needed for standard RNA-Seq analysis.

Summary by CodeRabbit

  • Bug Fixes
    • Improved transcript processing to dynamically detect and use available identifier attributes, enhancing output stability.
    • Enhanced gene value extraction to accurately handle varied input formats, ensuring more reliable results.

Copy link
Contributor

coderabbitai bot commented Mar 10, 2025

Walkthrough

The changes update two scripts by refining how attributes and parsed values are handled. In the R script, the attribute "ensembl_transcript_id_version" is now conditionally included via a helper function and renamed robustly using a flexible approach. In the Python script, the extract_study_items function has been modified to extract gene information from different positions in a split string. No public or exported entities were affected.

Changes

File(s) Change Summary
workflow/.../get-transcript-info.R Uses use_if_available to conditionally include "ensembl_transcript_id_version" for three_prime_attributes and applies any_of for robust column renaming.
workflow/.../postprocess_go_enrichment.py Adjusts indexing in extract_study_items to retrieve the gene name from parts[-2] and its value from parts[-1] after splitting the input string.

Sequence Diagram(s)

sequenceDiagram
    participant RScript as get-transcript-info.R
    participant AttrFunc as use_if_available
    participant Data as available_attributes
    RScript->>AttrFunc: Check for "ensembl_transcript_id_version"
    alt Attribute Exists
        AttrFunc-->>RScript: Return attribute value
    else Attribute Missing
        AttrFunc-->>RScript: Return NULL/skip
    end
    RScript->>RScript: Rename column with any_of in other_annotations
Loading
sequenceDiagram
    participant Func as extract_study_items
    participant Input as raw_input_string
    participant Split as parts_list
    Func->>Input: Receive input string
    Func->>Split: Split string by delimiter
    Note over Func: Use parts[-2] for gene, parts[-1] for value
    Func->>Func: Process and assign gene data
Loading

Poem

Hop, hop, through lines of code I race,
Checking attributes at a steady pace.
With functions guiding every twist,
Parsing genes through each new list.
A joyful bound from bug to grace!
🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d0e6e78 and 075315f.

📒 Files selected for processing (2)
  • workflow/scripts/get-transcript-info.R (2 hunks)
  • workflow/scripts/postprocess_go_enrichment.py (1 hunks)
🔇 Additional comments (3)
workflow/scripts/postprocess_go_enrichment.py (1)

19-20:

❓ Verification inconclusive

Verify the gene name extraction works for all Drosophila melanogaster gene formats

The change from fixed indexing to negative indexing addresses the issue with gene names containing colons (like "His4:CG33869"). However, this approach assumes a specific format where the gene identifier is always the second-to-last part after splitting on colons.

For gene names with multiple colons, this approach might not capture the complete gene name. Consider a more robust solution if you need to handle diverse gene name formats in the future.


🏁 Script executed:

#!/bin/bash
# Check for different gene:value patterns in the input data
echo "Checking for various gene:value patterns in GO enrichment data..."
grep -o "[^,]*:[^,]*" $(find workflow -name "*go_enrichment*" -type f | head -1) | sort | uniq -c | sort -nr | head -10

Length of output: 672


Action required: Verify gene name extraction comprehensively

The revised extraction using negative indices (i.e. gene = parts[-2]) now correctly handles gene names with a single colon (e.g., "His4:CG33869"). However, this solution still assumes that the gene identifier is always the second-to-last segment when splitting on colons. If a gene name contains multiple colons, the current logic might not capture the intended full identifier.

  • Please validate the extraction logic against actual GO enrichment input data containing diverse Drosophila gene formats.
  • If you encounter gene names with more than one colon, consider refining the parsing mechanism (or adding unit tests) to ensure the full gene identifier is reliably retrieved.
workflow/scripts/get-transcript-info.R (2)

93-93: Good defensive programming approach

Using the use_if_available function to conditionally include the "ensembl_transcript_id_version" attribute is an excellent approach. This makes the code more robust by ensuring it works correctly even when this attribute is not available for certain species like Drosophila melanogaster.


175-175: Proper handling of conditional column renaming

Using any_of() in the rename function ensures that the operation won't fail if the "ensembl_transcript_id_version" column doesn't exist. This is a good defensive programming practice that improves the robustness of the code.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

@DanielM812 DanielM812 changed the title Add support for Drosophila melanogaster fix: Add support for Drosophila melanogaster Mar 10, 2025
Copy link
Member

@dlaehnemann dlaehnemann left a comment

Choose a reason for hiding this comment

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

Thanks for these generalizations. Good catches, and sorry for the inconvenience.

@dlaehnemann dlaehnemann merged commit dedfdf7 into snakemake-workflows:main Mar 11, 2025
6 of 8 checks passed
dlaehnemann pushed a commit that referenced this pull request Mar 11, 2025
🤖 I have created a release *beep* *boop*
---


##
[2.9.0](v2.8.4...v2.9.0)
(2025-03-11)


### Features

* Make PCA plots interactive and switch to HTML format
([#137](#137))
([d0e6e78](d0e6e78))


### Bug Fixes

* add support for drosophila melanogaster and other non-standard species
([#142](#142))
([dedfdf7](dedfdf7))
* Improve error handling for missing or empty column values in dataframe
with duplicate definitions
([#138](#138))
([7f3d590](7f3d590))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants