diff --git a/DESCRIPTION b/DESCRIPTION index 82750b5..5f6d15c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -46,7 +46,6 @@ Imports: htmltools, fontawesome, emojifont, - geneBasisR, waiter, cicerone, shinyanimate @@ -71,7 +70,8 @@ Suggests: printr, ggplot2, heatmaply, - plotly + plotly, + geneBasisR Remotes: github::MarioniLab/geneBasisR, github::camlab-bioml/inferorg, diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c79d717 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,41 @@ +FROM rocker/verse +ARG DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y --no-install-recommends \ + sudo \ + libcurl4-openssl-dev \ + libharfbuzz-dev \ + libfribidi-dev \ + libgsl-dev \ + libgeos-dev \ + && rm -rf /var/lib/apt/lists/* + +RUN R -e "install.packages(c('devtools','BiocManager', 'DT', 'shinyalert', 'reactable', 'bsplus', 'shinyjs', 'plyr', 'shinytest2', 'shinydashboard', 'shinyBS', 'rdrop2', 'shinyanimate', 'stringr', 'yardstick', 'htmltools', 'methods', 'stats', 'gridExtra', 'testthat', 'tools', 'printr', 'ggplot2', 'heatmaply', 'plotly', 'waiter', 'cicerone'), dependencies=T)" +RUN R -e "BiocManager::install(c('scran', 'Seurat', 'caret', 'scuttle', 'scater', 'SummarizedExperiment', 'SingleCellExperiment', 'clustifyr', 'zellkonverter'))" + + +RUN R -e "devtools::install_github('stephenturner/annotables', dependencies = F); devtools::install_github('camlab-bioml/inferorg', dependencies = F)" + +RUn R -e "install.packages(c('sortable', 'randomcoloR', 'emojifont'))" + +RUN R -e "devtools::install_github('MarioniLab/geneBasisR', dependencies = T)" + +RUN R -e "devtools::install_github('react-R/reactR')" + +RUN mkdir /cytosel + +COPY . /cytosel + +COPY R/ /cytosel/R + +WORKDIR /cytosel + +RUN ls + +# RUN cd cytosel + +# RUN yes | R -e "setwd('cytosel'); options(needs.promptUser = FALSE); library(devtools); devtools::load_all()" + +EXPOSE 3888 + +CMD R -e "options(shiny.port = 3888,shiny.host='0.0.0.0'); devtools::load_all(); cytosel()" diff --git a/NAMESPACE b/NAMESPACE index 3f4415f..1f84184 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,7 +3,6 @@ export(cytosel) import(emojifont) import(fontawesome) -import(geneBasisR) import(htmltools) import(reactable) import(shiny) diff --git a/R/analysis.R b/R/analysis.R index 65885d0..381a264 100644 --- a/R/analysis.R +++ b/R/analysis.R @@ -7,32 +7,39 @@ #' @param columns A vector storing columns #' @param pref_assay Assay loaded #' @param p_val_type The type of p-value to use in marker group calculation. Can be either all or any. +#' @param use_rank Whether or not to use the logFC rank as the sorting criteria. Default is TRUE #' compute_fm <- function(sce, columns, pref_assay, allowed_genes, - p_val_type = "all") { + p_val_type = "all", use_rank = T) { library(scran) - fms <- lapply(columns, - function(col) { - test_type <- ifelse(pref_assay == "counts", "binom", "t") ag <- intersect(rownames(sce), allowed_genes) - fm <- scran::findMarkers(sce[ag,], SummarizedExperiment::colData(sce)[[col]], - test.type = test_type, - # BPPARAM = MulticoreParam(), - pval.type = p_val_type, - assay.type = pref_assay) + # fm <- scran::findMarkers(sce[ag,], SummarizedExperiment::colData(sce)[[col]], + # test.type = test_type, + # # BPPARAM = MulticoreParam(), + # pval.type = p_val_type, + # assay.type = pref_assay) + + sort_by_stat <- function(frame, sort_by_rank = use_rank) { + if (isTRUE(sort_by_rank)) { + return (frame[order(frame$rank.logFC.detected, decreasing=F),]) + } else { + return (frame[order(frame$median.logFC.cohen, decreasing=T),]) + } + } + + score <- scran::scoreMarkers(assay(sce[ag,], pref_assay), + colData(sce)[[columns]]) + + fm <- lapply(score, FUN = function(X) sort_by_stat(X)) + # fm <- SimpleList(fm) for(n in names(fm)) { fm[[n]] <- fm[[n]][rownames(fm[[n]]) %in% allowed_genes,] } fm - }) - - names(fms) <- columns - - fms } @@ -47,10 +54,11 @@ compute_fm <- function(sce, columns, pref_assay, allowed_genes, #' @param allowed_genes Set of allowed genes #' @param in_session whether the function is being called in a shiny session or not #' @importFrom dplyr mutate tally group_by filter pull slice_head arrange summarize ungroup -#' @import geneBasisR get_markers <- function(fms, panel_size, marker_strategy, sce, allowed_genes, in_session = T) { + library(geneBasisR) + cell_types_wout_markers <- c() columns <- names(fms) original_multimarkers <- c() @@ -58,17 +66,18 @@ get_markers <- function(fms, panel_size, marker_strategy, sce, allowed_genes, marker <- list(recommended_markers = c(), scratch_markers = c(), top_markers = c()) if(marker_strategy == "geneBasis") { - sce2 <- retain_informative_genes(sce[allowed_genes,], n = 10*panel_size) - genes <- gene_search(sce2, n_genes=panel_size) + sce2 <- geneBasisR::retain_informative_genes(sce[allowed_genes,], n = 10*panel_size) + genes <- geneBasisR::gene_search(sce2, n_genes=panel_size) marker <- list( recommended_markers = genes$gene[!is.na(genes$gene)], scratch_markers = c(), top_markers = genes$gene[!is.na(genes$gene)] ) } else { - for(col in columns) { - fm <- fms[[col]] - n <- length(fm) + + n <- length(fms) + + fm <- fms top_select <- ceiling((panel_size + 10) / n) @@ -84,24 +93,27 @@ get_markers <- function(fms, panel_size, marker_strategy, sce, allowed_genes, original_multimarkers <- c() for(i in seq_len(n)) { f <- fm[[i]] - f <- f[!(rownames(f) %in% recommended),] |> as.data.frame() + + f <- f[!(rownames(f) %in% recommended),] ## Only keep markers that are over-expressed f[is.na(f)] <- 0 - f <- f[f$summary.logFC > 0,] + f <- f[f$median.logFC.cohen > 0,] if(nrow(f) > 0){ selected_markers <- rownames(f)[seq_len(top_select)] recommended_df <- bind_rows(recommended_df, tibble(marker = selected_markers, cell_type = names(fm)[i], - summary.logFC = f[selected_markers,]$summary.logFC)) + median.logFC.cohen = f[selected_markers,]$median.logFC.cohen)) + + # print(recommended_df) expressed_markers <- rownames(f)[seq_len(25)] highly_expressed <- bind_rows(highly_expressed, tibble(marker = expressed_markers, cell_type = names(fm)[i], - summary.logFC = f[expressed_markers,]$summary.logFC)) + median.logFC.cohen = f[expressed_markers,]$median.logFC.cohen)) }else{ @@ -155,7 +167,7 @@ get_markers <- function(fms, panel_size, marker_strategy, sce, allowed_genes, remove <- recommended_df %>% filter(cell_type %in% markers_per_cell_type$cell_type) %>% group_by(marker) %>% - summarize(mean_lfc = mean(summary.logFC)) %>% + summarize(mean_lfc = mean(median.logFC.cohen)) %>% arrange(mean_lfc) %>% slice_head(n = 1) %>% pull(marker) @@ -195,7 +207,7 @@ get_markers <- function(fms, panel_size, marker_strategy, sce, allowed_genes, ## Only keep markers that are over-expressed f[is.na(f)] <- 0 - f <- f[f$summary.logFC > 0,] + f <- f[f$median.logFC.cohen > 0,] new_markers_add <- rownames(f)[seq_len(subset(multimarkers, cell_type == i)$num_markers)] recommended <- c(recommended, new_markers_add) } @@ -205,7 +217,7 @@ get_markers <- function(fms, panel_size, marker_strategy, sce, allowed_genes, scratch <- unique(scratch) top <- recommended #unique(top) - } + marker <- list(recommended_markers = recommended[!is.na(recommended)], scratch_markers = scratch[!is.na(scratch)], top_markers = top[!is.na(top)]) @@ -229,7 +241,7 @@ create_multimarker_frame <- function(frame, recommended_markers) { mutate(num_markers = length(unique(marker)), highest = max(cell_types_expressed_in), lowest = min(cell_types_expressed_in)) |> ungroup() |> - arrange(summary.logFC) |> filter(lowest > 1)) + arrange(median.logFC.cohen) |> filter(lowest > 1)) } @@ -240,7 +252,7 @@ create_multimarker_frame <- function(frame, recommended_markers) { #' recommended_markers, scratch_markers, and top_markers #' @param fms Stored findMarkers outputs get_associated_cell_types <- function(markers, fms) { - fm <- fms[[1]] # For now, we're only doing this for the first + fm <- fms # For now, we're only doing this for the first all_markers <- unique(unlist(markers[c('recommended_markers', 'scratch_markers', 'top_markers')])) @@ -250,9 +262,9 @@ get_associated_cell_types <- function(markers, fms) { tmp <- f[tm,] # get summary statistics for this gene ## return p value if it's a marker, or 1 otherwise - # ifelse(tmp$summary.logFC < 0, 1, tmp$FDR) + # ifelse(tmp$median.logFC.cohen < 0, 1, tmp$FDR) ## New: return summary logFC - -tmp$summary.logFC + -tmp$median.logFC.cohen }) names(pvals)[which.min(pvals)] }) @@ -593,16 +605,15 @@ get_allowed_genes <- function(selected_applications, applications_parsed, sce) { #' @importFrom dplyr mutate_if mutate_at get_cell_type_add_markers_reactable <- function(fm, current_markers) { fm <- fm[!rownames(fm) %in% current_markers,] - fm <- fm[fm$summary.logFC > 0,] + fm <- fm[fm$median.logFC.cohen > 0,] fm <- as.data.frame(head(fm, 50)) - fm <- rownames_to_column(fm, 'Gene') - fm <- fm[,c("Gene", "FDR", "summary.logFC")] - fm$FDR <- signif(fm$FDR, 3) - fm$summary.logFC <- round(fm$summary.logFC, digits = 3) - list(fm = fm, + table <- data.frame(Gene = rownames(fm), + logFC = round(fm$median.logFC.cohen, digits = 3)) + + list(fm = table, reactable = reactable( - fm, + table, selection = "multiple", onClick = "select" ) diff --git a/R/app.R b/R/app.R index 6940573..bd58417 100644 --- a/R/app.R +++ b/R/app.R @@ -1055,7 +1055,7 @@ cytosel <- function(...) { req(allowed_genes()) req(fms()) - showModal(markers_add_modal(allowed_genes(), names(fms()[[1]]), session)) + showModal(markers_add_modal(allowed_genes(), names(fms()), session)) }) # ### ANTIBODY EXPLORER ### @@ -1470,6 +1470,7 @@ cytosel <- function(...) { sce()[,sce()$keep_for_analysis == "Yes"], allowed_genes()) + markers <- markers_list$marker[!is.na(markers_list$marker)] markers$scratch_markers <- scratch_markers_to_keep multimarkers(markers_list$multimarkers) @@ -1655,7 +1656,7 @@ cytosel <- function(...) { observeEvent(input$add_cell_type_markers, { if(!is.null(input$cell_type_markers) && !is.null(fms())) { - tmp <- get_cell_type_add_markers_reactable(fms()[[1]][[input$cell_type_markers]], + tmp <- get_cell_type_add_markers_reactable(fms()[[input$cell_type_markers]], unique(unlist(current_markers()))) current_cell_type_marker_fm <<- tmp$fm @@ -1695,7 +1696,7 @@ cytosel <- function(...) { update_BL(current_markers(), num_markers_in_selected(), num_markers_in_scratch(), - names(fms()[[1]])) + names(fms())) removeModal() }) @@ -1729,7 +1730,7 @@ cytosel <- function(...) { update_BL(current_markers(), num_markers_in_selected(), num_markers_in_scratch(), - names(fms()[[1]])) + names(fms())) } else if(!(input$add_markers %in% rownames(sce()))) { dne_modal(dne = input$add_markers) @@ -1764,7 +1765,7 @@ cytosel <- function(...) { update_BL(current_markers(), num_markers_in_selected(), num_markers_in_scratch(), - names(fms()[[1]])) + names(fms())) updateTabsetPanel(session, "tabs", "marker_selection") } @@ -1806,7 +1807,7 @@ cytosel <- function(...) { update_BL(current_markers(), num_markers_in_selected(), num_markers_in_scratch(), - names(fms()[[1]])) + names(fms())) if(length(not_sce) > 0) { # warning_modal(not_sce) @@ -1863,7 +1864,7 @@ cytosel <- function(...) { update_BL(current_markers(), num_markers_in_selected(), num_markers_in_scratch(), - names(fms()[[1]])) + names(fms())) } if (length(alias$merged) > length(marker) | !all(alias$merged %in% marker) | @@ -1946,7 +1947,7 @@ cytosel <- function(...) { update_BL(current_markers(), num_markers_in_selected(), num_markers_in_scratch(), - names(fms()[[1]])) + names(fms())) removeModal() @@ -2017,7 +2018,7 @@ cytosel <- function(...) { update_BL(current_markers(), num_markers_in_selected(), num_markers_in_scratch(), - names(fms()[[1]])) + names(fms())) showNotification("Marker(s) added successfully.", duration = 3) @@ -2031,7 +2032,7 @@ cytosel <- function(...) { req(sce()) req(possible_umap_dims()) - toggle(id = "precomputed_list", condition = isTruthy(input$precomputed_dim)) + shinyjs::show("precomputed_list") updateSelectInput(session, "possible_precomputed_dims", choices = possible_umap_dims(), selected = possible_umap_dims()[1]) @@ -2244,7 +2245,7 @@ cytosel <- function(...) { reset("read_back_analysis") update_BL(current_markers(), num_markers_in_selected(), num_markers_in_scratch(), - names(fms()[[1]])) + names(fms())) valid_existing_panel(TRUE) original_panel(NULL) umap_top(NULL) @@ -2454,7 +2455,7 @@ cytosel <- function(...) { update_BL(current_markers(), num_markers_in_selected(), num_markers_in_scratch(), - names(fms()[[1]])) + names(fms())) marker_sort(input$panel_sorter) @@ -2595,7 +2596,7 @@ cytosel <- function(...) { update_BL(current_markers(), num_markers_in_selected(), num_markers_in_scratch(), - names(fms()[[1]])) + names(fms())) setProgress(value = 0.25) @@ -2780,7 +2781,11 @@ cytosel <- function(...) { # input_sce <- remove_confounding_genes(input_sce) sce(input_sce) + set_allowed_genes() + shinyjs::hide(id = "download_button") + shinyjs::hide(id = "precomputed") + shinyjs::hide(id = "precomputed_list") toggle(id = "analysis_button", condition = isTruthy(sce())) # toggle(id = "apps", condition = isTruthy(SUBSET_TO_ABCAM)) @@ -2792,6 +2797,9 @@ cytosel <- function(...) { previous_metrics(NULL) current_overall_score(NULL) previous_overall_score(NULL) + possible_umap_dims(NULL) + use_precomputed_umap(FALSE) + if (!isTruthy(input$min_category_count)) { updateNumericInput(session, "min_category_count", 2) @@ -2844,12 +2852,6 @@ cytosel <- function(...) { column(input$coldata_column) } - if (isTruthy(input$bl_top) | isTruthy(current_markers())) { - proceed_with_analysis(FALSE) - showModal(reset_option_on_change_modal("uploaded a new dataset")) - - } - aliases_table(NULL) gene_aliases_to_show(NULL) @@ -2860,17 +2862,22 @@ cytosel <- function(...) { req(proceed_with_analysis()) possible_umap_dims(detect_umap_dims_in_sce(sce())) - - toggle(id = "precomputed", condition = length(possible_umap_dims()) > 0) - - if (isTruthy(curated_selection()) & !isTruthy(use_precomputed_umap())) { - updateCheckboxInput(session, inputId = "precomputed_dim", - value = T) - } - - set_allowed_genes() - toggle(id = "gene_alias_tag", condition = isTruthy(gene_aliases_to_show())) - + + if (length(possible_umap_dims()) > 0) shinyjs::show("precomputed") + if (length(possible_umap_dims()) > 0) shinyjs::show("precomputed_list") + if (length(possible_umap_dims()) > 0) updateCheckboxInput(session, inputId = "precomputed_dim", + value = T) + + if (isTruthy(input$bl_top) | isTruthy(current_markers())) { + proceed_with_analysis(FALSE) + showModal(reset_option_on_change_modal("uploaded a new dataset")) + + } + + req(proceed_with_analysis()) + + shinyjs::hide("gene_alias_tag") + } set_allowed_genes <- function() { diff --git a/README.md b/README.md index 20ccf9b..3d1b9b9 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,19 @@ Alteratively, in the RStudio Desktop console: devtools::load_all(); cytosel() ``` +### Docker + +cytosel can be run in a containerized environment using the following commands. Ensure that Docker is installed for the specific local OS: + +``` +cd cytosel +docker build -t cytosel . +docker run -p 3888:3888 docker.io/library/cytosel +```` + +This should prompt the user to navigate to a local URL such as `http://localhost:3888/` + + ## Developer guide The developer guide for cytosel is in progress and being hosted [here](https://github.com/camlab-bioml/cytosel/wiki/cytosel-Developer-guide) diff --git a/man/compute_fm.Rd b/man/compute_fm.Rd index 54a0de6..bf4cdb6 100644 --- a/man/compute_fm.Rd +++ b/man/compute_fm.Rd @@ -4,7 +4,14 @@ \alias{compute_fm} \title{Compute the findMarkers outputs and store} \usage{ -compute_fm(sce, columns, pref_assay, allowed_genes, p_val_type = "all") +compute_fm( + sce, + columns, + pref_assay, + allowed_genes, + p_val_type = "all", + use_rank = T +) } \arguments{ \item{sce}{A SingleCellExperiment object} @@ -14,6 +21,8 @@ compute_fm(sce, columns, pref_assay, allowed_genes, p_val_type = "all") \item{pref_assay}{Assay loaded} \item{p_val_type}{The type of p-value to use in marker group calculation. Can be either all or any.} + +\item{use_rank}{Whether or not to use the logFC rank as the sorting criteria. Default is TRUE} } \description{ Note: this used to be part of get_markers but needs diff --git a/scripts/benchmarking_shinyapps/send_cytosel_requests.py b/scripts/benchmarking_shinyapps/send_cytosel_requests.py new file mode 100644 index 0000000..47f7dc9 --- /dev/null +++ b/scripts/benchmarking_shinyapps/send_cytosel_requests.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python + +import time +from selenium.webdriver.common.by import By +from selenium import webdriver +from selenium.webdriver.chrome.options import Options as ChromeOptions +from selenium.webdriver.support.wait import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +from selenium.common.exceptions import TimeoutException, ElementClickInterceptedException, NoAlertPresentException + +chrome_options = ChromeOptions() +chrome_options.add_argument('--headless') +chrome_options.add_argument('--disable-gpu') + +driver = webdriver.Chrome(options=chrome_options) +iterations = 0 + +while iterations < 10: + try: + driver.get('https://camlab.shinyapps.io/cytosel/') + try: + alert = driver.switch_to.alert + alert.accept() + except NoAlertPresentException: + pass + + WebDriverWait(driver, 180).until( + EC.visibility_of_element_located((By.ID, "curated_dataset")) + ) + + try: + alert = driver.switch_to.alert + alert.accept() + except NoAlertPresentException: + pass + + driver.find_element(By.ID, "curated_dataset").click() + WebDriverWait(driver, 180).until( + EC.visibility_of_element_located((By.ID, "pick_curated")) + ) + driver.find_element(By.ID, "pick_curated").click() + print("curated selected") + + element = WebDriverWait(driver, 180).until( + EC.visibility_of_element_located((By.ID, "start_analysis"))) + + element.click() + + try: + alert = driver.switch_to.alert + alert.accept() + except NoAlertPresentException: + pass + + print("starting analysis") + + # gene_tab_visible = WebDriverWait(driver, 180).until( + # EC.visibility_of_element_located((By.XPATH, '//a[contains(@href,"#shiny-tab-gene-expression")]')) + # ) + + analysis_successful = WebDriverWait(driver, 300).until( + EC.visibility_of_element_located((By.ID, "markers_change_modal"))) + + print("panel generated.") + + umap_is_ready = WebDriverWait(driver, 180).until( + EC.visibility_of_element_located((By.XPATH, '//a[contains(@href,"#shiny-tab-UMAP")]'))) + umap_is_ready.click() + + # umap_visible = WebDriverWait(driver, 180).until( + # EC.visibility_of_element_located((By.ID, "show_umap_legend"))) + + umap_is_visible = WebDriverWait(driver, 180).until( + EC.visibility_of_element_located((By.XPATH, "//span[.='Show UMAP plot legends']"))) + + time.sleep(3) + + print("rendering UMAP.") + + except (TimeoutException, ElementClickInterceptedException) as error: + print("Unable to perform the complete cytosel analysis.") + + iterations += 1 + + + diff --git a/scripts/tabula_sapiens/bulk_download_ts_datasets.py b/scripts/tabula_sapiens/bulk_download_ts_datasets.py index fbe6e88..8bce995 100644 --- a/scripts/tabula_sapiens/bulk_download_ts_datasets.py +++ b/scripts/tabula_sapiens/bulk_download_ts_datasets.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import requests import os from tqdm import * diff --git a/tests/testthat/recommendations.tsv b/tests/testthat/recommendations.tsv index c6f33fc..113caae 100644 --- a/tests/testthat/recommendations.tsv +++ b/tests/testthat/recommendations.tsv @@ -1,4 +1,4 @@ -marker cell_type summary.logFC +marker cell_type median.logFC.cohen TXNIP Cell_1 1.69746207532874 PTPRCAP Cell_1 1.5044159987842 S100A10 Cell_10 1.43691581887884 diff --git a/tests/testthat/test_functions.R b/tests/testthat/test_functions.R index eb9e5dd..3cd3ddb 100644 --- a/tests/testthat/test_functions.R +++ b/tests/testthat/test_functions.R @@ -100,33 +100,36 @@ test_that("get_markers and compute_fm return different results with different p- sce_path <- test_path("pbmc_small.rds") sce <- read_input_scrnaseq(sce_path, filter_counts = F) + sce <- sce[,!sce$seurat_annotations %in% c("Platelet", "Undetermined")] + # sce$cell_type <- sample(c("A", "B"), ncol(sce), replace=TRUE) fms_1 <- compute_fm(sce, "seurat_annotations", "logcounts", - rownames(sce) + rownames(sce), + use_rank = F ) markers_1 <- get_markers(fms_1, panel_size = 12, marker_strategy = 'standard', sce = sce, allowed_genes = rownames(sce)) - expect_true(is_empty(markers_1$multimarkers)) - - fms_2 <- compute_fm(sce, - "fake_col", - "logcounts", - rownames(sce), - p_val_type = "any" - ) - - markers_2 <- get_markers(fms_2, panel_size = 12, marker_strategy = 'standard', - sce = sce, - allowed_genes = rownames(sce)) - - expect_false(is.null(markers_2$multimarkers)) + expect_false(is_empty(markers_1$multimarkers)) + # fms_2 <- compute_fm(sce, + # "fake_col", + # "logcounts", + # rownames(sce), + # p_val_type = "any" + # ) + # + # markers_2 <- get_markers(fms_2, panel_size = 12, marker_strategy = 'standard', + # sce = sce, + # allowed_genes = rownames(sce)) + # + # expect_false(is.null(markers_2$multimarkers)) + # }) context("Check for valid output formats in marker finding") @@ -134,6 +137,8 @@ context("Check for valid output formats in marker finding") test_that("get_markers and compute_fm returns valid output", { sce_path <- test_path("pbmc_small.rds") sce <- read_input_scrnaseq(sce_path, filter_counts = F) + + sce <- sce[,!sce$seurat_annotations %in% c("Platelet", "Undetermined")] # sce$cell_type <- sample(c("A", "B"), ncol(sce), replace=TRUE) @@ -143,9 +148,9 @@ test_that("get_markers and compute_fm returns valid output", { rownames(sce) ) - expect_is(fms, 'list') - expect_equal(length(fms), 1) - expect_equal(nrow(fms[[1]][[1]]), nrow(sce)) + # expect_is(fms, 'list') + expect_equal(length(fms), 7) + expect_equal(nrow(fms[[1]]), nrow(sce)) markers <- get_markers(fms, panel_size = 100, marker_strategy = 'standard', sce = sce, @@ -164,7 +169,7 @@ test_that("get_markers and compute_fm returns valid output", { allowed_genes = rownames(sce)) markers_geneBasis <- markers_geneBasis$marker - + expect_is(markers_geneBasis, 'list') expect_equal(names(markers_geneBasis), c("recommended_markers", "scratch_markers", "top_markers")) diff --git a/tests/testthat/test_server.R b/tests/testthat/test_server.R index 9ee972a..1ea0c2b 100644 --- a/tests/testthat/test_server.R +++ b/tests/testthat/test_server.R @@ -99,7 +99,7 @@ test_that("Server has basic functionality", { # Verify proper format of the findmarkers output and marker lists expect_equal("seurat_annotations", column()) - expect_equal(length(names(fms()[[1]])), 3) + expect_equal(length(names(fms())), 3) expect_equal(length(current_markers()), 3)