Skip to content
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

Add quality control property for batch processing over genotypes #76

Conversation

eberrigan
Copy link
Collaborator

@eberrigan eberrigan commented Apr 23, 2024

  • add qc_fail property to Series
  • modify batch statistics using qc_fail flag to remove unwanted samples

Summary by CodeRabbit

  • New Features

    • Enhanced data integrity by introducing a qc_fail property in the Series class to indicate quality control failures during trait computations.
  • Bug Fixes

    • Ensured accurate trait analysis by updating trait computation functions to skip series marked with a quality control failure.
  • Tests

    • Validated the new qc_fail property with tests to accurately identify series failing quality control.

Copy link
Contributor

coderabbitai bot commented Apr 23, 2024

Walkthrough

The latest update introduces a qc_fail property to the Series class, enhancing the quality control process by skipping series flagged for QC failures in trait computations. This addition is supported by modifications in both series management and trait calculation functions, along with corresponding updates in unit tests to ensure robustness.

Changes

File Path Change Summary
sleap_roots/series.py, sleap_roots/trait_pipelines.py Added qc_fail property to Series; updated trait computation functions to skip series with QC failures; added logging for skipped series.
tests/test_series.py Updated CSV data structure in tests; added new test to verify qc_fail functionality.

🐰✨
A hop, a skip, a code deploy,
In fields of data, we find our joy.
Quality checked, no trait left unchecked,
With every commit, closer to perfect.
Cheers to the code, from dusk till dawn! 🌟
🐰💻


Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between ec56e0f and 05336f5.
Files selected for processing (1)
  • sleap_roots/series.py (2 hunks)
Additional Context Used
Ruff (1)
sleap_roots/series.py (1)

359-359: Do not compare types, use isinstance()

GitHub Check Runs (1)
codecov/patch success (3)

sleap_roots/series.py: [warning] 169-170: sleap_roots/series.py#L169-L170
Added lines #L169 - L170 were not covered by tests


sleap_roots/series.py: [warning] 175-177: sleap_roots/series.py#L175-L177
Added lines #L175 - L177 were not covered by tests


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

Copy link
Contributor

@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: 1

Actionable comments outside the diff hunks (3)
tests/test_series.py (2)

Line range hint 2-2: Remove the unused import of numpy.

- import numpy as np

Line range hint 79-79: Rename the second test_series_name function to avoid redefinition and clarify its purpose.

- def test_series_name(series_instance):
+ def test_series_name_from_instance(series_instance):
sleap_roots/series.py (1)

Line range hint 359-359: Replace type comparison with isinstance() for better practice.

-    if type(data_folders) != list:
+    if not isinstance(data_folders, list):

Comment on lines 165 to 177
@property
def qc_fail(self) -> bool:
"""Flag to indicate if the series failed QC from the CSV."""
if not self.csv_path or not Path(self.csv_path).exists():
print("CSV path is not set or the file does not exist.")
return np.nan
df = pd.read_csv(self.csv_path)
try:
# Match the series_name (or plant_qr_code in the CSV) to fetch the QC flag
return df[df["plant_qr_code"] == self.series_name]["qc_cylinder"].iloc[0]
except IndexError:
print(f"No QC flag found for series {self.series_name} in CSV.")
return np.nan
Copy link
Contributor

Choose a reason for hiding this comment

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

Change the return value of qc_fail to False when the CSV path is not set or the QC flag is not found, to maintain consistency with the expected boolean return type.

-            return np.nan
+            return False
-            return np.nan
+            return False

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.

Suggested change
@property
def qc_fail(self) -> bool:
"""Flag to indicate if the series failed QC from the CSV."""
if not self.csv_path or not Path(self.csv_path).exists():
print("CSV path is not set or the file does not exist.")
return np.nan
df = pd.read_csv(self.csv_path)
try:
# Match the series_name (or plant_qr_code in the CSV) to fetch the QC flag
return df[df["plant_qr_code"] == self.series_name]["qc_cylinder"].iloc[0]
except IndexError:
print(f"No QC flag found for series {self.series_name} in CSV.")
return np.nan
@property
def qc_fail(self) -> bool:
"""Flag to indicate if the series failed QC from the CSV."""
if not self.csv_path or not Path(self.csv_path).exists():
print("CSV path is not set or the file does not exist.")
return False
df = pd.read_csv(self.csv_path)
try:
# Match the series_name (or plant_qr_code in the CSV) to fetch the QC flag
return df[df["plant_qr_code"] == self.series_name]["qc_cylinder"].iloc[0]
except IndexError:
print(f"No QC flag found for series {self.series_name} in CSV.")
return False

Copy link

codecov bot commented Apr 23, 2024

Codecov Report

Attention: Patch coverage is 42.85714% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 74.58%. Comparing base (f8baa7b) to head (05336f5).

Files Patch % Lines
sleap_roots/series.py 54.54% 5 Missing ⚠️
sleap_roots/trait_pipelines.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #76      +/-   ##
==========================================
- Coverage   74.92%   74.58%   -0.34%     
==========================================
  Files          13       13              
  Lines        1312     1326      +14     
==========================================
+ Hits          983      989       +6     
- Misses        329      337       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@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: 1

Comment on lines +168 to +177
if not self.csv_path or not Path(self.csv_path).exists():
print("CSV path is not set or the file does not exist.")
return np.nan
df = pd.read_csv(self.csv_path)
try:
# Match the series_name (or plant_qr_code in the CSV) to fetch the QC flag
return df[df["plant_qr_code"] == self.series_name]["qc_cylinder"].iloc[0]
except IndexError:
print(f"No QC flag found for series {self.series_name} in CSV.")
return np.nan
Copy link
Contributor

Choose a reason for hiding this comment

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

Change the return value of qc_fail to False when the CSV path is not set or the QC flag is not found, to maintain consistency with the expected boolean return type.

-            return np.nan
+            return False
-            return np.nan
+            return False

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.

Suggested change
if not self.csv_path or not Path(self.csv_path).exists():
print("CSV path is not set or the file does not exist.")
return np.nan
df = pd.read_csv(self.csv_path)
try:
# Match the series_name (or plant_qr_code in the CSV) to fetch the QC flag
return df[df["plant_qr_code"] == self.series_name]["qc_cylinder"].iloc[0]
except IndexError:
print(f"No QC flag found for series {self.series_name} in CSV.")
return np.nan
if not self.csv_path or not Path(self.csv_path).exists():
print("CSV path is not set or the file does not exist.")
return False
df = pd.read_csv(self.csv_path)
try:
# Match the series_name (or plant_qr_code in the CSV) to fetch the QC flag
return df[df["plant_qr_code"] == self.series_name]["qc_cylinder"].iloc[0]
except IndexError:
print(f"No QC flag found for series {self.series_name} in CSV.")
return False

@eberrigan eberrigan merged commit 035b153 into main Apr 23, 2024
5 checks passed
@eberrigan eberrigan deleted the elizabeth/Add-quality-control--property-for-batch-processing-over-genotypes branch April 23, 2024 16:32
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