lizzieinvancouver / localadaptclim

1 stars 0 forks source link

Finalizing results #17

Open alinazeng opened 1 year ago

alinazeng commented 1 year ago

Hi Lizzie. @lizzieinvancouver It took me a while to get through everything we discussed during our last meeting before you left. Here are the updates:

1) Results we have to date.

Our models show that spring events are not related to provenance latitude or mean annual temperature in North America, and only weakly related in Europe (This might be explained by the higher extent of climate overlap we found in European studies. The more similar the climate is between provenances and gardens, the less difference between spring event dates. However, it is interesting that climate overlap was not much better than MAT or latitude at predicting event dates).

In contrast, fall events advance strongly with provenance latitude and mean annual temperature, meaning fall events are earlier where provenance mean annual temperature is lower (more northern, higher latitudes).

While comparing how similarity in climate relates to event dates, we observed very weak effects of climate overlap on spring events, nearly identical across angiosperms and gymnosperms. Fall events diverge as climate overlap declines for both angiosperms and gymnosperms, but slightly more strongly for gymnosperms.

The inconsistently and weak clines in spring events that we found suggest high plasticity in spring phenology across continents and species. Fall events, on the other hand, exhibit stronger clines, suggesting more local adaptation, especially in North America.

Overall, our results predict that warming springs will continue to be tracked more closely phenologically by trees than warming fall temperatures.

2) In our study, all the angiosperms happen to be deciduous, and all gymnosperms are evergreen, so there was not a need to do a separate test. 3) I have rerun the fits to display (1) latitude difference (2) spherical distance on earth, and (3) MAT difference on the X-axis. Please see below and let me know if this is at all constructive.

LAT - Spring events image

LAT - Fall events (here I wasn't able to run the model with earth distance successfully, hence lacking that plot. but can try again if necessary) image

MAT image

4) I did the alternative fit that you suggested, where I fit each (species & common garden) instead of just species. At the moment I am only applying this to absolute Lat and Mat instead of Lat difference and Mat difference. Pending depending on what you think of bullet point 3).

LAT - Spring events (the slopes do not change very much in my opinion)

fitting just species

                                 slope        Intercept

Alnus rubra -0.54205818 111.74172 Betula papyrifera 0.84294372 57.00769 Fagus sylvatica 0.57434664 95.30634 Fraxinus excelsior 0.61780092 113.58666 Picea abies -0.09585397 126.98399 Picea engelmannii -0.05012547 105.06830 Picea mariana -0.04687759 141.83015 Picea sitchensis -0.09180345 125.92917 Pinus albicaulis -0.75947374 134.74101 Pinus ponderosa -0.12048628 168.52617 Populus balsamifera 0.12298126 111.23423 Populus trichocarpa 0.53678376 38.85538 Pseudotsuga menziesii 0.40427209 105.35980 Quercus petraea -0.08666814 112.19610 Tsuga heterophylla -0.34804361 132.84375

fitting species garden

                                 slope        Intercept

Alnus rubra A -0.74386404 122.01707 Betula papyrifera K 1.05917470 26.01149 Betula papyrifera L 0.92354838 60.01451 Betula papyrifera M 0.83526304 70.85565 Fagus sylvatica R 0.22916588 99.95821 Fagus sylvatica T 0.16050787 118.70245 Fraxinus excelsior Q 0.87496083 100.00138 Picea abies S -0.38161729 144.59099 Picea engelmannii B -0.03798769 104.59857 Picea mariana I -0.33014835 155.97002 Picea sitchensis D -0.12133977 127.58789 Pinus albicaulis C -1.14554929 152.53832 Pinus ponderosa J -0.53762919 183.85056 Populus balsamifera F 0.22129137 106.19181 Populus trichocarpa D 0.74904321 28.25067 Pseudotsuga menziesii H 0.58377618 96.80657 Quercus petraea U -0.14028833 114.25506 Quercus petraea V -0.13261934 113.63864 Tsuga heterophylla E -0.76267968 150.33300 Tsuga heterophylla G 0.62797886 95.70884

