View source: R/vis_acr_shiny.R
vis_acr_shiny | R Documentation |
vis_acr_shiny is meant to launch a shiny application that helps you visualize your Ancestral State Reconstructions
vis_acr_shiny(phylo, sf, state_df, cellsize = 1)
phylo |
is an object of class phylo with data related to states and their corresponding nodes |
sf |
is an object of class sf that contains the states for visualization |
state_df |
is a df of states and their frequencies. It should be named according to your nodes, and names must be just numbers (e.g. not node1, node2, node3 etc. Each node, needs an entry in the state list. Each dataframe in the list, should only have 2 columns, named state and freq in that order |
cellsize |
I did a dumb thing |
For the phylo object, each node should have a corresponding list that represents the states and their frequencies. A common example output would be similar to that one provided by RASP. This list, should contain a single dataframe, with 2 columns. The first column is the state, and the second column is the frequency.
set.seed(123456)
phylo <- ape::rtree(n = 20)
phylo$node =1:39
states = list()
for(i in 1:39){
states[i] <- list(data.frame(state = sample(c("A",'B','C','D','AB','AC','AD','BC','BD','CD'),
5, replace = FALSE),
freq = sample(c(1,2,3,4,5),5, replace = FALSE)/15))
names(states)[i] <- paste0(i)
}
#Make the SF test
n1 = 2
data1 <- data.frame(x = rep(1:n1, each = n1), # Create data frame for raster
y = rep(1:n1, n1),
value = runif(n1^2))
raster::rasterFromXYZ(data1)%>%
as(.,"SpatialPolygonsDataFrame")%>%
sf::st_as_sf() -> sf
sf$state <- c('A','B','C','D')
state_df <- ASR_list_2_df(states, ML = TRUE)
vis_acr_shiny(phylo, regions, state_df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.