Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lianos committed Aug 26, 2023
1 parent 6d57605 commit 9f2fc0e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
12 changes: 12 additions & 0 deletions R/assaySelect-module.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,21 @@ assaySelectServer <- function(id, rfds, ..., debug = FALSE) {
if (unselected(state$assay_info)) "" else state$assay_info$assay
})

assay_info <- reactive({
active_assays(rfds) |>
filter(.data$assay == assay_name())
})

features <- reactive({
req(!unselected(assay_name()))
FacileData::features(rfds$fds(), assay_name = assay_name())
})

vals <- list(
assay_name = assay_name,
assay_names = assay_names,
assay_info = assay_info,
features = features,
.state = state,
.ns = session$ns)
class(vals) <- c("AssaySelectModule", "Labeled")
Expand Down
28 changes: 19 additions & 9 deletions R/facileDataStoreServer.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,18 @@ facileDataStoreServer <- function(id, x, ...,

if (nrow(state$esample_annotation)) {
ftrace("{bold}{red}adding ephemeral sample covariates [pdata]")
# TODO: pivot into wide form and presere type
ephemeral <- state$esample_annotation |>
select(dataset, sample_id, variable, value) |>
tidyr::pivot_wider(
id_cols = c("dataset", "sample_id"),
names_from = "variable")
is_long <- local({
check <- c("variable", "value")
length(setdiff(check, colnames(state$esample_annotation)) == 0)
})
if (is_long) {
# TODO: pivot into wide form and presere type
ephemeral <- state$esample_annotation |>
select(dataset, sample_id, variable, value) |>
tidyr::pivot_wider(
id_cols = c("dataset", "sample_id"),
names_from = "variable")
}
out <- left_join(out, ephemeral, by = c("dataset", "sample_id"))
}

Expand Down Expand Up @@ -240,7 +246,7 @@ facileDataStoreServer <- function(id, x, ...,
})
}

#' Crate a facileDataStoreServer module form whatevrrrrrrrrr
#' Create a server module form a non-reactive context.
#'
#' @export
#' @param id the id of the server module
Expand All @@ -250,8 +256,12 @@ facileDataStoreServer <- function(id, x, ...,
#' @return a [facileDataStoreServer()] module
FacileDataStoreServer <- function(id, x, samples_subset = NULL, ...) {
assert_string(id)
if (is(x, "reactive")) x <- x()
if (is(samples_subset, "reactive")) samples_subset <- samples_subset()
if (is(x, "reactive")) {
stop("You can only use this in non-reactive context")
}
if (is(samples_subset, "reactive")) {
stop("You can only use this in non-reactive context")
}

if (test_string(x) || is(x, "FacileDataStore")) {
xx <- reactive(x)
Expand Down
4 changes: 2 additions & 2 deletions man/facileDataStoreServer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion tests/shiny-modules/module-gallery.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ shiny::shinyApp(
fdslist <- FacileShine::facileDataSetSelectServer(
"fdslist", reactive(datadir))

rfds <- FacileShine::facileDataStoreServer(
# rfds <- FacileShine::facileDataStoreServer(
# "rfds", fdslist$path, user = user, debug = debug)
rfds <- FacileShine::FacileDataStoreServer(
"rfds", fdslist$path, user = user, debug = debug)

output$rfdsdebug <- shiny::renderText({
Expand Down

0 comments on commit 9f2fc0e

Please sign in to comment.