image

LAT - Fall events fitting just species

                                 slope        Intercept

Alnus rubra -2.30537937 351.5135 Fagus sylvatica 0.25997307 289.9028 Fraxinus excelsior -1.19118842 358.4840 Picea engelmannii -0.04806909 305.8692 Picea sitchensis -5.54165711 512.7683 Populus trichocarpa -9.49610961 711.3160 Tsuga heterophylla -3.81028557 417.3802

fitting species garden

                                 slope        Intercept

Alnus rubra A -2.29910225 351.8817 Fagus sylvatica R 0.27109545 290.3597 Fraxinus excelsior Q -1.17196897 359.1263 Picea engelmannii B -0.05691943 306.2000 Picea sitchensis D -5.54842772 512.8516 Populus trichocarpa D -9.49994339 712.2886 Tsuga heterophylla E -3.81356654 418.2034

image

5) Histograms:

Latitude and MAT in regards to provenance continent image

Latitude and MAT in regards to species type image

6) still working on fitting GDD... will update soon

lizzieinvancouver commented 1 year ago

@alinazeng Excellent work on this! A few queries as I dig through the results...

a)

LAT - Fall events (here I wasn't able to run the model with earth distance successfully, hence lacking that plot. but can try again if necessary)

Did the model not converge or what happened?

b)

  1. I did the alternative fit that you suggested, where I fit each (species & common garden) instead of just species. At the moment I am only applying this to absolute Lat and Mat instead of Lat difference and Mat difference. Pending depending on what you think of bullet point 3).

Yes, I did not think it would make much of a differences since you said most species appear in only one garden. Can you tell me how many unique species we have versus how many unique species * garden we have?

alinazeng commented 1 year ago

Hi Lizzie @lizzieinvancouver

Thanks!

Update:

a)

