Skip to content
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

DPLYR 1.0.6 issue analyzing biogeobears outputs #9

Closed
coyotree opened this issue Nov 2, 2021 · 3 comments
Closed

DPLYR 1.0.6 issue analyzing biogeobears outputs #9

coyotree opened this issue Nov 2, 2021 · 3 comments

Comments

@coyotree
Copy link

coyotree commented Nov 2, 2021

I'm not skilled at cross posting but if you receive the error "Error in DataMask$new(.data, caller_env) : argument "caller_env" is missing, with no default", consider loading dplyr 1.0.5. That fixed my problem when analyzing BioGeoBEARS data using RevGadgets.

Post with correction:
YuLab-SMU/ggtree#399

@RhettRautsaw
Copy link

@coyotree How did you convert BioGeoBEARS output list "res" to treedata that can be read and plotted by RevGadgets?

@coyotree
Copy link
Author

coyotree commented Jan 13, 2022

This all came from @cmt2! The script to convert is attached (or should be, I'm bad at github). It also be found in RevGadgets but I am not sure.

library(devtools)
#install_github(repo="nmatzke/BioGeoBEARS")
library(BioGeoBEARS)
#install_github("cmt2/RevGadgets")
#install_github("GuangchuangYu/ggtree")
library(RevGadgets)
#install.packages("tidytree")
library(tidytree)
#install.packages("tidyverse")
library(tidyverse)
#install.packages("naniar")
library(naniar)
#install_github("willgearty/deeptime")
library(deeptime)

setwd("working_directory")

source("bgb_to_revgadgets.R")

# Begin RevGadgets plotting section
results_path <- "DECJ.Rdata"
geo_data_path <- "geography.file.phy"
tree_path <- "tree.tre"

res_formatted <- bgb_to_revgadgets(results_path = results_path,
                                   geo_data_path = geo_data_path,
                                   tree_path = tree_path)

# gonna need a lot of colors 
n <- length(attributes(res_formatted)$state_labels) 
col_vector <- colorRampPalette(colFun(12))(n)
names(col_vector) <- attributes(res_formatted)$state_labels

pdf("plot1.pdf", width = 10, height = 40)
plotAncStatesMAP(t = res_formatted, cladogenetic = F, tip_labels_size = 1, node_labels_as = "state", 
                 node_labels_size = 1, node_shape = 15, node_labels_centered = T, tip_labels_offset = 5, node_color = col_vector, node_size_as = NULL,
                 node_size = 2, tip_labels_states = T, tip_labels_states_size = 1, tip_labels_states_offset = 1,
                 timeline = T, state_transparency = 1)
dev.off()

pdf("plot2.pdf", width = 10, height = 20)
plotAncStatesPie(t = res_formatted, cladogenetic = TRUE, node_pie_size = .3, tip_labels_states = T, 
                 tip_pies = FALSE, tip_labels_size = 1, timeline =T, node_labels_as = "state",
                 tip_labels_offset = 2, pie_colors = col_vector) +
  ggplot2::theme(legend.position = c(0.2, 0.8)) +
  ggplot2::theme(legend.text = element_text(size = 2))

dev.off()

bgb_to_revgadgets.txt

@RhettRautsaw
Copy link

Thanks @coyotree!! I haven't seen this function anywhere, but that is very useful.

@cmt2 cmt2 closed this as completed Apr 7, 2022
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

No branches or pull requests

3 participants