Skip to content

Commit a68f68d

Browse files
committed
Update to version 4.14.1
1 parent 0750ce5 commit a68f68d

78 files changed

Lines changed: 3689 additions & 1053 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.Rbuildignore

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
^.*\.Rproj$
22
^\.Rproj\.user$
3-
^doc$
4-
^Meta$
5-
^_pkgdown\.yml$
6-
^docs$
7-
^pkgdown$
8-
^sandbox$
9-
^script_pkgdown.R$
3+
^data-raw$
4+
dev_history.R
5+
^dev$
6+
$run_dev.*
7+
^LICENSE\.md$
8+
^README\.Rmd$
9+
^app\.R$
10+
^rsconnect$

DESCRIPTION

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,44 @@
11
Package: pr2database
2-
Type: Package
3-
Title: PR2 database
4-
Version: 4.14.0
5-
Author: Daniel Vaulot
6-
Maintainer: Daniel Vaulot <[email protected]>
2+
Title: PR2 database with shiny web interface
3+
Version: 4.14.1
4+
Authors@R: person('Daniel', 'Vaulot', email = '[email protected]', role = c('cre', 'aut'))
75
Description: PR2 database
86
See https://pr2-database.org
9-
License: CC-BY 4.0
7+
License: MIT + file LICENSE
8+
Imports:
9+
Biostrings,
10+
blaster (>= 1.0.4),
11+
config (>= 0.3.1),
12+
dplyr,
13+
DT,
14+
forcats,
15+
ggplot2,
16+
golem (>= 0.3.5),
17+
markdown,
18+
pkgload,
19+
purrr,
20+
qs,
21+
rio,
22+
shiny (>= 1.7.2),
23+
shinycssloaders,
24+
shinydisconnect,
25+
shinylogs,
26+
shinyvalidate,
27+
shinyWidgets,
28+
stringr,
29+
tidyr,
30+
yaml
1031
Encoding: UTF-8
1132
LazyData: true
1233
RoxygenNote: 7.1.2
34+
URL: https://github.com/pr2database
35+
BugReports: https://github.com/pr2database/issues
1336
Suggests:
14-
knitr,
15-
rmarkdown
16-
VignetteBuilder: knitr
37+
spelling,
38+
testthat (>= 3.0.0)
39+
Config/testthat/edition: 3
40+
Language: en-US
1741
Depends:
1842
R (>= 2.10)
43+
Remotes:
44+
manutamminen/blaster

NAMESPACE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
export(pr2_database)
4+
export(run_app)
5+
import(dplyr)
6+
import(forcats)
7+
import(ggplot2)
8+
import(markdown)
9+
import(shiny)
10+
import(stringr)
11+
importFrom(golem,activate_js)
12+
importFrom(golem,add_resource_path)
13+
importFrom(golem,bundle_resources)
14+
importFrom(golem,favicon)
15+
importFrom(golem,with_golem_options)
16+
importFrom(shiny,HTML)
17+
importFrom(shiny,column)
18+
importFrom(shiny,shinyApp)
19+
importFrom(shiny,tagAppendAttributes)
20+
importFrom(shiny,tagList)
21+
importFrom(shiny,tags)

R/app_config.R

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#' Access files in the current app
2+
#'
3+
#' NOTE: If you manually change your package name in the DESCRIPTION,
4+
#' don't forget to change it here too, and in the config file.
5+
#' For a safer name change mechanism, use the `golem::set_golem_name()` function.
6+
#'
7+
#' @param ... character vectors, specifying subdirectory and file(s)
8+
#' within your package. The default, none, returns the root of the app.
9+
#'
10+
#' @noRd
11+
app_sys <- function(...) {
12+
system.file(..., package = "pr2database")
13+
}
14+
15+
16+
#' Read App Config
17+
#'
18+
#' @param value Value to retrieve from the config file.
19+
#' @param config GOLEM_CONFIG_ACTIVE value. If unset, R_CONFIG_ACTIVE.
20+
#' If unset, "default".
21+
#' @param use_parent Logical, scan the parent directory for config file.
22+
#' @param file Location of the config file
23+
#'
24+
#' @noRd
25+
get_golem_config <- function(
26+
value,
27+
config = Sys.getenv(
28+
"GOLEM_CONFIG_ACTIVE",
29+
Sys.getenv(
30+
"R_CONFIG_ACTIVE",
31+
"default"
32+
)
33+
),
34+
use_parent = TRUE,
35+
# Modify this if your config file is somewhere else
36+
file = app_sys("golem-config.yml")
37+
) {
38+
config::get(
39+
value = value,
40+
config = config,
41+
file = file,
42+
use_parent = use_parent
43+
)
44+
}

R/app_server.R

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#' The application server-side
2+
#'
3+
#' @param input,output,session Internal parameters for {shiny}.
4+
#' DO NOT REMOVE.
5+
#' @import shiny
6+
#' @noRd
7+
app_server <- function(input, output, session) {
8+
9+
# Your application server logic
10+
11+
# Stop the application of the session is closed (after 30 min) - ACTIVATE for web application
12+
session$onSessionEnded(stopApp)
13+
14+
# Disconnection
15+
16+
observeEvent(input$button_disconnect, {session$close()})
17+
18+
# To track usage
19+
shinylogs::track_usage(storage_mode = shinylogs::store_sqlite(path = "logs/"))
20+
21+
22+
# Taxonomy selection on left menu
23+
taxo_selected <- mod_select_taxonomy_server("select_taxonomy")
24+
25+
26+
# Separate sequences filtration from display so can be used in different panels
27+
sequences_filtered <- mod_filter_sequences_server("filter_sequences", taxo_selected)
28+
29+
mod_table_taxonomy_server("table_taxonomy", pr2$taxonomy, taxo_selected)
30+
31+
# Display table of sequences... It is necessary to pass taxo_selected to display correctly number of sequences
32+
mod_table_sequences_server("table_sequences", sequences_filtered, taxo_selected)
33+
34+
# Download the data full and selected sequences
35+
mod_download_server("download", sequences_filtered, taxo_selected)
36+
37+
# Query all sequences
38+
mod_query_server("query")
39+
40+
41+
}

R/app_ui.R

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#' The application User-Interface
2+
#'
3+
#' @param request Internal parameter for `{shiny}`.
4+
#' DO NOT REMOVE.
5+
#' @import shiny
6+
#' @noRd
7+
app_ui <- function(request) {
8+
tagList(
9+
# Leave this function for adding external resources
10+
golem_add_external_resources(),
11+
# Your application UI logic
12+
13+
# --- Page with side bar layout
14+
fluidPage(
15+
16+
# Message for disconnection
17+
18+
shinydisconnect::disconnectMessage(
19+
text = "Server lost connection.",
20+
refresh = "Reload now"
21+
),
22+
23+
title = "PR2 reference database",
24+
sidebarLayout(sidebar(),
25+
mainpanel()
26+
)
27+
)
28+
)
29+
}
30+
31+
#' Add external Resources to the Application
32+
#'
33+
#' This function is internally used to add external
34+
#' resources inside the Shiny application.
35+
#'
36+
#' @import shiny
37+
#' @importFrom golem add_resource_path activate_js favicon bundle_resources
38+
#' @noRd
39+
golem_add_external_resources <- function() {
40+
add_resource_path(
41+
"www",
42+
app_sys("app/www")
43+
)
44+
add_resource_path(
45+
"readme",
46+
app_sys("app/readme")
47+
)
48+
49+
add_resource_path(
50+
"data-qs",
51+
app_sys("app/data-qs")
52+
)
53+
54+
tags$head(
55+
favicon(),
56+
bundle_resources(
57+
path = app_sys("app/www"),
58+
app_title = "PR2 database"
59+
),
60+
61+
# Script to close the windows after some inactivity - ACTIVATE for web application
62+
tags$script(inactivity),
63+
64+
65+
)
66+
}