LAT - Fall events (here I wasn't able to run the model with earth distance successfully, hence lacking that plot. but can try again if necessary)

Did the model not converge or what happened?

Was eventually able to run the model.... I guess FSC computers are just not ready to handle models. It took over three hours while there isn't much data... Here is the updated graph for fall.

image

Yes, I did not think it would make much of a differences since you said most species appear in only one garden. Can you tell me how many unique species we have versus how many unique species * garden we have?

We have 15 unique species

[1] "Alnus rubra"           "Picea engelmannii"     "Picea sitchensis"      "Pinus albicaulis"      "Populus trichocarpa"   "Tsuga heterophylla"    "Populus balsamifera"   "Pseudotsuga menziesii" "Picea mariana"        
[10] "Pinus ponderosa"       "Betula papyrifera"     "Fraxinus excelsior"    "Fagus sylvatica"       "Picea abies"           "Quercus petraea"      

and 20 unique pairs of species*garden

 [1] "Alnus rubra A"           "Picea engelmannii B"     "Picea sitchensis D"      "Pinus albicaulis C"      "Populus trichocarpa D"   "Tsuga heterophylla E"    "Populus balsamifera F"   "Tsuga heterophylla G"   
 [9] "Pseudotsuga menziesii H" "Picea mariana I"         "Pinus ponderosa J"       "Betula papyrifera K"     "Betula papyrifera L"     "Betula papyrifera M"     "Fraxinus excelsior Q*"   "Fagus sylvatica R*"     
[17] "Picea abies S*"          "Fagus sylvatica T*"      "Quercus petraea U*"      "Quercus petraea V*"  

Another update: Was finally able to calculate gdd for all my provenances... after countless hours of reorganizing the daily climate csvs that I saved from before lol. Question: my daily climate data are from 2011 to 2020. Should I pick one of the years and use the corresponding GDDs or should I take the average of GDDs on each day across the 10 year frame?

Thank you very much!

lizzieinvancouver commented 1 year ago

@alinazeng Nice!

Here is the updated graph for fall. Can you check your code for the spherical distance? All the intercepts look identical which suggests to me you did not let them vary in the model (or the plotting is wrong).

Wrangling climate data to get GDD always takes me longer than I expect.

Should I pick one of the years and use the corresponding GDDs or should I take the average of GDDs on each day across the 10 year frame?

Good question! The ideal would be to use the GDD of the year the phenology data was collected. Is it ever possible to tell? (And what are the years if so?) If not possible, use the average GDD across the years on the spring event date.

alinazeng commented 1 year ago

Hi Lizzie @lizzieinvancouver

I am graphing GDD in relation to Lat and MAT below. In the end I calculated the GDD of each location for 2011-2020 and took an average for the 10 years because (1) that is the daily climate we worked with ; (2) for some studies it is not possible to retrieve the daily climate info because they happened in years we do not have climate information available.

p.s. still trying to figure out what when wrong for the earth distance graphs. will report back later. image

alinazeng commented 1 year ago

Hi lizzie @lizzieinvancouver

p.s. still trying to figure out what when wrong for the earth distance graphs. will report back later.

hmmm i rerun the model multiple times and have been getting the same intercepts for the spherical distance ones... The code is as follows, the exact same as my other ones except that I swapped lat_prov with earth_distance_from_garden

fitA_spring_earth_distance <- stan_glmer(spring_event~(earth_distance_from_garden|Species), data = d)
fitA_fall_earth_distance <- stan_glmer(fall_event~(earth_distance_from_garden|Species), data = d)

what could have gone wrong?

lizzieinvancouver commented 1 year ago

what could have gone wrong?

@alinazeng Okay, I think it is wrong. As an example, look at the green squares on top -- they should get an intercept closer to 300 (as in the left and center panel) but they don't.

My best guess is the SCALE of the x variable. In all models, but especially ones like this (tricky Bayesian ones with lots of effects), you don't want wildly different numbers (e.g., you're estimating a slope of 1-3 or less and using Y values of 100-300 and then you have an x value of 50000 -- that X is really big!). So I suggest you change your spherical distance to km (just divide by 1000) or you can divide by 10,000 and check your model output.

alinazeng commented 1 year ago

@lizzieinvancouver Hi Lizzie. Great Catch!! yes apparently the digits overwhelmed the model. I believe the following plots now make sense after I adjusted the unit to kilometer.

image

I believe that's everything from our last meeting. What would you suggest that I work on next? I am casually writing the Methodologies at the moment. Thank you so much.

Cheers, Alina

lizzieinvancouver commented 1 year ago

@alinazeng Nice work! And phew -- I did not have any guesses for what was up otherwise.

Question -- what is up with the gardens at the TOP of the bottom plots? The ones that seem to show almost no trends? Is it all one garden or location or species? It's weird so we'll need to explain it...

Speaking of which, next up we should draft an outline of the results. I will send you a tex file to work off. Ping me here if I do not send it by Wednesday (26 Oct)! And until then start to jot down what are the results -- you can work off your talks.

I'd prefer you work in Sweave (or knitr) as then the work is more reproducible, but it's up to you. If you want to try Sweave (or KnitR) step 1 is to install it on your machine and compile a test file successfully.

alinazeng commented 1 year ago

Hi Lizzie @lizzieinvancouver Thank you!

