|
| 1 | +## ----biocstyle, echo = FALSE, messages = FALSE, results = "hide"-------------- |
| 2 | +BiocStyle::markdown() |
| 3 | + |
| 4 | +## ----init, message = FALSE, echo = FALSE, results = "hide"-------------------- |
| 5 | +## Silently loading all packages |
| 6 | +library(BiocStyle) |
| 7 | +library(desc) |
| 8 | +library(kableExtra) |
| 9 | +library(tidyverse) |
| 10 | + |
| 11 | +## ----load REcoTox package, eval = FALSE, echo = TRUE, message = FALSE, warning = FALSE---- |
| 12 | +# # Load the REcoTox package |
| 13 | +# library(REcoTox) |
| 14 | + |
| 15 | +## ----R Documentation, echo = TRUE, eval = FALSE------------------------------- |
| 16 | +# # Documentation of REcoTox |
| 17 | +# help(package = "REcoTox") |
| 18 | + |
| 19 | +## ----initialize folders, echo = TRUE, message = FALSE, warning = FALSE, eval = TRUE---- |
| 20 | +# Path of the project folder |
| 21 | +project_folder <- "REcoTox_demo" |
| 22 | + |
| 23 | +database_folder <- system.file("extdata/database_folder", package="REcoTox") |
| 24 | +# The project folder is created in the home directory |
| 25 | +project_path <- normalizePath(ifelse(.Platform$OS.type == "unix", |
| 26 | + paste0("~/", project_folder), |
| 27 | + paste0( |
| 28 | + Sys.getenv("HOMEPATH"), |
| 29 | + "\\", |
| 30 | + project_folder |
| 31 | + ) |
| 32 | +)) |
| 33 | + |
| 34 | +# An existing folder is deleted |
| 35 | +if (dir.exists(project_folder)) { |
| 36 | + unlink(project_folder, recursive = TRUE) |
| 37 | +} |
| 38 | + |
| 39 | +## ----create project, echo = TRUE, message = FALSE, warning = FALSE, eval = TRUE---- |
| 40 | +project <- REcoTox::create_project(database_path = database_folder, |
| 41 | + project_path, |
| 42 | + initalise_database_project = TRUE, # create the basic project from current ASCII files in DB folder |
| 43 | + initalise_project = TRUE, # initializes the project folder |
| 44 | + load_default = FALSE) # loads the default project in the project folder in the memoryfault_example = TRUE |
| 45 | + |
| 46 | +file.copy( |
| 47 | + from = system.file( |
| 48 | + "extdata", |
| 49 | + "Query_EcoTox_DB.R", |
| 50 | + package = "REcoTox" |
| 51 | + ), |
| 52 | + to = normalizePath( |
| 53 | + path = file.path( |
| 54 | + project_folder, |
| 55 | + "Query_EcoTox_DB.R" |
| 56 | + ), |
| 57 | + winslash = "\\", |
| 58 | + mustWork = FALSE |
| 59 | + ), |
| 60 | + overwrite = TRUE |
| 61 | + ) |
| 62 | + |
| 63 | + |
| 64 | +## ----list project folder------------------------------------------------------ |
| 65 | +# List files and directories in project_folder |
| 66 | +list.files(project_folder, recursive = TRUE, include.dirs = TRUE) |
| 67 | + |
| 68 | +## ----list database folder----------------------------------------------------- |
| 69 | +# List files and directories in project_folder |
| 70 | +list.files(database_folder, recursive = TRUE, include.dirs = TRUE) |
| 71 | + |
| 72 | +## ----view chemical_properties, echo = TRUE, eval = TRUE, message = TRUE------- |
| 73 | +# Review of the chemical properties |
| 74 | +chemical_properties <- readr::read_csv(file = normalizePath(path = file.path( |
| 75 | + database_folder, |
| 76 | + "chemical_properties.csv" |
| 77 | +), ), show_col_types = FALSE) |
| 78 | + |
| 79 | +kable( |
| 80 | + chemical_properties %>% |
| 81 | + head(5), |
| 82 | + format = "html", |
| 83 | + digits = 2 |
| 84 | +) %>% |
| 85 | +kable_styling("striped", full_width = TRUE) %>% |
| 86 | +scroll_box(width = "700px", height = "300px") |
| 87 | + |
| 88 | +## ----view results, echo = TRUE, eval = TRUE, message = TRUE------------------- |
| 89 | +# Review of the result table |
| 90 | +results <- |
| 91 | + readr::read_delim( |
| 92 | + file = normalizePath( |
| 93 | + path = file.path( |
| 94 | + database_folder, |
| 95 | + "results.txt" |
| 96 | + ), |
| 97 | + ), |
| 98 | + show_col_types = FALSE, |
| 99 | + delim = "|" |
| 100 | + |
| 101 | + ) |
| 102 | + |
| 103 | +kable( |
| 104 | + results %>% |
| 105 | + head(5), |
| 106 | + format = "html", digits = 2 |
| 107 | +) %>% |
| 108 | +kable_styling("striped", full_width = TRUE) %>% |
| 109 | +scroll_box(width = "700px", height = "300px") |
| 110 | + |
| 111 | +## ----view chemicals, echo = TRUE, eval = TRUE, message = TRUE----------------- |
| 112 | +# Review of the substance_table |
| 113 | +substances <- |
| 114 | + readr::read_delim( |
| 115 | + file = normalizePath( |
| 116 | + path = file.path( |
| 117 | + database_folder, |
| 118 | + "validation", |
| 119 | + "chemicals.txt" |
| 120 | + ), |
| 121 | + ), |
| 122 | + show_col_types = FALSE, |
| 123 | + delim = "|" |
| 124 | + |
| 125 | + ) |
| 126 | + |
| 127 | +kable( |
| 128 | + substances %>% |
| 129 | + head(5), |
| 130 | + format = "html", digits = 2 |
| 131 | +) %>% |
| 132 | +kable_styling("striped", full_width = TRUE) %>% |
| 133 | +scroll_box(width = "700px", height = "300px") |
| 134 | + |
| 135 | +## ----view references, echo = TRUE, eval = TRUE, message = TRUE---------------- |
| 136 | +# Review of the substance_table |
| 137 | +references <- |
| 138 | + readr::read_delim( |
| 139 | + file = normalizePath( |
| 140 | + path = file.path( |
| 141 | + database_folder, |
| 142 | + "validation", |
| 143 | + "references.txt" |
| 144 | + ), |
| 145 | + ), |
| 146 | + show_col_types = FALSE, |
| 147 | + delim = "|" |
| 148 | + |
| 149 | + ) |
| 150 | + |
| 151 | +kable( |
| 152 | + references %>% |
| 153 | + head(5), |
| 154 | + format = "html", digits = 2 |
| 155 | +) %>% |
| 156 | +kable_styling("striped", full_width = TRUE) %>% |
| 157 | +scroll_box(width = "700px", height = "300px") |
| 158 | + |
| 159 | +## ----view species, echo = TRUE, eval = TRUE, message = TRUE------------------- |
| 160 | +# Review of the substance_table |
| 161 | +species <- |
| 162 | + readr::read_delim( |
| 163 | + file = normalizePath( |
| 164 | + path = file.path( |
| 165 | + database_folder, |
| 166 | + "validation", |
| 167 | + "species.txt" |
| 168 | + ), |
| 169 | + ), |
| 170 | + show_col_types = FALSE, |
| 171 | + delim = "|" |
| 172 | + |
| 173 | + ) |
| 174 | + |
| 175 | +kable( |
| 176 | + species %>% |
| 177 | + head(5), |
| 178 | + format = "html", digits = 2 |
| 179 | +) %>% |
| 180 | +kable_styling("striped", full_width = TRUE) %>% |
| 181 | +scroll_box(width = "700px", height = "300px") |
| 182 | + |
| 183 | +## ----initialize databases, echo = TRUE, message = FALSE, warning = FALSE, eval = FALSE---- |
| 184 | +# project <- REcoTox::create_project(database_path = database_folder, |
| 185 | +# project_path, |
| 186 | +# initalise_database_project = TRUE, |
| 187 | +# initalise_project = TRUE, |
| 188 | +# load_default = FALSE) |
| 189 | + |
| 190 | +## ----initialize project, echo = TRUE, message = FALSE, warning = FALSE, eval = FALSE---- |
| 191 | +# project <- REcoTox::prepare_data(project = project, |
| 192 | +# load_initial_project = FALSE, |
| 193 | +# new_project_path = NA, |
| 194 | +# save_project = TRUE |
| 195 | +# ) |
| 196 | + |
| 197 | +## ----view pivot tables, echo = FALSE, eval = TRUE, message = TRUE------------- |
| 198 | +# Review of the privot table |
| 199 | +pivot <- |
| 200 | + project$object$results_pivot |
| 201 | + |
| 202 | +kable( |
| 203 | + pivot %>% |
| 204 | + head(5), |
| 205 | + format = "html", digits = 2 |
| 206 | +) %>% |
| 207 | +kable_styling("striped", full_width = TRUE) %>% |
| 208 | +scroll_box(width = "700px", height = "300px") |
| 209 | + |
| 210 | +## ----sessioninfo, echo = TRUE, eval = TRUE, message = FALSE------------------- |
| 211 | +sessionInfo() |
| 212 | + |
| 213 | +## ----clean_up, echo = FALSE, results = "asis", eval = FALSE------------------- |
| 214 | +# unlink(project_folder, recursive = TRUE) |
| 215 | + |
0 commit comments