-
Notifications
You must be signed in to change notification settings - Fork 282
Meta Analysis Quarto NoteBook #3707
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
Meta Analysis Quarto NoteBook #3707
Conversation
documentation/tutorials/Demo_03_Meta_Analysis/meta_analysis.qmd
Outdated
Show resolved
Hide resolved
documentation/tutorials/Demo_03_Meta_Analysis/meta_analysis.qmd
Outdated
Show resolved
Hide resolved
documentation/tutorials/Demo_03_Meta_Analysis/meta_analysis.qmd
Outdated
Show resolved
Hide resolved
documentation/tutorials/Demo_03_Meta_Analysis/meta_analysis.qmd
Outdated
Show resolved
Hide resolved
| install.packages('PEcAn.all') | ||
| ``` | ||
|
|
||
| * **A valid `pecan.xml` configuration file**: Start with the example at `pecan/documentation/tutorials/Demo_03_Meta_Analysis/pecan.xml`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue to open: one should be able to run the MA itself without a full settings object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<?xml version="1.0" encoding="UTF-8"?>
<pecan>
<pfts>
<pft>
<name>temperate.coniferous</name>
<posterior.files>pft/temperate.coniferous</posterior.files>
<outdir>pft/temperate.coniferous</outdir>
</pft>
</pfts>
<meta.analysis>
<iter>3000</iter>
<random.effects>
<on>FALSE</on>
<use_ghs>TRUE</use_ghs>
</random.effects><threshold>1.2</threshold>
</meta.analysis>
</pecan>
This configuration alone is enough to run the meta-analysis; no additional model or run blocks are required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. So I think it would be fine in the Issue I'm recommending to recommend that the MA module be refactored to take in the following as arguments:
- trait dataframe
- prior dataframe
- output directory
- list containing MA configs (iter, random.effects, use_ghs, theshold, etc.) with some sensible defaults
Here in the demo one could elect to grab those things from a settings object, but one could also build a demo based on just specifying those things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update: If this demo is updated to use the new meta_analysis_standalone function then I think we'll be able to get away from a pecan.xml and instead just have a code block that defines the inputs and configurations that the MA needs. That should make the use of the MA package more transparent.
That said, at the end of the demo you could show how to do the same thing with a pecan.xml and runModule.run.meta.analysis, which could reuse a lot of the text and code you've already written, and could point out that the "module" version is handy if you're running the MA as part of a larger modeling workflow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in c40a0e0
documentation/tutorials/Demo_03_Meta_Analysis/meta_analysis.qmd
Outdated
Show resolved
Hide resolved
documentation/tutorials/Demo_03_Meta_Analysis/meta_analysis.qmd
Outdated
Show resolved
Hide resolved
| # Run Meta Analysis | ||
|
|
||
| We now run the meta-analysis. The `runModule.run.meta.analysis` function will: | ||
| 1. Read the `trait.data.Rdata` and `prior.distns.Rdata` from the PFT output directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue to open: would be great to be able to pass data into the MA directly, rather than it having to come from a file with a very specific file name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I believe this needs a separate function to implement it. We just need to pass trait.data.Rdata and prior.distns.Rdata to make it work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead, can we do this within this notebook by adding a section where the user only needs to provide the paths to trait.data.Rdata and prior.distns.Rdata ? If a user already has these two files, they can run the meta-analysis directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
follow up: I'm not requesting a change to this PR to implement what I'm suggesting. I'm instead asking that you open a new Issue to improve what we're doing in the future. Specifically, I'd recommend that the MA module take in the trait dataframe and prior dataframe as arguments to the function itself, rather than relying on the functions knowing to load those specific files from paths provided within an overly complex settings object. This will push a tiny bit of work into the demo (load the example files, look at them to see how they are formatted, pass them into the MA function) but IMHO will greatly increase the usability of the MA module as a stand-alone tool. Right now, it's functionally easy to to use the MA outside the PEcAn workflow, but its CONCEPTUALLY hard to do so because there's so much mystery in what it's doing. Right now, no one can actually run this as a stand alone module in practice without a whole lot of diving into the code to see what the module actually does and what it actually needs to work. Actually getting this working and documented might be a good place for a new GSOC student.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done here #3718
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AritraDey-Dev Thanks for creating issue #3717! I've implemented the format_try_for_ma() function in PR #3720.
This connects directly to @mdietze's suggestion about using external data. Once PR #3720 (TRY formatter) and issue #3718 (MA refactoring) are both implemented, this tutorial could show how to use TRY data with PEcAn's meta-analysis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
per earlier comments, would be good to update to meta_analysis_standalone in this PR. Then #3720 could include an update to the tutorial mentioning the new TRY conversion function. This PR shouldn't wait for that -- because we don't have permissions to redistribute TRY data we can't include a fully worked example in the Demo.
documentation/tutorials/Demo_03_Meta_Analysis/meta_analysis.qmd
Outdated
Show resolved
Hide resolved
|
@mdietze Thanks for the review and the detailed comments. I’ve tried to address and fix the suggested items in the subsequent commits. |
|
@mdietze This is a great suggestion. My If the MA module is refactored as you suggest, users could:
This would make PEcAn's meta-analysis much more accessible to researchers with external data sources. |
| install.packages('PEcAn.all') | ||
| ``` | ||
|
|
||
| * **A valid `pecan.xml` configuration file**: Start with the example at `pecan/documentation/tutorials/Demo_03_Meta_Analysis/pecan.xml`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update: If this demo is updated to use the new meta_analysis_standalone function then I think we'll be able to get away from a pecan.xml and instead just have a code block that defines the inputs and configurations that the MA needs. That should make the use of the MA package more transparent.
That said, at the end of the demo you could show how to do the same thing with a pecan.xml and runModule.run.meta.analysis, which could reuse a lot of the text and code you've already written, and could point out that the "module" version is handy if you're running the MA as part of a larger modeling workflow
| ```{r libraries} | ||
| # Load necessary PEcAn packages | ||
| # library("PEcAn.all") # Alternatively, load all packages if installed | ||
| library("PEcAn.settings") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you switch to meta_analysis_standalone you might only need PEcAn.MA and could push the other library loads to the end when you show the module version.
| # Run Meta Analysis | ||
|
|
||
| We now run the meta-analysis. The `runModule.run.meta.analysis` function will: | ||
| 1. Read the `trait.data.Rdata` and `prior.distns.Rdata` from the PFT output directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
per earlier comments, would be good to update to meta_analysis_standalone in this PR. Then #3720 could include an update to the tutorial mentioning the new TRY conversion function. This PR shouldn't wait for that -- because we don't have permissions to redistribute TRY data we can't include a fully worked example in the Demo.
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Add Demo 03 notebook to run meta-analysis with pre-generated data. Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
Signed-off-by: Aritra Dey <adey01027@gmail.com>
ac4ece1 to
c40a0e0
Compare
Signed-off-by: Aritra Dey <adey01027@gmail.com>
|
|
||
| This demo supports the modeling scenario introduced in [Demo 01](../Demo_1_Basic_Run/run_pecan.qmd) and [Demo 02](../Demo_02_Uncertainty_Analysis/uncertainty.qmd), which simulated ecosystem carbon balance at the AmeriFlux Niwot Ridge Forest site ([US‑NR1](https://ameriflux.lbl.gov/sites/siteinfo/US-NR1)) using the SIPNET model. | ||
|
|
||
| While those demos focused on running the ecosystem model, this notebook zooms in on the **Meta-Analysis** step. We will generate informative posterior distributions for the **temperate coniferous** Plant Functional Type (PFT) used in those simulations. These posteriors can then be used to constrain the parameters of the SIPNET model (or other models) to improve prediction accuracy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This paragraph and the next are a bit repetitive. Recommend merging
Signed-off-by: Aritra Dey <adey01027@gmail.com>
45423fd
Description
This PR implements a Quarto notebook for the meta-analysis. It uses the posterior files and
trait.data.Rdatato run the Meta Analysis demo. A pecan.xml file is also included to run the workflow.Motivation and Context
Review Time Estimate
Types of changes
Checklist: