Function plotRateThroughTime malfunctioning

22 views
Skip to first unread message

Humberto Nappo

unread,
Feb 15, 2024, 5:12:52 PM2/15/24
to bamm-project
I am having a problem with plotRateThroughTime(). For some reason I could not identify, the function does not seem to use the correct node for calculating average rates. Comparing with the outputs of all other functions, I can see the age of the clade should be older and the average rates should be higher. Other functions seem to work fine. I include the tree and event data files as well as a RateThroughTime plot (so you can see the error) and a mean phylorate plot (so you can see the correct ages and rates).


# Import tree
Teiidae_tree <- read.tree("dated_tree.nwk") %>%
  ladderize(.)

# Create bammdata files
bammdata_Teiidae <- getEventData("Teiidae_tree.tre",
                                 "event_data.txt",
                                 burnin = 0.1)

# Mean Phylorate
plot.bammdata(bammdata_Teiidae,
              breaksmethod = "jenks",
              spex = "netdiv",
              lwd = 3,
              pal = "temperature",
              labels = T,
              legend = T,
              cex = 0.4)

#Plot rate through time
plotRateThroughTime(bammdata_Teiidae,
                    ratetype = "auto",
                    useMedian = F,
                    intervalCol = "red",
                    avgCol = "red",
                    node = getMRCA(Teiidae_tree,
                                   c("Aspidoscelis_maximus",
                                     "Aspidoscelis_rodecki")),
                    nodetype = "include",
                    ylim = c(0,1.1),
                    xlim = c(30,0),
                    cex.lab = 1.0,
                    cex.axis = 1.5)
RateThroughTime_wrong.pdf
mean_phylorate_correct.pdf
event_data.txt
dated_tree.nwk

pasca...@gmail.com

unread,
Feb 16, 2024, 9:48:01 AM2/16/24
to bamm-project
Hi Humberto,

First of all, you are plotting the phylo-rate plot for net diversification, but your rate through time plot for speciation rate. If you want net div, then specify "netdiv" in plotRateThroughTime() for ratetype.

Beyond that, when I run this, it makes sense to me. I'm not sure why you are seeing something different. Perhaps run a clean session in R, and try again.
This is what I get. Both the timing of the node and the rates make sense.

Screenshot 2024-02-16 at 09.46.27.png

-Pascal

Humberto Nappo

unread,
Feb 16, 2024, 7:01:51 PM2/16/24
to bamm-project
I messed up with the code I copied in this topic but there is a problem indeed. When I plot the RateThroughTime for the MRCA of A. maximus and A. rodecki, this clade age appears as lower than 5 Ma. When you did it, it got the right age. I keep getting the same problem when I try to define other nodes. I already updated R installation (and BAMMtools), started a fresh session but the problem persists.

pasca...@gmail.com

unread,
Feb 18, 2024, 3:01:08 PM2/18/24
to bamm-project
Hi Humberto,

As you can see from the figure I included, based on the code you provided (I only adjusted it to plot net div rate), it works as intended. I don't know why you are getting different results, but I am pretty confident that the BAMMtools code is correct. If you provided an R script that generated a strange result that is reproducible, then I can look into it.

-Pascal

Humberto Nappo

unread,
Feb 19, 2024, 1:19:42 PM2/19/24
to bamm-project
Well, if the problem is on my PC I will try and plot the figure in a different machine. I will come back here to inform the results.
Reply all
Reply to author
Forward
0 new messages