# load packages library(tidyverse) library(lubridate) library(cowplot) library(leaflet) library(dplyr) library(knitr) library(DT) #setting working directory knitr::opts_knit$set(root.dir = '..')
map_general <- function(df, color_use) { icos <- iconList( red = makeIcon( iconUrl = paste0("https://storage.googleapis.com/andersenlab.org/img/red.svg"), iconWidth = 15, iconHeight = 15, popupAnchorX = 0.001, popupAnchorY = -15, iconAnchorX = 15/2, iconAnchorY = 15 ), orange = makeIcon( iconUrl = paste0("https://storage.googleapis.com/andersenlab.org/img/orange.svg"), iconWidth = 15, iconHeight = 15, popupAnchorX = 0.001, popupAnchorY = -15, iconAnchorX = 15/2, iconAnchorY = 15 ), blue = makeIcon( iconUrl = paste0("https://storage.googleapis.com/andersenlab.org/img/blue.svg"), iconWidth = 15, iconHeight = 15, popupAnchorX = 0.001, popupAnchorY = -15, iconAnchorX = 15/2, iconAnchorY = 15 ), black = makeIcon( iconUrl = paste0("https://storage.googleapis.com/andersenlab.org/img/black.svg"), iconWidth = 15, iconHeight = 15, popupAnchorX = 0.001, popupAnchorY = -15, iconAnchorX = 15/2, iconAnchorY = 15 ) ) df <- dplyr::filter(df, !is.na(df[[color_use]])) %>% dplyr::mutate(substrate=ifelse(is.na(substrate), "", substrate)) %>% dplyr::arrange(species_id) popup_select <- df %>% dplyr::mutate(popup_use = case_when(length(target_sp) == 3 ~ glue::glue("<h2>{c_label}</h2><hr /> <strong>Collected by:</strong> {collection_by}<br /> <strong>Latitidue, Longitude:</strong> {format(round(collection_latitude, 6), nsmall = 6)}, {format(round(collection_longitude, 6), nsmall = 6)}<br /> <strong>Substrate:</strong> {substrate}<br /> <strong>{target_sp[1]}</strong> {count_1} <strong>{target_sp[2]}</strong> {count_2} <strong>{target_sp[3]}</strong> {count_3}<br /> <img style='width: 150px;' src='{sample_photo1_processed_url}'></a>"), length(target_sp) == 2 ~ glue::glue("<h2>{c_label}</h2><hr /> <strong>Collected by:</strong> {collection_by}<br /> <strong>Latitidue, Longitude:</strong> {format(round(collection_latitude, 6), nsmall = 6)}, {format(round(collection_longitude, 6), nsmall = 6)}<br /> <strong>Substrate:</strong> {substrate}<br /> <strong>{target_sp[1]}</strong> {count_1} <strong>{target_sp[2]}</strong> {count_2}<br /> <img style='width: 150px;' src='{sample_photo1_processed_url}'></a>"), length(target_sp) == 1 ~ glue::glue("<h2>{c_label}</h2><hr /> <strong>Collected by:</strong> {collection_by}<br /> <strong>Latitidue, Longitude:</strong> {format(round(collection_latitude, 6), nsmall = 6)}, {format(round(collection_longitude, 6), nsmall = 6)}<br /> <strong>Substrate:</strong> {substrate}<br /> <strong>{target_sp[1]}</strong> {count_1}<br /> <img style='width: 150px;' src='{sample_photo1_processed_url}'></a>"), TRUE ~ glue::glue("<h2>{c_label}</h2><hr /> <strong>Collected by:</strong> {collection_by}<br /> <strong>Latitidue, Longitude:</strong> {format(round(collection_latitude, 6), nsmall = 6)}, {format(round(collection_longitude, 6), nsmall = 6)}<br /> <strong>Substrate:</strong> {substrate}<br /> <strong>{target_sp[1]}</strong> {count_1} <strong>{target_sp[2]}</strong> {count_2} <strong>{target_sp[3]}</strong> {count_3}<br /> <img style='width: 150px;' src='{sample_photo1_processed_url}'></a>"))) %>% dplyr::distinct(popup_use) %>% dplyr::pull(popup_use) attach(df) leaflet::leaflet(data = df, width = "100%", options = list(zoomControl = T)) %>% addProviderTiles("Stamen.Terrain") %>% leaflet::addMarkers(~collection_longitude, ~collection_latitude, popup = popup_select, popupOptions(maxWidth = 500), icon = icos[ df[[color_use]] ] ) } knitr::knit_hooks$set( warning = function(x, options) { paste('\n\n<div class="alert alert-warning">', gsub('##', '\n', gsub('^##\ Warning:', '**Warning**', x)), '</div>', sep = '\n') }, message = function(x, options) { paste('\n\n<div class="alert alert-info">', gsub('##', '\n', x), '</div>', sep = '\n') } )
sf <- lubridate::stamp("Tuesday, September 30, 1997") # pull information on project projects <- pull(df%>%dplyr::distinct(project)%>%dplyr::filter(!is.na(project))) collectors <- pull(df%>%dplyr::distinct(collection_by)%>%dplyr::filter(!is.na(collection_by))) isolators <- pull(df%>%dplyr::distinct(isolation_by)%>%dplyr::filter(!is.na(isolation_by))) collection_dates <- pull(df%>%dplyr::distinct(collection_date_UTC)%>% dplyr::filter(!is.na(collection_date_UTC)) %>% dplyr::arrange(collection_date_UTC)) %>% ymd() %>% sf() isolation_dates <- pull(df%>%dplyr::distinct(isolation_date_UTC)%>% dplyr::filter(!is.na(isolation_date_UTC)) %>% dplyr::arrange(isolation_date_UTC)) %>% ymd() %>% sf() # make personnel dataframe personnel_projects <- data.frame(projects) personnel_collectors <- data.frame(collectors) personnel_isolators <- data.frame(isolators) personnel_collection_dates <- data.frame(collection_dates) personnel_isolation_dates <- data.frame(isolation_dates) # print nice tables DT::datatable(personnel_projects, colnames = "easyFulcrum project name:", rownames = FALSE, filter = "none", options = list(dom = 't',ordering=F)) DT::datatable(personnel_collectors, colnames = "Participants in collection:", rownames = FALSE, filter = "none", options = list(dom = 't')) DT::datatable(personnel_isolators, colnames = "Participants in strain isolation:", rownames = FALSE, filter = "none", options = list(dom = 't')) DT::datatable(personnel_collection_dates, colnames = "Dates of collection:", rownames = FALSE, filter = "none", options = list(dom = 't')) DT::datatable(personnel_isolation_dates, colnames = "Dates of isolation:", rownames = FALSE, filter = "none", options = list(dom = 't'))
This table describes whether isolations were made from a collection plate or not and tallies the number of collections in each class.
# temporary table to collect enumerations on certain quantities of interest collection_counts_1 <- df %>% dplyr::filter(!is.na(c_label)) %>% dplyr::group_by(c_label) %>% dplyr::mutate(collection_class = case_when(length(unique(s_label)) >= 2 ~ "with isolates", length(unique(s_label)) < 2 ~ "without isolates"), collection_class = factor(collection_class, levels = c("with isolates", "without isolates"))) %>% dplyr::ungroup() %>% dplyr::arrange(collection_class) %>% dplyr::distinct(c_label, .keep_all = TRUE) %>% dplyr::mutate(`total number of distinct collections` = n()) %>% dplyr::add_count(collection_class) %>% dplyr::rename(collection_class_counts = n) %>% dplyr::select(c_label,collection_class, `total number of distinct collections`, collection_class_counts) collection_distinct <- pull(collection_counts_1%>%dplyr::distinct(`total number of distinct collections`)%>%dplyr::filter(!is.na(`total number of distinct collections`))) collection_class <- collection_counts_1%>% dplyr::distinct(collection_class,collection_class_counts) collection_class <- data.frame(collection_class) collection_class$collection_class <- fct_explicit_na(collection_class$collection_class, "unknown/NA") message(paste("Total number of distinct collections:", collection_distinct, sep = " ")) DT::datatable(collection_class, colnames = c("collection class","number of collections"), rownames = FALSE, filter = "none", options = list(dom = 't'))
collections_df <- df %>% dplyr::select(c_label,s_label,species_id,proc_ambient_temperature,ambient_humidity, proc_substrate_temperature,collection_altitude, substrate, landscape, collection_by) DT::datatable(collections_df, rownames = FALSE, colnames = c("C-label", "S-label", "SpeciesID", "AmbientTemp", "AmbientHumidity", "SubstrateTemp", "Altitude", "Substrate", "Landscape", "CollectedBy"), filter = "none", options = list(dom = 'ftrp', scrollX = '200px'))
all_map_df <- df %>% dplyr::filter(!is.na(c_label)) %>% dplyr::group_by(c_label) %>% dplyr::mutate(collection_class = case_when(length(unique(s_label)) >= 2 ~ "with isolates", length(unique(s_label)) < 2 ~ "without isolates"), collection_class = factor(collection_class, levels = c("with isolates", "without isolates"))) %>% dplyr::ungroup() %>% dplyr::group_by(c_label, species_id) %>% dplyr::mutate(species_count = n()) %>% dplyr::mutate(`count_1` = ifelse(species_id == target_sp[1] & !is.na(species_id), species_count, 0), `count_2` = ifelse(species_id == target_sp[2] & !is.na(species_id), species_count, 0), `count_3` = ifelse(species_id == target_sp[3] & !is.na(species_id), species_count, 0)) %>% dplyr::ungroup() %>% dplyr::distinct(c_label, species_id, .keep_all =T) %>% dplyr::arrange(c_label, desc(species_count)) %>% dplyr::group_by(c_label) %>% dplyr::mutate(`count_1` = sum(`count_1`), `count_2` = sum(`count_2`), `count_3` = sum(`count_3`)) %>% dplyr::ungroup() %>% dplyr::distinct(c_label, .keep_all =T) %>% dplyr::mutate(color = case_when(collection_class == "with isolates" ~ "red", collection_class == "without isolates" ~ "black")) general_map <- map_general(all_map_df,"color") general_map
red points are collections with target isolations.
black points are collections without target isolations.
stat_df <- df %>% dplyr::distinct(project, c_label, .keep_all = T) %>% dplyr::select(project, c_label, s_label, species_id, proc_ambient_temperature, ambient_humidity, proc_substrate_temperature, collection_altitude) %>% tidyr::gather(env_par, value, proc_ambient_temperature,ambient_humidity, proc_substrate_temperature, collection_altitude) plot_atemp <- ggplot(data = stat_df %>% dplyr::filter(env_par == "proc_ambient_temperature")) + geom_boxplot(aes(x = env_par, y = value), outlier.color = NA) + geom_jitter(aes(x = env_par, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(x = "", y = "Ambient temperature (°C)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") plot_stemp <- ggplot(data = stat_df %>% dplyr::filter(env_par == "proc_substrate_temperature")) + geom_boxplot(aes(x = env_par,y = value), outlier.color = NA) + geom_jitter(aes(x = env_par,y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(x = "", y = "Substrate temperature (°C)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") plot_ahum <- ggplot(data = stat_df %>% dplyr::filter(env_par == "ambient_humidity")) + geom_boxplot(aes(x = env_par, y = value), outlier.color = NA) + geom_jitter(aes(x = env_par, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(x = "", y = "Ambient humidity (%)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") plot_elev <- ggplot(data = stat_df %>% dplyr::filter(env_par == "collection_altitude")) + geom_boxplot(aes(x = env_par, y = value), outlier.color = NA) + geom_jitter(aes(x = env_par, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(x = "", y = "Elevation (m)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") cowplot::plot_grid(plot_atemp, plot_stemp, plot_ahum, plot_elev, ncol = 2, nrow = 2, align = "hv", axis = "l")
# temporary table to collect enumerations on certain quantities of interest isolation_counts_1 <- df %>% dplyr::mutate(class = case_when(!is.na(species_id) ~ species_id, TRUE ~ NA_character_)) %>% dplyr::distinct(s_label, .keep_all = TRUE) %>% dplyr::filter(!is.na(s_label)) %>% dplyr::mutate(`total number of distinct isolations` = n()) %>% dplyr::add_count(class) %>% dplyr::rename(class_counts = n) %>% dplyr::select(c_label,class,`total number of distinct isolations`,class_counts) isolation_distinct <- pull(isolation_counts_1%>%dplyr::distinct(`total number of distinct isolations`)%>%dplyr::filter(!is.na(`total number of distinct isolations`))) isolation_species_id <- isolation_counts_1%>% dplyr::distinct(class,class_counts) isolation_species_id <- data.frame(isolation_species_id) isolation_species_id$class[is.na(isolation_species_id$class)] <- "unknown/NA" message(paste("Total number of distinct isolations:", isolation_distinct, sep = " ")) DT::datatable(isolation_species_id, colnames = c("isolation class","number of isolations"), rownames = FALSE, filter = "none", options = list(dom = 't'))
target_df <- df %>% dplyr::filter(species_id %in% target_sp) %>% dplyr::select(c_label,s_label,species_id,proc_ambient_temperature,ambient_humidity, proc_substrate_temperature,collection_altitude, substrate, landscape, collection_by) DT::datatable(target_df, rownames = FALSE, colnames = c("C-label", "S-label", "SpeciesID", "AmbientTemp", "AmbientHumidity", "SubstrateTemp", "Altitude", "Substrate", "Landscape", "CollectedBy"), filter = "none", options = list(dom = 'ftrp', scrollX = '200px'))
target_map_df <- df %>% dplyr::filter(!is.na(c_label)) %>% dplyr::group_by(c_label) %>% dplyr::mutate(collection_class = case_when(length(unique(s_label)) >= 2 ~ "with isolates", length(unique(s_label)) < 2 ~ "without isolates"), collection_class = factor(collection_class, levels = c("with isolates", "without isolates"))) %>% dplyr::ungroup() %>% dplyr::group_by(c_label, species_id) %>% dplyr::mutate(species_count = n()) %>% dplyr::mutate(`count_1` = ifelse(species_id == target_sp[1] & !is.na(species_id), species_count, 0), `count_2` = ifelse(species_id == target_sp[2] & !is.na(species_id), species_count, 0), `count_3` = ifelse(species_id == target_sp[3] & !is.na(species_id), species_count, 0)) %>% dplyr::ungroup() %>% dplyr::distinct(c_label, species_id, .keep_all =T) %>% dplyr::arrange(c_label, desc(species_count)) %>% dplyr::group_by(c_label) %>% dplyr::mutate(`count_1` = sum(`count_1`), `count_2` = sum(`count_2`), `count_3` = sum(`count_3`)) %>% dplyr::ungroup() %>% dplyr::filter(species_id %in% target_sp) %>% dplyr::distinct(c_label, .keep_all =T) %>% dplyr::mutate(color = "black") target_map <- map_general(target_map_df,"color") target_map
stat_df <- df %>% dplyr::filter(species_id %in% target_sp) %>% dplyr::distinct(project, c_label, species_id, .keep_all = T) %>% dplyr::select(project, c_label, s_label, species_id, proc_ambient_temperature, ambient_humidity, proc_substrate_temperature, collection_altitude) %>% dplyr::mutate(species_id = factor(species_id, levels = target_sp)) %>% tidyr::gather(env_par, value, proc_ambient_temperature,ambient_humidity, proc_substrate_temperature, collection_altitude) # make a palette for up to 5 target species target_palette <- c("red","blue","orange", "green", "pruple") names(target_palette) <- target_sp plot_atemp <- ggplot(data = stat_df %>% dplyr::filter(env_par == "proc_ambient_temperature")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values= target_palette) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Ambient temperature (°C)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") plot_stemp <- ggplot(data = stat_df %>% dplyr::filter(env_par == "proc_substrate_temperature")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values= target_palette) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Substrate temperature (°C)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") plot_ahum <- ggplot(data = stat_df %>% dplyr::filter(env_par == "ambient_humidity")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values= target_palette) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Ambient humidity (%)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") plot_elev <- ggplot(data = stat_df %>% dplyr::filter(env_par == "collection_altitude")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values= target_palette) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Elevation (m)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") cowplot::plot_grid(plot_atemp, plot_stemp, plot_ahum, plot_elev, ncol = 2, nrow = 2, align = "hv", axis = "l")
r if(!is.na(target_sp[1])){target_sp[1]}
eval_1 <- ifelse(df %>% dplyr::filter(species_id == target_sp[1]) %>% dplyr::pull(c_label) %>% length()==0, FALSE,TRUE) if(eval_1 == FALSE & !is.na(target_sp[1])) { warning(paste("There were no", target_sp[1], "isolates for this collection project", sep = " ")) }
df_1 <- df %>% dplyr::filter(species_id == target_sp[1]) %>% dplyr::select(c_label,s_label,species_id,proc_ambient_temperature,ambient_humidity, proc_substrate_temperature,collection_altitude, substrate, landscape, collection_by) DT::datatable(df_1, rownames = FALSE, colnames = c("C-label", "S-label", "SpeciesID", "AmbientTemp", "AmbientHumidity", "SubstrateTemp", "Altitude", "Substrate", "Landscape", "CollectedBy"), filter = "none", options = list(dom = 'ftrp', scrollX = '200px'))
target_df_1 <- target_map_df %>% dplyr::filter(species_id == target_sp[1]) %>% dplyr::mutate(color = target_palette[[1]]) target_map_1 <- map_general(target_df_1,"color") target_map_1
stat_df_1 <- stat_df %>% dplyr::filter(species_id == target_sp[1]) plot_atemp <- ggplot(data = stat_df_1 %>% dplyr::filter(env_par == "proc_ambient_temperature")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values=c("red","blue","orange")) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Ambient temperature (°C)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") plot_stemp <- ggplot(data = stat_df_1 %>% dplyr::filter(env_par == "proc_substrate_temperature")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values=c("red","blue","orange")) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Substrate temperature (°C)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") plot_ahum <- ggplot(data = stat_df_1 %>% dplyr::filter(env_par == "ambient_humidity")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values=c("red","blue","orange")) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Ambient humidity (%)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") plot_elev <- ggplot(data = stat_df_1 %>% dplyr::filter(env_par == "collection_altitude")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values=c("red","blue","orange")) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Elevation (m)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") cowplot::plot_grid(plot_atemp, plot_stemp, plot_ahum, plot_elev, ncol = 2, nrow = 2, align = "hv", axis = "l")
r if(!is.na(target_sp[2])){target_sp[2]}
eval_2 <- ifelse(df %>% dplyr::filter(species_id == target_sp[2]) %>% dplyr::pull(c_label) %>% length()==0, FALSE,TRUE) if(eval_2 == FALSE & !is.na(target_sp[2])) { warning(paste("There were no", target_sp[2], "isolates for this collection project", sep = " ")) }
df_2 <- df %>% dplyr::filter(species_id == target_sp[2]) %>% dplyr::select(c_label,s_label,species_id,proc_ambient_temperature,ambient_humidity, proc_substrate_temperature,collection_altitude, substrate, landscape, collection_by) DT::datatable(df_2, rownames = FALSE, colnames = c("C-label", "S-label", "SpeciesID", "AmbientTemp", "AmbientHumidity", "SubstrateTemp", "Altitude", "Substrate", "Landscape", "CollectedBy"), filter = "none", options = list(dom = 'ftrp', scrollX = '200px'))
target_df_2 <- target_map_df %>% dplyr::filter(species_id == target_sp[2]) %>% dplyr::mutate(color = target_palette[[2]]) target_map_2 <- map_general(target_df_2,"color") target_map_2
stat_df_2 <- stat_df %>% dplyr::filter(species_id == target_sp[2]) plot_atemp <- ggplot(data = stat_df_2 %>% dplyr::filter(env_par == "proc_ambient_temperature")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values = target_palette) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Ambient temperature (°C)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") plot_stemp <- ggplot(data = stat_df_2 %>% dplyr::filter(env_par == "proc_substrate_temperature")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values = target_palette) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Substrate temperature (°C)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") plot_ahum <- ggplot(data = stat_df_2 %>% dplyr::filter(env_par == "ambient_humidity")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values = target_palette) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Ambient humidity (%)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") plot_elev <- ggplot(data = stat_df_2 %>% dplyr::filter(env_par == "collection_altitude")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values = target_palette) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Elevation (m)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") cowplot::plot_grid(plot_atemp, plot_stemp, plot_ahum, plot_elev, ncol = 2, nrow = 2, align = "hv", axis = "l")
r if(!is.na(target_sp[3])){target_sp[3]}
eval_3 <- ifelse(df %>% dplyr::filter(species_id == target_sp[3]) %>% dplyr::pull(c_label) %>% length()==0, FALSE,TRUE) if(eval_3 == FALSE & !is.na(target_sp[3])) { warning(paste("There were no", target_sp[3], "isolates for this collection project", sep = " ")) }
df_3 <- df %>% dplyr::filter(species_id == target_sp[3]) %>% dplyr::select(c_label,s_label,species_id,proc_ambient_temperature,ambient_humidity, proc_substrate_temperature,collection_altitude, substrate, landscape, collection_by) DT::datatable(df_3, rownames = FALSE, colnames = c("C-label", "S-label", "SpeciesID", "AmbientTemp", "AmbientHumidity", "SubstrateTemp", "Altitude", "Substrate", "Landscape", "CollectedBy"), filter = "none", options = list(dom = 'ftrp', scrollX = '200px'))
target_df_3 <- target_map_df %>% dplyr::filter(species_id == target_sp[3]) %>% dplyr::mutate(color = target_palette[[3]]) target_map_3 <- map_general(target_df_3,"color") target_map_3
stat_df_3 <- stat_df %>% dplyr::filter(species_id == target_sp[3]) plot_atemp <- ggplot(data = stat_df_3 %>% dplyr::filter(env_par == "proc_ambient_temperature")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values = target_palette) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Ambient temperature (°C)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") plot_stemp <- ggplot(data = stat_df_3 %>% dplyr::filter(env_par == "proc_substrate_temperature")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values = target_palette) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Substrate temperature (°C)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") plot_ahum <- ggplot(data = stat_df_3 %>% dplyr::filter(env_par == "ambient_humidity")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values = target_palette) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Ambient humidity (%)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") plot_elev <- ggplot(data = stat_df_3 %>% dplyr::filter(env_par == "collection_altitude")) + geom_boxplot(aes(x = species_id, y = value, fill = species_id), outlier.color = NA) + scale_fill_manual(values = target_palette) + geom_jitter(aes(x = species_id, y = value, shape = project), size = 1.5, width = .25) + theme_bw() + theme(axis.title = element_text(size = 8, color = "black"), axis.text = element_text(size = 8, color = "black")) + labs(fill = "Species", x = "", y = "Elevation (m)") + theme(axis.text.x = element_text(size = 9, face = "italic", color = "black"), axis.text.y = element_text(size = 9, face = "plain", color = "black"), axis.title.x = element_text(size = 9, face = "bold", color = "black"), axis.title.y = element_text(size = 9, face = "bold", color = "black"), plot.margin = unit(c(0,1,1,1), "lines"), legend.position = "none") cowplot::plot_grid(plot_atemp, plot_stemp, plot_ahum, plot_elev, ncol = 2, nrow = 2, align = "hv", axis = "l")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.