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

Added BCA confidence intervals #552

Merged

Conversation

austinTalbot7241993
Copy link
Collaborator

@austinTalbot7241993 austinTalbot7241993 commented Jul 29, 2024

This uses the BCA algorithm from the bootstrap to compute confidence intervals on the POE estimates.

Summary by CodeRabbit

  • New Features
    • Enhanced statistical analysis for bootstrap confidence interval computations.
    • Improved accuracy and robustness of confidence interval calculations.
  • Improvements
    • Streamlined resampling processes, improving data normalization and statistical properties.
    • Updated logic for confidence interval estimation, adding new variables for better calculations.

Copy link
Contributor

coderabbitai bot commented Jul 29, 2024

Walkthrough

The recent updates to the fit function in the parent_of_origin.py file enhance the bootstrap confidence interval calculations by improving code readability and refining statistical analysis. Key changes involve optimizing the resampling logic and introducing new variables, resulting in more robust confidence interval computations and greater accuracy in statistical assessments.

Changes

Files Change Summary
python/python/bystro/parent_of_origin/parent_of_origin.py Major modifications to the fit function, improving bootstrap confidence intervals with streamlined loop iteration, refined resampling logic, and enhanced calculation of confidence intervals.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FitFunction
    participant Bootstrap
    participant ConfidenceInterval

    User->>FitFunction: Call fit()
    FitFunction->>Bootstrap: Generate bootstrap samples using n_p_b
    Bootstrap-->>FitFunction: Return resampled data
    FitFunction->>ConfidenceInterval: Calculate confidence intervals
    ConfidenceInterval-->>FitFunction: Return confidence intervals
    FitFunction-->>User: Return results
Loading

🐇 In the meadow, hops the clever hare,
With changes made, we breathe fresh air.
Resampling brightens the data’s glow,
Confidence intervals now surely flow.
A leap of joy for stats so neat,
Our numbers dance, oh what a treat! 🌼✨


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.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

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.

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between eaec328 and 75e4512.

Files selected for processing (1)
  • python/python/bystro/parent_of_origin/parent_of_origin.py (3 hunks)
Additional comments not posted (7)
python/python/bystro/parent_of_origin/parent_of_origin.py (7)

331-332: Introduce a new variable for readability

The introduction of n_p_b for self.n_permutations_bootstrap improves readability.


334-335: Initialize confidence interval storage

The initialization of ci_eigenvector for storing confidence intervals is necessary for the subsequent calculations.


335-339: Initialize bootstrap samples storage

The initialization of bootstrap_samples_ for storing bootstrap samples is necessary for the resampling process.


340-347: Resampling logic using X_het_whitened

The resampling logic has been updated to use X_het_whitened, which likely improves the statistical properties of the samples generated.


366-368: Define alpha values for confidence intervals

The definition of alpha, alpha1, and alpha2 is necessary for the computation of the confidence intervals.


369-415: Compute BCA confidence intervals

The computation of BCA confidence intervals is a significant enhancement that adds robustness to the confidence interval estimation.


417-417: Store computed confidence intervals

The computed confidence intervals are stored in self.confidence_interval_, replacing the previous method of storing bootstrap samples and quantiles.

jackknife_mean_vector_component = (
j_values_vector_component.mean()
)
a_vector_component = np.sum(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you explain the constants here (** 3, 6.0 * np.sum, **1.5, etc) or reference the equation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Referenced the equation, it requires a whole chapter to explain basically.

Copy link
Collaborator

@akotlar akotlar left a comment

Choose a reason for hiding this comment

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

LGTM

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 75e4512 and a38a58f.

Files selected for processing (1)
  • python/python/bystro/parent_of_origin/parent_of_origin.py (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • python/python/bystro/parent_of_origin/parent_of_origin.py

@austinTalbot7241993 austinTalbot7241993 merged commit aeb8f8c into bystrogenomics:master Jul 31, 2024
8 checks passed
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