-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- include exported data - add tex file
- Loading branch information
Showing
10 changed files
with
1,585 additions
and
1,031 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,238 @@ | ||
library("stats") | ||
library("stringr") | ||
library("smatr") | ||
library("plyr") | ||
library("tidyr") | ||
library("dplyr") | ||
library("xtable") | ||
library("igraph") | ||
library("rmarkdown") | ||
library("broom") | ||
library("ggtern") | ||
library("ggmap") | ||
library("yaml") | ||
library("mgcv") | ||
library("knitr") | ||
source("R/figures.R") | ||
source("R/FlowerParts.R") | ||
source("R/GraphRepresentation.R") | ||
source("R/Growth.R") | ||
source("R/Investment.R") | ||
source("R/ms-accessory.R") | ||
source("R/ms-RA.R") | ||
source("R/ms-SuppMatt.R") | ||
source("R/ReproductionTissues.R") | ||
source("R/Species.R") | ||
source("R/Summaries.R") | ||
source("R/Utils.R") | ||
source("R/WeightCalculations.R") | ||
dir.create("ms/RA/figures", FALSE, TRUE) | ||
dir.create("ms", FALSE, TRUE) | ||
dir.create("export", FALSE, TRUE) | ||
pdf("ms/RA/figures/schematic.pdf", height = 2.5, width = 7.5) | ||
plotRASexamples() | ||
dev.off() | ||
library("remake") | ||
make_script(file = "analysis.R") | ||
BAER_PartsList <- make_OrderedListsOfParts_BAER() | ||
BOLE_PartsList <- make_OrderedListsOfParts_BOLE() | ||
COER_PartsList <- make_OrderedListsOfParts_COER() | ||
EPMI_PartsList <- make_OrderedListsOfParts_EPMI() | ||
GRBU_PartsList <- make_OrderedListsOfParts_GRBU() | ||
GRSP_PartsList <- make_OrderedListsOfParts_GRSP() | ||
HATE_PartsList <- make_OrderedListsOfParts_HATE() | ||
HEPU_PartsList <- make_OrderedListsOfParts_HEPU() | ||
LEES_PartsList <- make_OrderedListsOfParts_LEES() | ||
PELA_PartsList <- make_OrderedListsOfParts_PELA() | ||
PEPU_PartsList <- make_OrderedListsOfParts_PEPU() | ||
PHPH_PartsList <- make_OrderedListsOfParts_PHPH() | ||
PILI_PartsList <- make_OrderedListsOfParts_PILI() | ||
PUTU_PartsList <- make_OrderedListsOfParts_PUTU() | ||
pdf("ms/map.pdf", width = 4L, height = 4L) | ||
figure_site_map("data/sites.csv") | ||
dev.off() | ||
IndividualsList <- read_csv("data/individuals.csv") | ||
FlowerPartsData <- read_csv("data/flowerParts.csv") | ||
Reproduction_raw <- read_csv("data/reproduction.csv") | ||
ReproductionData <- filterForAllocation(Reproduction_raw, IndividualsList) | ||
HarvestData_raw <- read_csv("data/harvest.csv") | ||
HarvestData <- preprocessHarvest(HarvestData_raw, IndividualsList) | ||
FloweringCategories <- read_csv("data/flowerCategories.csv") | ||
MultiplierTable <- read_csv("data/multiplierTable.csv") | ||
InvestmentCategories <- yaml.load_file("data/accessoryParts.yml") | ||
LMA_1 <- read_csv("data/LMA.csv") | ||
LMA <- process_LMA(LMA_1) | ||
wood_density_spp1 <- read_csv("data/woodDensity.csv") | ||
wood_density_spp <- process_wood_density(wood_density_spp1) | ||
seedsize <- read_csv("data/seedsize.csv") | ||
leavesPerLength_1 <- read_csv("data/leaves_per_length.csv") | ||
leavesPerLength <- process_leaves_per_length(leavesPerLength_1) | ||
leafLoss_1 <- read_csv("data/leaderGrowthLL.csv") | ||
leafLoss <- process_leaf_loss(leafLoss_1, leavesPerLength) | ||
variable_list <- read_csv("data/variable_metadata.csv") | ||
write.csv(variable_list, "export/Variable_metadata.csv", row.names = FALSE) | ||
BAER_IndividualsList <- filterToBAER(IndividualsList) | ||
BAER_FlowerPartsData <- filterToBAER(FlowerPartsData) | ||
BAER_HarvestData <- filterToBAER(HarvestData) | ||
BAER_ReproductionData <- filterToBAER(ReproductionData) | ||
BAER_PartsSummary <- make_PartsSummary(BAER_FlowerPartsData, BAER_PartsList) | ||
BAER_GraphMaps <- make_BAER_GraphMaps(BAER_PartsSummary, MultiplierTable) | ||
BAER_Investment <- CalculateInvestmentForBAER(BAER_ReproductionData, FloweringCategories, MultiplierTable, BAER_GraphMaps, BAER_PartsSummary) | ||
BAER_ReproductiveCosts <- CalculateReproductiveCostsForBAER(BAER_IndividualsList, InvestmentCategories, BAER_Investment, BAER_PartsSummary) | ||
BAER_Growth <- CalculateGrowthForBAER(BAER_HarvestData, BAER_IndividualsList) | ||
BOLE_IndividualsList <- filterToBOLE(IndividualsList) | ||
BOLE_FlowerPartsData <- filterToBOLE(FlowerPartsData) | ||
BOLE_HarvestData <- filterToBOLE(HarvestData) | ||
BOLE_ReproductionData <- filterToBOLE(ReproductionData) | ||
BOLE_PartsSummary <- make_PartsSummary(BOLE_FlowerPartsData, BOLE_PartsList) | ||
BOLE_GraphMaps <- make_BOLE_GraphMaps(BOLE_PartsSummary, MultiplierTable) | ||
BOLE_Investment <- CalculateInvestmentForBOLE(BOLE_ReproductionData, FloweringCategories, MultiplierTable, BOLE_GraphMaps, BOLE_PartsSummary) | ||
BOLE_ReproductiveCosts <- CalculateReproductiveCostsForBOLE(BOLE_IndividualsList, InvestmentCategories, BOLE_Investment, BOLE_PartsSummary) | ||
BOLE_Growth <- CalculateGrowthForBOLE(BOLE_HarvestData, BOLE_IndividualsList) | ||
COER_IndividualsList <- filterToCOER(IndividualsList) | ||
COER_FlowerPartsData <- filterToCOER(FlowerPartsData) | ||
COER_HarvestData <- filterToCOER(HarvestData) | ||
COER_ReproductionData <- filterToCOER(ReproductionData) | ||
COER_PartsSummary <- make_PartsSummary(COER_FlowerPartsData, COER_PartsList) | ||
COER_GraphMaps <- make_COER_GraphMaps(COER_PartsSummary, MultiplierTable) | ||
COER_Investment <- CalculateInvestmentForCOER(COER_ReproductionData, FloweringCategories, MultiplierTable, COER_GraphMaps, COER_PartsSummary) | ||
COER_ReproductiveCosts <- CalculateReproductiveCostsForCOER(COER_IndividualsList, InvestmentCategories, COER_Investment, COER_PartsSummary) | ||
COER_Growth <- CalculateGrowthForCOER(COER_HarvestData, COER_IndividualsList) | ||
EPMI_IndividualsList <- filterToEPMI(IndividualsList) | ||
EPMI_FlowerPartsData <- filterToEPMI(FlowerPartsData) | ||
EPMI_HarvestData <- filterToEPMI(HarvestData) | ||
EPMI_ReproductionData <- filterToEPMI(ReproductionData) | ||
EPMI_PartsSummary <- make_PartsSummary(EPMI_FlowerPartsData, EPMI_PartsList) | ||
EPMI_GraphMaps <- make_EPMI_GraphMaps(EPMI_PartsSummary, MultiplierTable) | ||
EPMI_Investment <- CalculateInvestmentForEPMI(EPMI_ReproductionData, FloweringCategories, MultiplierTable, EPMI_GraphMaps, EPMI_PartsSummary) | ||
EPMI_ReproductiveCosts <- CalculateReproductiveCostsForEPMI(EPMI_IndividualsList, InvestmentCategories, EPMI_Investment, EPMI_PartsSummary) | ||
EPMI_Growth <- CalculateGrowthForEPMI(EPMI_HarvestData, EPMI_IndividualsList) | ||
GRBU_IndividualsList <- filterToGRBU(IndividualsList) | ||
GRBU_FlowerPartsData <- filterToGRBU(FlowerPartsData) | ||
GRBU_HarvestData <- filterToGRBU(HarvestData) | ||
GRBU_ReproductionData <- filterToGRBU(ReproductionData) | ||
GRBU_PartsSummary <- make_PartsSummary(GRBU_FlowerPartsData, GRBU_PartsList) | ||
GRBU_GraphMaps <- make_GRBU_GraphMaps(GRBU_PartsSummary, MultiplierTable) | ||
GRBU_Investment <- CalculateInvestmentForGRBU(GRBU_ReproductionData, FloweringCategories, MultiplierTable, GRBU_GraphMaps, GRBU_PartsSummary) | ||
GRBU_ReproductiveCosts <- CalculateReproductiveCostsForGRBU(GRBU_IndividualsList, InvestmentCategories, GRBU_Investment, GRBU_PartsSummary) | ||
GRBU_Growth <- CalculateGrowthForGRBU(GRBU_HarvestData, GRBU_IndividualsList) | ||
GRSP_IndividualsList <- filterToGRSP(IndividualsList) | ||
GRSP_FlowerPartsData <- filterToGRSP(FlowerPartsData) | ||
GRSP_HarvestData <- filterToGRSP(HarvestData) | ||
GRSP_ReproductionData <- filterToGRSP(ReproductionData) | ||
GRSP_PartsSummary <- make_PartsSummary(GRSP_FlowerPartsData, GRSP_PartsList) | ||
GRSP_GraphMaps <- make_GRSP_GraphMaps(GRSP_PartsSummary, MultiplierTable) | ||
GRSP_Investment <- CalculateInvestmentForGRSP(GRSP_ReproductionData, FloweringCategories, MultiplierTable, GRSP_GraphMaps, GRSP_PartsSummary) | ||
GRSP_ReproductiveCosts <- CalculateReproductiveCostsForGRSP(GRSP_IndividualsList, InvestmentCategories, GRSP_Investment, GRSP_PartsSummary) | ||
GRSP_Growth <- CalculateGrowthForGRSP(GRSP_HarvestData, GRSP_IndividualsList) | ||
HATE_IndividualsList <- filterToHATE(IndividualsList) | ||
HATE_FlowerPartsData <- filterToHATE(FlowerPartsData) | ||
HATE_HarvestData <- filterToHATE(HarvestData) | ||
HATE_ReproductionData <- filterToHATE(ReproductionData) | ||
HATE_PartsSummary <- make_PartsSummary(HATE_FlowerPartsData, HATE_PartsList) | ||
HATE_GraphMaps <- make_HATE_GraphMaps(HATE_PartsSummary, MultiplierTable) | ||
HATE_Investment <- CalculateInvestmentForHATE(HATE_ReproductionData, FloweringCategories, MultiplierTable, HATE_GraphMaps, HATE_PartsSummary) | ||
HATE_ReproductiveCosts <- CalculateReproductiveCostsForHATE(HATE_IndividualsList, InvestmentCategories, HATE_Investment, HATE_PartsSummary) | ||
HATE_Growth <- CalculateGrowthForHATE(HATE_HarvestData, HATE_IndividualsList) | ||
HEPU_IndividualsList <- filterToHEPU(IndividualsList) | ||
HEPU_FlowerPartsData <- filterToHEPU(FlowerPartsData) | ||
HEPU_HarvestData <- filterToHEPU(HarvestData) | ||
HEPU_ReproductionData <- filterToHEPU(ReproductionData) | ||
HEPU_PartsSummary <- make_PartsSummary(HEPU_FlowerPartsData, HEPU_PartsList) | ||
HEPU_GraphMaps <- make_HEPU_GraphMaps(HEPU_PartsSummary, MultiplierTable) | ||
HEPU_Investment <- CalculateInvestmentForHEPU(HEPU_ReproductionData, FloweringCategories, MultiplierTable, HEPU_GraphMaps, HEPU_PartsSummary) | ||
HEPU_ReproductiveCosts <- CalculateReproductiveCostsForHEPU(HEPU_IndividualsList, InvestmentCategories, HEPU_Investment, HEPU_PartsSummary) | ||
HEPU_Growth <- CalculateGrowthForHEPU(HEPU_HarvestData, HEPU_IndividualsList) | ||
LEES_IndividualsList <- filterToLEES(IndividualsList) | ||
LEES_FlowerPartsData <- filterToLEES(FlowerPartsData) | ||
LEES_HarvestData <- filterToLEES(HarvestData) | ||
LEES_ReproductionData <- filterToLEES(ReproductionData) | ||
LEES_PartsSummary <- make_PartsSummary(LEES_FlowerPartsData, LEES_PartsList) | ||
LEES_GraphMaps <- make_LEES_GraphMaps(LEES_PartsSummary, MultiplierTable) | ||
LEES_Investment <- CalculateInvestmentForLEES(LEES_ReproductionData, FloweringCategories, MultiplierTable, LEES_GraphMaps, LEES_PartsSummary) | ||
LEES_ReproductiveCosts <- CalculateReproductiveCostsForLEES(LEES_IndividualsList, InvestmentCategories, LEES_Investment, LEES_PartsSummary) | ||
LEES_Growth <- CalculateGrowthForLEES(LEES_HarvestData, LEES_IndividualsList) | ||
PELA_IndividualsList <- filterToPELA(IndividualsList) | ||
PELA_FlowerPartsData <- filterToPELA(FlowerPartsData) | ||
PELA_HarvestData <- filterToPELA(HarvestData) | ||
PELA_ReproductionData <- filterToPELA(ReproductionData) | ||
PELA_PartsSummary <- make_PartsSummary(PELA_FlowerPartsData, PELA_PartsList) | ||
PELA_GraphMaps <- make_PELA_GraphMaps(PELA_PartsSummary, MultiplierTable) | ||
PELA_Investment <- CalculateInvestmentForPELA(PELA_ReproductionData, FloweringCategories, MultiplierTable, PELA_GraphMaps, PELA_PartsSummary) | ||
PELA_ReproductiveCosts <- CalculateReproductiveCostsForPELA(PELA_IndividualsList, InvestmentCategories, PELA_Investment, PELA_PartsSummary) | ||
PELA_Growth <- CalculateGrowthForPELA(PELA_HarvestData, PELA_IndividualsList) | ||
PEPU_IndividualsList <- filterToPEPU(IndividualsList) | ||
PEPU_FlowerPartsData <- filterToPEPU(FlowerPartsData) | ||
PEPU_HarvestData <- filterToPEPU(HarvestData) | ||
PEPU_ReproductionData <- filterToPEPU(ReproductionData) | ||
PEPU_PartsSummary <- make_PartsSummary(PEPU_FlowerPartsData, PEPU_PartsList) | ||
PEPU_GraphMaps <- make_PEPU_GraphMaps(PEPU_PartsSummary, MultiplierTable) | ||
PEPU_Investment <- CalculateInvestmentForPEPU(PEPU_ReproductionData, FloweringCategories, MultiplierTable, PEPU_GraphMaps, PEPU_PartsSummary) | ||
PEPU_ReproductiveCosts <- CalculateReproductiveCostsForPEPU(PEPU_IndividualsList, InvestmentCategories, PEPU_Investment, PEPU_PartsSummary) | ||
PEPU_Growth <- CalculateGrowthForPEPU(PEPU_HarvestData, PEPU_IndividualsList) | ||
PHPH_IndividualsList <- filterToPHPH(IndividualsList) | ||
PHPH_FlowerPartsData <- filterToPHPH(FlowerPartsData) | ||
PHPH_HarvestData <- filterToPHPH(HarvestData) | ||
PHPH_ReproductionData <- filterToPHPH(ReproductionData) | ||
PHPH_PartsSummary <- make_PartsSummary(PHPH_FlowerPartsData, PHPH_PartsList) | ||
PHPH_GraphMaps <- make_PHPH_GraphMaps(PHPH_PartsSummary, MultiplierTable) | ||
PHPH_Investment <- CalculateInvestmentForPHPH(PHPH_ReproductionData, FloweringCategories, MultiplierTable, PHPH_GraphMaps, PHPH_PartsSummary) | ||
PHPH_ReproductiveCosts <- CalculateReproductiveCostsForPHPH(PHPH_IndividualsList, InvestmentCategories, PHPH_Investment, PHPH_PartsSummary) | ||
PHPH_Growth <- CalculateGrowthForPHPH(PHPH_HarvestData, PHPH_IndividualsList) | ||
PILI_IndividualsList <- filterToPILI(IndividualsList) | ||
PILI_FlowerPartsData <- filterToPILI(FlowerPartsData) | ||
PILI_HarvestData <- filterToPILI(HarvestData) | ||
PILI_ReproductionData <- filterToPILI(ReproductionData) | ||
PILI_PartsSummary <- make_PartsSummary(PILI_FlowerPartsData, PILI_PartsList) | ||
PILI_GraphMaps <- make_PILI_GraphMaps(PILI_PartsSummary, MultiplierTable) | ||
PILI_Investment <- CalculateInvestmentForPILI(PILI_ReproductionData, FloweringCategories, MultiplierTable, PILI_GraphMaps, PILI_PartsSummary) | ||
PILI_ReproductiveCosts <- CalculateReproductiveCostsForPILI(PILI_IndividualsList, InvestmentCategories, PILI_Investment, PILI_PartsSummary) | ||
PILI_Growth <- CalculateGrowthForPILI(PILI_HarvestData, PILI_IndividualsList) | ||
PUTU_IndividualsList <- filterToPUTU(IndividualsList) | ||
PUTU_FlowerPartsData <- filterToPUTU(FlowerPartsData) | ||
PUTU_HarvestData <- filterToPUTU(HarvestData) | ||
PUTU_ReproductionData <- filterToPUTU(ReproductionData) | ||
PUTU_PartsSummary <- make_PartsSummary(PUTU_FlowerPartsData, PUTU_PartsList) | ||
PUTU_GraphMaps <- make_PUTU_GraphMaps(PUTU_PartsSummary, MultiplierTable) | ||
PUTU_Investment <- CalculateInvestmentForPUTU(PUTU_ReproductionData, FloweringCategories, MultiplierTable, PUTU_GraphMaps, PUTU_PartsSummary) | ||
PUTU_ReproductiveCosts <- CalculateReproductiveCostsForPUTU(PUTU_IndividualsList, InvestmentCategories, PUTU_Investment, PUTU_PartsSummary) | ||
PUTU_Growth <- CalculateGrowthForPUTU(PUTU_HarvestData, PUTU_IndividualsList) | ||
Growth_all <- combine_Growth(BAER_Growth, BOLE_Growth, COER_Growth, EPMI_Growth, GRBU_Growth, GRSP_Growth, HATE_Growth, HEPU_Growth, LEES_Growth, PELA_Growth, PEPU_Growth, PHPH_Growth, PILI_Growth, PUTU_Growth, NULL) | ||
pdf("ms/RA/figures/leaf_weight.pdf", width = 16L, height = 9L) | ||
figure_leaf_weight(Growth_all) | ||
dev.off() | ||
pdf("ms/RA/figures/height.pdf", width = 16L, height = 9L) | ||
figure_height(Growth_all) | ||
dev.off() | ||
ReproductiveCosts_all <- combine_data_frames(BAER_ReproductiveCosts, BOLE_ReproductiveCosts, COER_ReproductiveCosts, EPMI_ReproductiveCosts, GRBU_ReproductiveCosts, GRSP_ReproductiveCosts, HATE_ReproductiveCosts, HEPU_ReproductiveCosts, LEES_ReproductiveCosts, PELA_ReproductiveCosts, PEPU_ReproductiveCosts, PHPH_ReproductiveCosts, PILI_ReproductiveCosts, PUTU_ReproductiveCosts, NULL) | ||
SummaryInd_1 <- combine_by_individual(IndividualsList, Growth_all, ReproductiveCosts_all, LMA, leafLoss, wood_density_spp, seedsize) | ||
SummaryInd <- sort_by_variable(SummaryInd_1, variable_list) | ||
fits_figure_allocation_all_a <- fit_allocation_model(SummaryInd) | ||
pdf("ms/RA/figures/RA_all_a.pdf", width = 16L, height = 9L) | ||
figure_allocation_all_a(fits_figure_allocation_all_a) | ||
dev.off() | ||
pdf("ms/RA/figures/investment.pdf", width = 16L, height = 9L) | ||
figure_investment_weight(SummaryInd) | ||
dev.off() | ||
SummarySppAge <- get_species_values(SummaryInd, groups = c("species", "age")) | ||
pdf("ms/RA/figures/RA_demo.pdf", width = 16L, height = 4L) | ||
figure_allocation_demo_single(SummarySppAge) | ||
dev.off() | ||
pdf("ms/RA/figures/RA_demo_all.pdf", width = 16L, height = 32L) | ||
figure_allocation_demo_all(SummarySppAge) | ||
dev.off() | ||
pdf("ms/RA/figures/abstract.pdf", width = 8L, height = 4L) | ||
figure_graphical_abstract(SummarySppAge) | ||
dev.off() | ||
SummarySpp <- get_species_values(SummaryInd, groups = "species") | ||
pdf("ms/RA/figures/life_history.pdf", width = 8L, height = 4L) | ||
figure_life_history(SummarySpp, SummarySppAge, fits_figure_allocation_all_a) | ||
dev.off() | ||
pdf("ms/RA/figures/leaf_loss.pdf", width = 4L, height = 4L) | ||
figure_LMA_leafloss(SummarySpp) | ||
dev.off() | ||
write.csv(SummaryInd, "export/SummaryInd.csv", row.names = FALSE) | ||
PartsSummary_all <- combine_list_elements(BAER_PartsSummary, BOLE_PartsSummary, COER_PartsSummary, EPMI_PartsSummary, GRBU_PartsSummary, GRSP_PartsSummary, HATE_PartsSummary, HEPU_PartsSummary, LEES_PartsSummary, PELA_PartsSummary, PEPU_PartsSummary, PHPH_PartsSummary, PILI_PartsSummary, PUTU_PartsSummary, element = "AvWeightPerUnit") | ||
Investment_FD_all <- combine_list_elements(BAER_Investment, BOLE_Investment, COER_Investment, EPMI_Investment, GRBU_Investment, GRSP_Investment, HATE_Investment, HEPU_Investment, LEES_Investment, PELA_Investment, PEPU_Investment, PHPH_Investment, PILI_Investment, PUTU_Investment, element = "FD") | ||
knitr::knit("ms/RA/Wenk-RA-SI.Rnw", "ms/RA/Wenk-RA-SI.tex") | ||
latex_build("ms/RA/Wenk-RA-SI.tex", clean = TRUE) |
Oops, something went wrong.