Browse code

[MINOR] Fixes from release pt1

Giulia Pais authored on 08/06/2021 13:18:21
Showing 4 changed files

... ...
@@ -1,7 +1,6 @@
1 1
 on:
2 2
   push:
3 3
     branches:
4
-      - RELEASE_3_13
5 4
       - master
6 5
 
7 6
 name: pkgdown
... ...
@@ -1258,7 +1258,9 @@ cumulative_count_union <- function(x,
1258 1258
 #' default_stats()
1259 1259
 default_stats <- function() {
1260 1260
     list(
1261
-        diversity = vegan::diversity,
1261
+        shannon = ~ vegan::diversity(.x, index = "shannon"),
1262
+        simpson = ~ vegan::diversity(.x, index = "simpson"),
1263
+        invsimpson = ~ vegan::diversity(.x, index = "invsimpson"),
1262 1264
         sum = ~ sum(.x, na.rm = TRUE),
1263 1265
         count = length,
1264 1266
         describe = ~ tibble::as_tibble(psych::describe(.x))
... ...
@@ -254,6 +254,7 @@ import_association_file <- function(path,
254 254
     filter_for = NULL,
255 255
     import_iss = FALSE,
256 256
     export_widget_path = NULL,
257
+    convert_tp = TRUE,
257 258
     ...) {
258 259
     # Check parameters
259 260
     stopifnot(is.character(path) & length(path) == 1)
... ...
@@ -310,55 +311,45 @@ import_association_file <- function(path,
310 311
         missing_dates
311 312
     )))
312 313
     ## Fix timepoints
313
-    if (!"TimepointMonths" %in% colnames(as_file)) {
314
-        as_file <- as_file %>%
315
-            tibble::add_column(TimepointMonths = NA_real_)
316
-    }
317
-    if (!"TimepointYears" %in% colnames(as_file)) {
314
+    if (convert_tp) {
315
+        if (!"TimepointMonths" %in% colnames(as_file)) {
316
+            as_file <- as_file %>%
317
+                tibble::add_column(TimepointMonths = NA_real_)
318
+        }
319
+        if (!"TimepointYears" %in% colnames(as_file)) {
320
+            as_file <- as_file %>%
321
+                tibble::add_column(TimepointYears = NA_real_)
322
+        }
318 323
         as_file <- as_file %>%
319
-            tibble::add_column(TimepointYears = NA_real_)
320
-    }
321
-    as_file <- as_file %>%
322
-        dplyr::mutate(
323
-            TimepointMonths = dplyr::if_else(
324
-                condition = is.na(.data$TimepointMonths),
325
-                false = .data$TimepointMonths,
326
-                true = dplyr::if_else(
327
-                    condition = as.numeric(.data$TimePoint) == 0,
328
-                    true = 0,
329
-                    false = dplyr::if_else(
330
-                        condition = as.numeric(.data$TimePoint) > 0 &
331
-                            as.numeric(.data$TimePoint) < 30,
332
-                        true = ceiling(as.numeric(.data$TimePoint) / 30),
333
-                        false = round(as.numeric(.data$TimePoint) / 30)
334
-                    )
335
-                )
336
-            ),
337
-            TimepointYears = dplyr::if_else(
338
-                condition = is.na(.data$TimepointYears),
339
-                false = .data$TimepointYears,
340
-                true = dplyr::if_else(
341
-                    condition = as.numeric(.data$TimePoint) == 0,
342
-                    true = 0,
343
-                    false = dplyr::if_else(
344
-                        condition = as.numeric(.data$TimePoint) > 0 &
345
-                            as.numeric(.data$TimePoint) < 360,
346
-                        true = ceiling(as.numeric(.data$TimePoint) / 360),
347
-                        false = round(as.numeric(.data$TimePoint) / 360)
324
+            dplyr::mutate(
325
+                TimepointMonths = dplyr::if_else(
326
+                        condition = as.numeric(.data$TimePoint) == 0,
327
+                        true = 0,
328
+                        false = dplyr::if_else(
329
+                            condition = as.numeric(.data$TimePoint) > 0 &
330
+                                as.numeric(.data$TimePoint) < 30,
331
+                            true = ceiling(as.numeric(.data$TimePoint) / 30),
332
+                            false = round(as.numeric(.data$TimePoint) / 30)
333
+                        )
334
+                    ),
335
+                TimepointYears = dplyr::if_else(
336
+                        condition = as.numeric(.data$TimePoint) == 0,
337
+                        true = 0,
338
+                        false = ceiling(as.numeric(.data$TimePoint) / 360)
348 339
                     )
349
-                )
340
+                ) %>%
341
+            dplyr::mutate(
342
+                TimepointMonths = stringr::str_pad(
343
+                    as.character(.data$TimepointMonths),
344
+                    pad = "0", side = "left", width = 2
345
+                ),
346
+                TimepointYears = stringr::str_pad(
347
+                    as.character(.data$TimepointYears),
348
+                    pad = "0", side = "left", width = 2
349
+                ),
350 350
             )
351
-        ) %>%
352
-        dplyr::mutate(
353
-            TimepointMonths = stringr::str_pad(
354
-                as.character(.data$TimepointMonths),
355
-                pad = "0", side = "left", width = 2
356
-            ),
357
-            TimepointYears = stringr::str_pad(
358
-                as.character(.data$TimepointYears),
359
-                pad = "0", side = "left", width = 2
360
-            ),
361
-        )
351
+    }
352
+
362 353
     widget <- if (something_to_report) {
363 354
         summary_report <- .summary_af_import_msg(
364 355
             pars_prob = parsing_problems, dates_prob = date_problems,
... ...
@@ -95,9 +95,16 @@ generate_Vispa2_launch_AF <- function(association_file, project, pool, path) {
95 95
     }
96 96
     files <- purrr::map2(project, pool, function(x, y) {
97 97
         selected_cols <- association_file %>%
98
-            dplyr::select(dplyr::all_of(reduced_AF_columns())) %>%
98
+            dplyr::select(dplyr::all_of(reduced_AF_columns()),
99
+                          .data$concatenatePoolIDSeqRun) %>%
99 100
             dplyr::filter(.data$ProjectID == x, .data$PoolID == y) %>%
100
-            dplyr::mutate(TagID2 = .data$TagID, .before = .data$TagID)
101
+            dplyr::mutate(TagID2 = .data$TagID, .before = .data$TagID) %>%
102
+            dplyr::mutate(PoolName = dplyr::if_else(
103
+                !is.na(.data$concatenatePoolIDSeqRun),
104
+                .data$concatenatePoolIDSeqRun,
105
+                .data$PoolID
106
+                )) %>%
107
+            dplyr::select(-.data$PoolID, -.data$concatenatePoolIDSeqRun)
101 108
     }) %>% purrr::set_names(paste0(project, "-", pool, "_AF.tsv"))
102 109
     purrr::walk2(files, names(files), function(x, y) {
103 110
         complete_path <- fs::path(path, y)