what is up with the gardens at the TOP of the bottom plots? Those are one species from one study (Picea engelmannii from Rehfeldt 1994, a greenhouse experiment. After some digging, I realized that the "fall events" we have for that paper are "the day by which seedling elongation had finished"... which isn't a common fall event indicator. Perhaps that's why there are little clines? I included that paper in the first place because Aitken and Bammals (2015) included it.

I'd prefer you work in Sweave (or knitr) as then the work is more reproducible So far I've used MiKTeK cuz I am using a PC. Would Sweave be the same in terms of coding? and that the only difference is that Sweave is embedded in Rstudio so we can edit the same file more easily?

Cheers!

alinazeng commented 1 year ago

@lizzieinvancouver bump~

I will send you a tex file to work off. Ping me here if I do not send it by Wednesday (26 Oct)!

lizzieinvancouver commented 1 year ago

@alinazeng

So far I've used MiKTeK cuz I am using a PC. Would Sweave be the same in terms of coding? and that the only difference is that Sweave is embedded in Rstudio so we can edit the same file more easily?

Sweave is pretty easy if you have LaTeX working -- you embed R code in your LaTeX code, but Sweave can sometimes be a pain to install depending on your machine. Are you using RStudio? If so I found this page:

See this info

You can find a test file to run here -- check out page 4. Or you can try the old Sweave demo I made. Let me know how it goes!

alinazeng commented 1 year ago

@lizzieinvancouver Hi Lizzie,

After hours of debugging I finally got Sweave to run on Rstudio! Yay I was working with your old Sweave demo. Weird thing is, I could never get the lines \begin{figure}[width=2in] and \begin{center} to work. everytime I put those lines before a <<>>=@the PDF would not write. Everything else works for me, though, and I am able to experiment with some more complex plots.

I was also wondering about this line in the preamble:

\SweaveOpts{prefix.string=/Users/Lizzie/Documents/git/teaching/demoSweave/figures/demoFig, eps=FALSE} 
%put your figures in one place! Also, note that here 'figures' is the folder and 'demoFig' is what each 
% figure produced will be titled plus its number or label (e.g., demoFig-nqpbetter.pdf')

is this figures folder something I should manually create inside my directory or it will be automatically created after this command? what about the demoFig folder?

Definitely realized how efficient Sweave can make the writing process :)) and I will not have to keep making and saving new versions of my plots to local disk again.

For the outline for Results, what elements would you like me to include for the first round?

Thank you!

lizzieinvancouver commented 1 year ago

@alinazeng

After hours of debugging I finally got Sweave to run on Rstudio! Yay

Brilliant! Great work, I think this upfront work will be worth it.

I was working with your old Sweave demo. Weird thing is, I could never get the lines \begin{figure}[width=2in] and \begin{center} to work. everytime I put those lines before a <<>>=@ the PDF would not write. Everything else works for me, though, and I am able to experiment with some more complex plots.

This is weird. Can you email me a minimal reproducible example? That is a very SHORT .Rnw file with the minimal code you need to show the problem and I will see if it compiles on my machine.

is this figures folder something I should manually create inside my directory? what about the demoFig folder?

Yes! You need to have the path (e.g., /Users/Lizzie/Documents/git/teaching/demoSweave/figures) through 'figures' so you would need a path to a folder called figures ... demoFig will just add demofig' to the start of any figure file name. So you do not need a folder calleddemofig.'

Definitely realized how efficient Sweave can make the writing process :)) and I will not have to keep making and saving new versions of my plots to local disk again.

Yes! Once I started doing this, I found it hard to go back to the old way.

For the outline for Results, what elements would you like me to include for the first round?

I would suggest you start two .Rnw files now -- one with 'supp' (for supplement or supporting information) in the name and one with 'ms' (for manuscript) or similar in the name. Focus on getting the figures and take-away messages from your talk into the ms file and add any details or placeholders for what we should add to the supp. For example -- you might add a figure to the ms file and make a note in the supp that we need a table of the results for that figure.

alinazeng commented 1 year ago

hi lizzie @lizzieinvancouver

Here is the path to my .tex. and .rnw files

I started populating the manuscript file. Still learning how to write in Latex.

I have grouped major findings into sections and would appreciate it if you could have a look and provide suggestions before I actually elaborate on the results. So far I only have a skeleton in there, and I only included two figures at the moment because I would like to know if there's anything I should change regarding their format and colors. They are quite blurry, I will find ways to export plots with better resolutions.

some specific inquiries:

Ready to dive into writing after you let me know if I am off track :)) Thank you very much!

This is weird. Can you email me a minimal reproducible example? That is a very SHORT .Rnw file with the minimal code you need to show the problem and I will see if it compiles on my machine.

Email sent

lizzieinvancouver commented 1 year ago

@alinazeng Nice! Some quick thoughts and I will look more deeply later:

  1. You might use the todonotes package to make reminders of what to do or call out questions to me.
  2. You should open results with how many papers you reviewed and how many you were able to include in the analysis, as well an overview of number of species, what years the data come from etc.
  3. I would also add the map as a figure in the main text.
  4. No worries about figure quality! We can deal with all that later. However, I have found it best to write an R file that I source which has all the info I need in the Sweave file, and I make sure that R file WRITES out a bunch of PDFs of the figures that I read in. Here's a recent example limiting cues ms and one more ... tempcar ms

some specific inquiries:

  • I don't know what we should say about the GDD ~ lat and GDD ~ mat plots.

Okay, flag this for me to look at next time.

  • what code should I use when I want to put (Fig. X) in text and then ensure the X is the same as what would show up in the Caption?

Good question! You need to add a label to the figure (for example \label{fig:alpharstarsupp}) and then you can reference that elsewhere with \ref (for example \ref{fig:alpharstarsupp}). You can reference tables and figures from your supp in your main text if you use cross reference (info on the labgit site on that).

  • Do we leave all figures at the end or in between paragraphs?

I usually put them at the end (it compiles easier often) but up to you... most journals want them at the end, but some want them as you have them.

alinazeng commented 1 year ago

Hi Lizzie @lizzieinvancouver Thanks for the suggestions!

I have made minor tweaks to the ms.rnw

Could you please take a look at the Results section and let me know what other subsections we might want to include? or if the outline seems okay I will start writing things in the coming weeks. Thank you.

Cheers, Alina

lizzieinvancouver commented 1 year ago

@alinazeng Amazing! I love your Sweave work and all the todo notes.

Thanks! I iterate a LOT over the results, and then the outline before writing so I need some time to review this and for us to go back and forth. It takes me a while to think through whether our outline is complete and working ... and unfortunately I cannot do this this week (I hope next).

To not stall your progress as you're doing quite well I suggest you work on the supplemental tables with the model results (if you need help Deirdre has some code that does this for Stan models, though your rstanarm ones will be a little different) and also get your references started. That means creating a bibtex file and adding in refs you think we'll need. I would start jotting down the\citep{refs}commands with what info they have that you'll likely include in the intro or discussion.

If you somehow get all that running you can make your supp and ms cross reference.

Random tips and info here.

alinazeng commented 1 year ago

Hi Lizzie,

Thank you! Please take your time regarding the general outline.

  1. I successfully cross-referenced ms and supp (Line 133 in manuscript.rnw; first sentence under Result section) .
  2. I found a way to display rstanarm model results (Table 1 in supplement). Before I go any further, it'd be great if you could have a look at my model table and let me know if this is on the right track. I displayed the output of spring_event~(lat_prov|species) and fall_event~(lat_prov|species) side by side as a trial run. Let me know what you think about the format and content.
  3. As for the bibliography, do you prefer me to work with natbib or biblatex? I will start putting the literature that we want to reference soon.
lizzieinvancouver commented 1 year ago

I successfully cross-referenced ms and supp

Whoo--hoo, this took me years to figure out so way to go.

As for the bibliography, do you prefer me to work with natbib or biblatex? I will start putting the literature that we want to reference soon.

I think up to you. I can help with natbib as that is still almost all I ever use, but I am told biblatex is better... see here for some discussion. If you're not sure, go with natbib, since I can help with issues. If you get really excited about biblatex, you're welcome to use it, but I will be less help.

I found a way to display rstanarm model results

