Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tutorials/multifig/data/hawaii/feature_description.csv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
index,relationship,type,description
1,within,categorical,Age class (old=0 young=1)
2,within,categorical,Growth class (decay=0 growth=1)
1,within,quantitative,Max. altitude (m)
2,within,quantitative,Log max. altitude (m)
1,within,quantitative,Size (km^2)
2,within,quantitative,Log size (km^2)
1,between,categorical,Dispersal class (short=0 long=1)
2,between,categorical,Rel. age class (older=0 younger=1)
1,between,quantitative,Distance (km)
Expand Down
2 changes: 1 addition & 1 deletion tutorials/multifig/data/hawaii/qw_feature1.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
G,N,K,O,M,H,Z
005,100,1431,1548,3155,4207,1500
005,100,1431,1548,3155,10434,1500
2 changes: 1 addition & 1 deletion tutorials/multifig/data/hawaii/qw_feature2.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
G,N,K,O,M,H,Z
1.6094379124341,4.60517018598809,7.26612877955645,7.34471905414967,8.05674377497531,8.34450508359,7.3132203870903
1.6094379124341,4.60517018598809,7.26612877955645,7.34471905414967,8.05674377497531,9.25282498358,7.3132203870903
Binary file removed tutorials/multifig/figures/.DS_Store
Binary file not shown.
Binary file modified tutorials/multifig/figures/features.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tutorials/multifig/figures/plot_feature_rate_network.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified tutorials/multifig/figures/plot_features_vs_time.feat_qw1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions tutorials/multifig/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Graphical model of MultiFIG. Square nodes represent constant values (data). Circ

The FIG model incorporates geographical features with two value types as model variables: quantitative features and categorical features. Quantitative features have continuous real values while categorical features have discrete values. MultiFIG also separates data by dimensionality type, incorporating one-dimensional within-region data and two-dimensional between-region data. We use four containers to store this data: $w_c$, $w_q$, $b_c$, and $b_q$.

Each regional feature is assigned a "feature effect" parameter that measures the strength and direction of the effect of a particular feature on a particular process. Note that "effect" refers to a mathematical relationship here, but does *not* indicate causality. These strength parameters are referred to as $\sigma$ and $\phi$, representing the effects of categorical and quantitative features respectively. There is one $\sigma$ or $\phi$ parameter per feature per process. For example, $\phi_w^{Altitude}$ would represent the relationship between region altitude and within-region speciation.
Each regional feature is assigned a "feature effect" parameter that measures the strength and direction of the effect of a particular feature on a particular process. Note that "effect" refers to a mathematical relationship here, but does *not* indicate causality. These strength parameters are referred to as $\sigma$ and $\phi$, representing the effects of categorical and quantitative features respectively. There is one $\sigma$ or $\phi$ parameter per feature per process. For example, $\phi_w^{Size}$ would represent the relationship between region size and within-region speciation.

For each process, the categorical and quantitative feature effects (with feature data modified by strength parameters) are gathered into $c$ and $q$ vectors, then ultimately combined into an $m$ vector. The $m$ vector represents the total effects of all regional features on a particular process, with entries representing each region (or region pair for between-region processes). The $m$ vector represents relative rates among regions, but to obtain absolute rates, the $m$ vector for each process is multiplied by a process-specific base rate parameter $\rho$. This constructs the $r$ vectors that are analogous to GeoSSE rates: $r_w$ for within-region speciation rates, $r_e$ for extinction rates, and $r_d$ for dispersal rates. Calculating $r_b$ for between-region speciation rates also requires the use of a range split score, as in {% cite Landis2022 %}.

Expand Down Expand Up @@ -70,14 +70,14 @@ and behaves similarly to the quantitative effect variable. (In this example, we

Each individual effect variable can be $<1$, $>1$, or $=1$, and so can the product of all effect variables. All relative rates are eventually rescaled by the same base rate (e.g. $\rho_w$). If the relative rates for regions $i$ and $j$ have the relationship $m_w(i) > m_w(j)$ then the absolute rates also follow $r_w(i) > r_w(j)$. Other $m$ functions behave in a similar manner. More details on the design of the $m$ functions are provided in {% cite Swiston2025 %}.

In this analysis, we are examining eight regional features. The first 4 are quantitative: maximum altitude (m), log maximum altitude (m), distance (km), and log distance (km). We include the log features because they will allow us to better understand the *shape* of the relationship between features and processes. For example, it may be that intermediate values of a particular feature are related to the highest rates of a particular process, so we would expect the feature strength parameter to be positive and the log-feature strength parameter to be negative. The other 4 features are categorical: age class (old/young), growth class (decay/growth), dispersal class (short/long), and relative age class (older/younger).
In this analysis, we are examining eight regional features. The first 4 are quantitative: size (km^2), log size (km^2), distance (km), and log distance (km). We include the log features because they will allow us to better understand the *shape* of the relationship between features and processes. For example, it may be that intermediate values of a particular feature are related to the highest rates of a particular process, so we would expect the feature strength parameter to be positive and the log-feature strength parameter to be negative. The other 4 features are categorical: age class (old/young), growth class (decay/growth), dispersal class (short/long), and relative age class (older/younger).

{% figure features %}
<img src="figures/plot_features_vs_time.feat_qw1.png" width="40%"><br>
<img src="figures/plot_features_vs_time.feat_qb1.png" width="40%"><br>
<img src="figures/plot_features_vs_time.feat_cb2.png" width="40%">
{% figcaption %}
Examples of a within-region quantitative feature (max. altitude), a between-region quantitative feature (distance), and a categorical quantitative feature (relative island age). These features (and others) may shape core biogeographic rates depending on which regions are involved in an event.
Examples of a within-region quantitative feature (area), a between-region quantitative feature (distance), and a categorical quantitative feature (relative island age). These features (and others) may shape core biogeographic rates depending on which regions are involved in an event.
{% endfigcaption %}
{% endfigure %}

Expand Down
4 changes: 2 additions & 2 deletions tutorials/timefig_dating/_data/hawaii/feature_description.csv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
index,relationship,type,description
1,within,categorical,Age class (old=0 young=1)
2,within,categorical,Growth class (decay=0 growth=1)
1,within,quantitative,Max. altitude (m)
2,within,quantitative,Log max. altitude (m)
1,within,quantitative,Size (km^2)
2,within,quantitative,Log size (km^2)
1,between,categorical,Dispersal class (short=0 long=1)
2,between,categorical,Rel. age class (older=0 younger=1)
1,between,quantitative,Distance (km)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
G,N,K,O,M,H,Z
005,100,1750,1750,nan,nan,1500
005,100,2500,2050,nan,nan,1500
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
G,N,K,O,M,H,Z
1.6094379124341,4.60517018598809,7.46737106691756,7.46737106691756,nan,nan,7.3132203870903
1.6094379124341,4.60517018598809,7.82404601086,7.62559507213,nan,nan,7.3132203870903
Binary file modified tutorials/timefig_dating/figures/plot_feature_rate_network.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 7 additions & 6 deletions tutorials/timefig_dating/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,8 @@ num_proc = 6
num_gen = 500 # set num_gen = 5000 for full analysis

# number of interations between MCMC samples
print_gen = 20
print_gen = 1
save_gen = 20

# empty vector for MCMC moves
moves = VectorMoves()
Expand Down Expand Up @@ -808,18 +809,18 @@ We also create the same original set of monitors.
monitors.append( mnScreen(root_age, printgen=print_gen) )

# file monitor for all simple model variables
monitors.append( mnModel(printgen=print_gen, file=out_fn+".model.txt") )
monitors.append( mnModel(printgen=save_gen, file=out_fn+".model.txt") )

# file monitor for tree
monitors.append( mnFile(timetree, printgen=print_gen, file=out_fn + ".tre") )
monitors.append( mnFile(timetree, printgen=save_gen, file=out_fn + ".tre") )
```

We also create monitors to track the biogeographic rates per region per time interval.
```
# file monitor for biogeographic rates
for (k in 1:num_times) {
bg_mon_fn = out_fn + ".time" + k + ".bg.txt"
monitors.append( mnFile( filename = bg_mon_fn, printgen=print_gen,
monitors.append( mnFile( filename = bg_mon_fn, printgen=save_gen,
rho_e, rho_w, rho_d, rho_b,
r_e[k], r_w[k],
r_d[k][1], r_d[k][2], r_d[k][3], r_d[k][4],
Expand All @@ -839,7 +840,7 @@ You can also create a ancestral state monitor to sample ancestral ranges that ar
```
# monitor ancestral ranges at internal nodes
monitors.append( mnJointConditionalAncestralState(
tree=timetree, glhbdsp=timetree, printgen=print_gen,
tree=timetree, glhbdsp=timetree, printgen=save_gen,
filename=out_fn+".states.txt",
withTips=true, withStartStates=true, type="NaturalNumbers") )
```
Expand All @@ -852,7 +853,7 @@ Similarly, you can construct a monitor to generate stochastic mappings that repr
# NOTE: uncomment if needed, but can cause performance issues

# monitors.append( mnStochasticCharacterMap(
# glhbdsp=timetree, printgen=print_gen*10,
# glhbdsp=timetree, printgen=save_gen*10,
# filename=out_fn+".stoch.txt",
# use_simmap_default=false) )
```
Expand Down
11 changes: 6 additions & 5 deletions tutorials/timefig_dating/scripts/divtime_timefig.Rev
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ out_fn = "./output/" + analysis
# MCMC variables
num_proc = 6
num_gen = 5000
print_gen = 20
print_gen = 1
save_gen = 20
moves = VectorMoves()
monitors = VectorMonitors()

Expand Down Expand Up @@ -127,21 +128,21 @@ moves.append(rate_age_proposal)
monitors.append( mnScreen(root_age, printgen=print_gen) )

# file monitor for all simple model variables
monitors.append( mnModel(printgen=print_gen, file=out_fn+".model.txt") )
monitors.append( mnModel(printgen=save_gen, file=out_fn+".model.txt") )

# file monitor for tree
monitors.append( mnFile(timetree, printgen=print_gen, file=out_fn + ".tre") )
monitors.append( mnFile(timetree, printgen=save_gen, file=out_fn + ".tre") )

# monitor ancestral ranges at internal nodes
monitors.append( mnJointConditionalAncestralState(
tree=timetree, glhbdsp=timetree, printgen=print_gen,
tree=timetree, glhbdsp=timetree, printgen=save_gen,
filename=out_fn+".states.txt",
withTips=true, withStartStates=true, type="NaturalNumbers") )

# file monitor for biogeographic rates
for (k in 1:num_times) {
bg_mon_fn = out_fn + ".time" + k + ".bg.txt"
monitors.append( mnFile( filename = bg_mon_fn, printgen=print_gen,
monitors.append( mnFile( filename = bg_mon_fn, printgen=save_gen,
rho_e, rho_w, rho_d, rho_b,
r_e[k], r_w[k],
r_d[k][1], r_d[k][2], r_d[k][3], r_d[k][4],
Expand Down
Binary file modified tutorials/timefig_dating/timefig_dating_project.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions tutorials/timefig_simple/_data/hawaii/feature_description.csv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
index,relationship,type,description
1,within,categorical,Age class (old=0 young=1)
2,within,categorical,Growth class (decay=0 growth=1)
1,within,quantitative,Max. altitude (m)
2,within,quantitative,Log max. altitude (m)
1,within,quantitative,Size (km^2)
2,within,quantitative,Log size (km^2)
1,between,categorical,Dispersal class (short=0 long=1)
2,between,categorical,Rel. age class (older=0 younger=1)
1,between,quantitative,Distance (km)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
G,N,K,O,M,H,Z
005,100,1750,1750,nan,nan,1500
005,100,2500,2050,nan,nan,1500
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
G,N,K,O,M,H,Z
1.6094379124341,4.60517018598809,7.46737106691756,7.46737106691756,nan,nan,7.3132203870903
1.6094379124341,4.60517018598809,7.82404601086,7.62559507213,nan,nan,7.3132203870903
Binary file modified tutorials/timefig_simple/figures/features.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tutorials/timefig_simple/figures/plot_feature_rate_network.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions tutorials/timefig_simple/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ In this tutorial, we will model the evolution and biogeography of *Kadua* using

The Hawaiian archipelago is a system in which phylogenetic models of historical biogeography will produce much more accurate reconstructions if they incorporate change over time in paleogeography than if change in island feature is ignored. In this tutorial, we apply a TimeFIG model to the Hawaiian radiation of *Kadua* (26 spp. including non-Hawaiian outgroups) to infer paleogeographically-informed parameter estimates for biogeographic event rates, effect rates of regional features, and ancestral areas.

The introduction to this tutorial series describes the complex palegeological history of the Hawaiian Archipelago ([link](https://revbayes.github.io/tutorials/fig_intro/#empirical-system-hawaiian-kadua)). Briefly, each Hawaiian island formed in the soutwest through seamount vulcanism and then drifted to the northwest with tectonic movements of the Pacific Plate. This creates a "conveyor belt" system, where taller but younger islands reside in the southeast while flatter but older islands extend to the northwest. This tutorial makes use of various paleogeographic measurements, such as island age, and estimates, such as paleoaltitude, to help shape biogeographic rates over time. For example, we might expect that terrestrial plants have higher extinction rates the oldest (barren) islands or that the plants cannot colonize islands below sea level (impossible).
The introduction to this tutorial series describes the complex palegeological history of the Hawaiian Archipelago ([link](https://revbayes.github.io/tutorials/fig_intro/#empirical-system-hawaiian-kadua)). Briefly, each Hawaiian island formed in the soutwest through seamount vulcanism and then drifted to the northwest with tectonic movements of the Pacific Plate. This creates a "conveyor belt" system, where taller but younger islands reside in the southeast while flatter but older islands extend to the northwest. This tutorial makes use of various paleogeographic measurements, such as island age, and estimates, such as paleoarea (size), to help shape biogeographic rates over time. For example, we might expect that terrestrial plants have higher extinction rates the oldest (barren) islands or that the plants cannot colonize islands below sea level (impossible).

{% figure features %}
<img src="figures/features.png" width="65%">
Expand Down Expand Up @@ -88,20 +88,20 @@ index,mean_age,start_age,end_age,feature_dir
6,18,18.15,17.75,time6
```

Paleogeographic features are further organized into subdirectories named `time1`, `time2`, etc. For example, to view quantitative within-region features for layer 1 (max. altitude) at time slice 4, type:
Paleogeographic features are further organized into subdirectories named `time1`, `time2`, etc. For example, to view quantitative within-region features for layer 1 (size, km^2) at time slice 4, type:
```
$ # from command line
$ cat ./data/hawaii/time4/qw_feature1.csv
G,N,K,O,M,H,Z
50,500,3787,nan,nan,nan,1500
```

Below is a visualization of maximum island altitude across regions and epoch, made by summarizing the feature files across the different `time` directories:
Below is a visualization of island size (km^2) across regions and epoch, made by summarizing the feature files across the different `time` directories:

{% figure feature_times %}
<img src="figures/plot_features_vs_time.feat_qw1.png" width="40%">
{% figcaption %}
Maximum altitude values for seven regions across seven epochs. This quantitative within-region feature may influence within-region speciation and extinction rates through the sign and magnitude of the estimated $\phi_w^{(1)}$ and $\phi_e^{(1)}$ parameters. Light colors are small values, dark colors are large values, and gray indicates the region was absent (missing feature).
Region size values for seven regions across seven epochs. This quantitative within-region feature may influence within-region speciation and extinction rates through the sign and magnitude of the estimated $\phi_w^{(1)}$ and $\phi_e^{(1)}$ parameters. Light colors are small values, dark colors are large values, and gray indicates the region was absent (missing feature).
{% endfigcaption %}
{% endfigure %}

Expand Down
Binary file modified tutorials/timefig_simple/timefig_simple_project.zip
Binary file not shown.