Skip to content

Environment stratification tool#6093

Open
chris263 wants to merge 4 commits into
masterfrom
topic/env_stratification
Open

Environment stratification tool#6093
chris263 wants to merge 4 commits into
masterfrom
topic/env_stratification

Conversation

@chris263
Copy link
Copy Markdown
Contributor

@chris263 chris263 commented May 5, 2026

Description

This PR adds the new Environment Stratification tool to Breedbase.

The tool allows users to select a dataset and trait, run environment stratification analysis, and review compatible environment groups based on genotype-by-
environment interaction. Results are returned through a new AJAX controller, processed by an R backend script, and displayed in a dedicated Mason/JavaScript
interface.

Main Features

  • New Environment Stratification page and UI.
  • Dataset and trait selection using existing Breedbase dataset tools.
  • R-based environment stratification analysis.
  • Pairwise environment compatibility testing.
  • Group summary output for statistically compatible environments.
  • ANOVA output tab with automatic experimental design detection.
  • Ungrouped environment output.
  • Interactive map showing trial locations and environment groups.
  • Hover tooltips on map markers showing location and trial name.
  • XLSX downloads for result tables.

ANOVA / Design Handling

The R script detects the available experimental design information and builds the ANOVA model accordingly.

Supported fixed-effect ANOVA structures include:

  • CRD
  • RCBD
  • Incomplete block / alpha-lattice
  • Augmented / block-only
  • Row-column / augmented row-column

Row and column terms are only used when the trial design is explicitly row-column/spatial. They are ignored for CRD and RCBD even if coordinate columns are present.

Screenshot from 2026-05-05 14-36-05 image

Checklist

  • Refactoring only
  • Documentation only
  • Fixture update only
  • Bug fix
    • The relevant issue has been closed.
    • Further work is required.
  • [ x] New feature
    • Relevant tests have been created and run.
    • Data was added to the fixture
      • Data was added via a patch in /t/data/fixture/patches/.
    • User-Facing Change
      • The user manual in /docs has been updated.
    • Any new Perl has been documented using perldoc.
    • Any new JavaScript has been documented using JSDoc.
    • Any new legacy JavaScript has been moved from /js to /js/source/legacy.

Copy link
Copy Markdown
Contributor

@ryan-preble ryan-preble left a comment

Choose a reason for hiding this comment

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

The tool works well and shows up properly on the job submissions table - good work!
It would also be good to add some lines to the tool compatibility function to display dataset compatibility with the analysis.

Copy link
Copy Markdown
Member

@lukasmueller lukasmueller left a comment

Choose a reason for hiding this comment

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

check comment about login requirement

:-)

map => { 'application/json' => 'JSON' },
);

sub shared_phenotypes : Path('/ajax/environment_stratification/shared_phenotypes') : {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should these functions be only available to logged in users?

@chris263
Copy link
Copy Markdown
Contributor Author

chris263 commented Jun 1, 2026

I have added dataset compatibility check plus login is required to use this tool.

Comment thread lib/CXGN/Dataset.pm Outdated
}
}

foreach my $analysis_name ("Dataset Analysis", "Environment Stratification") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is different from how all the other tools determine compatibility. It seems like this only requires a dataset to have trials and traits, but does not impose any requirement on the number of observed phenotypes. The other tools have a "warn" condition that explains the dataset meets the minimum requirements but may have low N, making results unreliable. The "dataset requirements" key is not present in any other tool. It is also unclear to me what the "Dataset Analysis" tool is and why it has the same requirements as environment stratification.

Copy link
Copy Markdown
Contributor Author

@chris263 chris263 Jun 1, 2026

Choose a reason for hiding this comment

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

I think this part should be flexible for breeders to decide how they are mounting the dataset to construct zones. They just need trials and at least a trait. Make it too restrict I think can cause more complains.

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.

3 participants