R/fct_select_taxonomy.R

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
options_picker_taxo <- shinyWidgets::pickerOptions(
2+
actionsBox = TRUE,
3+
selectedTextFormat = "count > 3",
4+
liveSearch = TRUE,
5+
noneSelectedText = "All",
6+
showTick = TRUE,
7+
size = 5
8+
)
9+
10+
options_picker_taxo_kingdom <- shinyWidgets::pickerOptions(
11+
actionsBox = TRUE,
12+
selectedTextFormat = "count > 3",
13+
liveSearch = TRUE,
14+
noneSelectedText = "None",
15+
showTick = TRUE,
16+
size = 5
17+
)
18+
19+
# =================================
20+
21+
# Small function to return the taxo level number
22+
#
23+
# @param taxo_level character
24+
#
25+
# @return the taxo_level number
26+
#
27+
# @noRd
28+
#
29+
# @examples taxo_level_number("genus")
30+
# # [1] 7
31+
#
32+
#
33+
taxo_level_number <- function(taxo_level) {
34+
which(global$taxo_levels == taxo_level)
35+
}
36+
37+
38+
#
39+
# =================================
40+
41+
# Small function to return the taxo level and taxon name
42+
#
43+
# @param kingdom
44+
# @param supergroup
45+
# @param division
46+
# @param class
47+
# @param order
48+
# @param family
49+
# @param genus
50+
# @param species
51+
#
52+
# @return A named vector with 3 elements. The first level which is not NULL, the corresponding name or names and the taxo as a list
53+
#
54+
# @noRd
55+
# #
56+
# @examples
57+
#
58+
# taxo_return("Eukaryota","S", "D", "C", "O", c("F", "F1"), NULL, NULL)
59+
# # $level
60+
# # [1] "family"
61+
# #
62+
# # $name
63+
# # [1] "F" "F1"
64+
# #
65+
# # $kingdom
66+
# # [1] "Eukaryota"
67+
# #
68+
# # $supergroup
69+
# # [1] "S"
70+
# #
71+
# # $division
72+
# # [1] "D"
73+
# #
74+
# # $class
75+
# # [1] "C"
76+
# #
77+
# # $order
78+
# # [1] "O"
79+
# #
80+
# # $family
81+
# # [1] "F" "F1"
82+
# #
83+
# # $genus
84+
# # NULL
85+
# #
86+
# # $species
87+
# # NULL
88+
89+
90+
taxo_return <- function(kingdom, supergroup, division, class, order, family, genus, species) {
91+
92+
93+
taxo_1 <- c(kingdom[1], supergroup[1], division[1], class[1], order[1], family[1], genus[1], species[1])
94+
taxo_list <- list(kingdom = kingdom, supergroup = supergroup, division=division,
95+
class=class, order = order, family = family, genus = genus, species = species)
96+
97+
# The levels for which nothing is selected return NULL and the length of the vector gives the first rank which is NULL
98+
99+
if (length(taxo_1) == 0) {
100+
return( c(level = "kingdom", list(name = unique(global$kingdom)), taxo_list))
101+
}
102+
103+
104+
taxo_level <- global$taxo_levels[length(taxo_1)]
105+
message("Taxo level: ", taxo_level)
106+
107+
108+
# Then the name(s) are just extracted from the list for the taxo_level
109+
110+
taxo_name <- taxo_list[[taxo_level]]
111+
112+
message("Taxo name: ", taxo_name)
113+
114+
# Very strange, the if one puts the name in the list then if there are more than one it is returned as several names (name1, name2 etc...)
115+
# See: https://stackoverflow.com/questions/9031819/add-named-vector-to-a-list
116+
117+
return( c(level = taxo_level, list(name = taxo_name), taxo_list))
118+
}
119+

0 commit comments

Comments
 (0)