Skip to content

Commit

Permalink
Compatible with R4.4.0
Browse files Browse the repository at this point in the history
2 modifications
t3: `filter(...)[,columns]` returns a data frame with 1 row (because we don't have drop = TRUE). So, sort() is applied to a data.frame. This used to work (with a warning), now errors. New version: explicitly convert t3 to a vector before sorting

tableDEX: input$topM2 is a string (because the UI is a `textInput()`). `head(mtcars, "2")` used to work as `head(mtcars, 2)`, not anymore. Now need to explicitly make numeric.
  • Loading branch information
AlexWeinreb committed Jun 4, 2024
1 parent 4b8455c commit f0344ae
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,14 @@ server <- function(input, output) {
}
withProgress(message = "Obtaining information...", value = 0, {
if (var %in% dplyr::filter(th, threshold == input$Tgene_cut)$gene_name) {
t3 <-
sort(
filter(
th,
gene_name == var,
threshold == input$Tgene_cut
)[, columns],
decreasing = TRUE
)
t3 <- th[th$gene_name == var & th$threshold == input$Tgene_cut,
columns]
t3 <- as.numeric(t3) |> setNames(colnames(t3))

t3 <- sort(t3, decreasing = TRUE)
t3 <- data.frame(CellType = names(t3), expression = as.numeric(t3))
t3 <- dplyr::filter(t3, expression > 0)

if (nrow(t3) > 0) {
t3[, 2] <-
as.numeric(formatC(t3[, 2], digits = 3, format = "f") %>% gsub(" ", "", .))
Expand Down Expand Up @@ -498,8 +495,8 @@ server <- function(input, output) {
if (nrow(tableDEX) > 0) {
output$MarkTable_Batch <- DT::renderDataTable({
DT::datatable(
tableDEX %>% head(input$topM2),
options = list(pageLength = input$topM2),
tableDEX %>% head( as.numeric(input$topM2) ),
options = list( pageLength = as.numeric(input$topM2) ),
style = 'jQueryUI',
class = 'cell-border stripe',
rownames = FALSE
Expand Down

0 comments on commit f0344ae

Please sign in to comment.