Commit e65cc6fd authored by peguerin's avatar peguerin
Browse files

tag on cells

parent 884e63f4
###############################################################################
## Codes for the paper:
## Global determinants of freshwater and marine fish genetic diversity
## Authors :
## Stephanie Manel, Pierre-Edouard Guerin, David Mouillot,
## Simon Blanchet, Laure Velez, Camille Albouy, Loic Pellissier
##
## Montpellier, 2017-2019
## Nature communications, 2020
##
###############################################################################
###############################################################################
# load libraries
library(shiny)
library(leaflet)
library(raster)
library(sp)
library(rgdal)
library(rgeos)
library(htmlwidgets)
library(htmltools)
......@@ -17,8 +24,11 @@ library(DT)
library(shinydashboard)
###############################################################################
# load data
#source("prepare_data.R")
load("donnees/cellsDat.RData")
source("prepare_data.R")
###############################################################################
# AESTETHICS
......@@ -26,13 +36,11 @@ gradiant_col_palette=c("#3333A2","#3333FF","#33CBFF","#33FFFF","#FFDF33","#FFA33
bin_col_palette=c("#FFCCCC","#FF6666","#FF0000","#990000")
###############################################################################
# SERVER
r_colors <- rgb(t(col2rgb(colors()) / 255))
names(r_colors) <- colors()
server <- function(input, output, session) {
#selected_data= marineRect %>% dplyr::select(input$cell_datatype)
......@@ -51,13 +59,15 @@ server <- function(input, output, session) {
maFillColor=colorBin(bin_col_palette, selected_data, bins=c(2,4,5,10, max(selected_data)) )(selected_data)
selected_interval_data=c(2,4,5,10, max(selected_data))
conpal=colorBin(bin_col_palette, selected_data, bins=c(2,4,5,10, max(selected_data)) )
titre_legende="Number of species"
titre_legende="Number of sequenced species"
} else if(input$cell_datatype =="mean_genetic_diversity") {
bins_gd = c(0,0.001,0.002,0.003,0.005,0.01,0.025,max(selected_data))
maFillColor= colorBin(gradiant_col_palette, selected_data, bins=bins_gd)(selected_data)
selected_interval_data=bins_gd
conpal = colorBin(gradiant_col_palette, selected_data, bins=bins_gd)
titre_legende="Mean genetic diversity"
titre_legende="Mean genetic diversity"
} else if(input$cell_datatype =="temperature") {
maFillColor= colorNumeric(gradiant_col_palette, selected_data )(selected_data)
selected_interval_data=c(min(selected_data),max(selected_data))
......@@ -68,9 +78,10 @@ server <- function(input, output, session) {
maFillColor=colorBin(bin_col_palette, selected_data, bins=c(2,5,10,20,30, max(selected_data)) )(selected_data)
selected_interval_data=c(2,5,10,20,30, max(selected_data))
conpal=colorBin(bin_col_palette,selected_data, bins=c(2,5,10,20,30, max(selected_data)) )
titre_legende="Mean number of individual sequences per species"
titre_legende="Mean number of available individual sequences per species"
}
labels <- sprintf("<strong>%s</strong><br/> %g", titre_legende, selected_data) %>% lapply(htmltools::HTML)
leaflet() %>%
addProviderTiles(providers$Hydda.Base,
......@@ -82,9 +93,21 @@ server <- function(input, output, session) {
lng1=selected_wt$lng1, lat1=selected_wt$lat1,
lng2=selected_wt$lng2, lat2=selected_wt$lat2,
color="#ffffff",
weight = 1, smoothFactor = 0.55,
opacity = 1.0, fillOpacity = 0.45,
fillColor = maFillColor
dashArray = "1",
weight = 1, smoothFactor = 0.5,
opacity = 1.0, fillOpacity = 0.5,
fillColor = maFillColor,
highlight = highlightOptions(
weight = 5,
color = "#ffffff",
dashArray = "",
fillOpacity = 1,
bringToFront = TRUE),
label = labels,
labelOptions = labelOptions(
style = list("font-weight" = "normal", padding = "2px 8px"),
textsize = "14px",
direction = "auto")
) %>%
addLegend(conpal,
selected_interval_data,
......@@ -94,19 +117,6 @@ server <- function(input, output, session) {
})
#############################################################################
## TABLE
# Clickable object: create a null reactive value to store the ID of the layer
SelectedID <- reactiveVal(NULL)
# Observe statement
observe({
event <- input$map_shape_click
req(event)
SelectedID(event$id)
#print(event$id) # Verification
})
}
###############################################################################
## Codes for the paper:
## Global determinants of freshwater and marine fish genetic diversity
## Authors :
## Stephanie Manel, Pierre-Edouard Guerin, David Mouillot,
## Simon Blanchet, Laure Velez, Camille Albouy, Loic Pellissier
##
## Montpellier, 2017-2019
## Nature communications, 2020
##
###############################################################################
###############################################################################
# load libraries
library(shiny)
library(leaflet)
......@@ -12,19 +23,18 @@ library(shinydashboard)
library(shinycssloaders)
###############################################################################
# DATA
choices_datatype=list("Genetic diversity" = "mean_genetic_diversity",
" Surface temperature" = "temperature",
"Number of species" = "number_of_species",
"Number of sequenced species" = "number_of_species",
"Mean number of individual sequences per species" = "number_of_sequences")
choices_watertype=c("marine","freshwater")
###############################################################################
# UI
ui <- dashboardPage(
dashboardHeader(title = "Worldmap of Fish Genetic Diversity",titleWidth=480),
dashboardSidebar(width=480,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment