# !diagnostics off
library(tidyverse)
library(deSolve)
library(data.table)
library(micro.crm)
library(vegan)
rm(list=ls())
# Augument passed from command line
args = commandArgs(trailingOnly=TRUE)
treatment_name = args[1]
# Read files from the community ----
parameter_load(parameter_text = paste0("parameter_script/", treatment_name, ".txt"))
## Community
result <- result_read(dir = "simulation_result/", pattern = treatment_name, threshold = threshold)
# Plot ----
## Community ----
communities <- filter(result, time == max(time), type == "X") %>% select(-time, -type)
### Final composition
p_title <- paste0("Inocula=", I, ", Pool=", S_pool, ", u_main=", group_mu, ", family=", function_group)
p1 <- communities %>%
arrange(value) %>%
ggplot(aes(x = replicate, y = value, fill = function_group)) +
geom_bar(stat="identity", position = 'fill', color = "black") +
facet_grid(.~treatment) +
scale_x_continuous(expand = c(0,0)) +
scale_y_continuous(expand = c(0,0)) +
scale_fill_discrete() +
theme_bw() +
guides(fill = guide_legend(title = "Family"), color = F) +
labs(x = "replicate", y = "relative abundancee") +
ggtitle(p_title)
pdf(paste0("figure/composition_", treatment_name,".pdf")); p1; dev.off()
### Beta diversity
beta_diversity(communities)
## Save final time step ---
# Write result file to txt
parameter_write(result = communities, parameter_list = parameter_list,
file_name = paste0("simulation_result/equilibrium/", treatment_name,"_communities.txt"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.