Nice! I like the idea of comparing the spring and fall model. I think you can cut everything from NumObs and below though -- we generally focus on the mean and intervals... check out table S3 onward here. Can you grab the 5%, mean and 95% intervals and plot the sigmas from the models more like this (you can skip other intervals and the Rhat for now)? It would also likely be fine to have spring and fall as separate tables if it's a pain (sadly these tables don't get looked at so much so it's most important that we share the info, but making it easy to compare is less critical). Also, can you paste the model output you get from rstanarm models below? I think there are a couple other parameters we'd want to include in the table .....

alinazeng commented 1 year ago

hi lizzie @lizzieinvancouver

is there an easy way to export this markdown table into latex language? I will also look online.

thank you!!

lizzieinvancouver commented 1 year ago

is there an easy way to export this markdown table into latex language? I will also look online.

Likely! I don't use tibbles, but you can pretty easily format dataframes etc. into latex tables using xtable in Sweave. There's a good manual for the package so see how it goes.

lizzieinvancouver commented 1 year ago

@alinazeng That's totally fine for now! As we work on an outline of the intro you may want a separate section in the Rnw for 'notes on refs' or such though, so it's easy for me to review the outline. BTW, I finally wrote up my 'writing with me' file, which is here. I think we're working across a couple steps now -- mainly getting the results and methods finalized.

lizzieinvancouver commented 1 year ago

@alinazeng It may be easiest to make a file (could be ms file or whatever is easiest) of all the figures and give each one a quick name so we can discuss which go in the main text versus supp versus we don't need them (otherwise it may get confusing to refer to them), but here's a possible start (see if this covers most of them):

Which figures/results did I miss?

lizzieinvancouver commented 1 year ago

@alinazeng Can you add a bullet list of our questions to the top of the results section? Once you have done that added all the plots from above as suggested (and tell me any I missed) I will take another look at the results. So far though, very good! I think we are close.

By the way, no need to outline the results with \enumerate ... I think they way you have it formatted with subsections and sentences works. We can work on methods and results and then when we get to the intro next we should outline with \enumerate or similar as that is easiest for me. Does that work for you?

alinazeng commented 1 year ago

Hi Lizzie,

I have addressed most if not all things you mentioned in this issue. I put the figures like you wanted in ms and supp. You can review the result section again now at your convenience.

Please excuse the placement and quality of the existing figures. Will fix later. (I don't know what the command is to put all figures at the end of the document, so now they are floating however they like :'))) ) Also please ignore the old table in the supp. I am still figuring out code to transform my tibble output. Will update later.

Right now the supp document has no order... I am just parking things randomly.

Provenance latitude (x-axis) plots should go in main text; I think the prov lat diff and earth spherical can definitely go in the supp as figures (likely we can skip the tables) Let's park the GDD (spring only) results in the supp for now and please start a new issue on them so we can decide what to do. Put climate overlap in the main text for now Definitely put the histograms shown above in the supp; they are important.

Which figures/results did I miss?

Not much, I think you forgot to mention MAT plots, which I am including in the ms for now together with the LAT~doy plot. There are also the histograms about spp type and continent that you didn't mention, I put them in the ms as well.

Let me know what you think~ Thank you.

alinazeng commented 1 year ago

@lizzieinvancouver By the way, I just had another question: since we are now displaying results that are for unique spp x garden instead of just unique spp, how would that affect our plots? As a reminder, our old plots (scroll up for the scatter plots with fitted lines) were colored by different gardens and shaped by different species. Since now we fit our models based on each spp x garden, do we just need to use either color or shape to distinguish between each combination, instead of having to use both? I hope my question makes sense.

lizzieinvancouver commented 1 year ago

@alinazeng Great question! I thought about this a little and I think best to keep what we have. It is nice to have the model match the figures, but we also want to balance visualizing the data in ways readers want to see ... they will want to easily pick out different species and different gardens. So we do that, and our plots are pretty close to how we model the data in the end.

While discussing plots though, we should have the colors differentiate by continent (all Europe first, then all North America or vice versa and then write in the caption a-j are Europe and j-X are North America).