unable to find an inherited method for function ‘Subset’ for signature ‘"matrix", "logical"’

I am working on a module of a larger app which analyses FlowCytometry data. I am running into the above error when I try to render a table of the Mean some of the data. I have other tables that render fine. I have updated all the packages and have added flowCore:: in front of the Subset function. neither have helped. I have also changed my data into a data.frame before subsetting, and the error message remains, but the word "matrix" is replaced with "data frame". Lastly, this code functions fine if I run it outside the app.

Any Ideas on what is causing this? (This code can be ran with any fcs file as the upload)

library(shiny)
library(flowCore)
library(flowMeans)
library(flowViz)
library(flowStats)
library(grid)
library(plotrix)
library(ggplot2)
library(gridExtra)
library(rgl)
library(bslib)

qBriteServer<- function(id) {
moduleServer(
id,
function(input, output, session) {
filePathbeads <- reactive(as.character(input$beadFile$datapath))
options(warn=-1)

  temp1 <- reactive({
  Qbrite <- read.FCS(paste(filePathbeads()), alter.names=TRUE)
  
  #### Transforming LMD data ####
  my_transforms2 <- function(x) {
    tTrans <- truncateTransform("truncate at 1", a = 1)
    tf1<- transformList(from=colnames(x)[c(1:8)], tfun=tTrans)
    trunc.x <- transform(x, tf1)
    lTrans <- logTransform(transformationId="log10-transformation", logbase=10, r=1, d=1)
    tf2<- transformList(from=colnames(trunc.x)[c(1:8)], tfun=lTrans)
    logX <- transform(trunc.x, tf2)
    return(logX)
  }
  QbriteT <- exprs(my_transforms2(Qbrite))
  temp1 <- QbriteT
  })

  temp2 <- reactive({
    fm_QbriteT <- flowMeans(temp1(), c("FL2.A"), NumC=4)
  })

  #### Importing Bead spec CSV file ####
  output$Qbrite <- renderTable({
  
 # Qbrite_values <- reactive(as.numeric(read.csv(filePathbeadValue, header=FALSE)))
 
  
  QbriteT<-temp1()
  fm_QbriteT<-temp2()
  ##### only need geo mean QBRrite##

  # a<-Subset(QbriteT, fm_QbriteT@Label==1)@exprs[, 6]
  # one<-10^mean(a)
    one <- 10^(mean(Subset(QbriteT, fm_QbriteT@Label==1)@exprs[, 6]))
    two <- 10^(mean(Subset(QbriteT, fm_QbriteT@Label==2)@exprs[, 6]))
    three <- 10^(mean(Subset(QbriteT, fm_QbriteT@Label==3)@exprs[, 6]))
    four <- 10^(mean(Subset(QbriteT, fm_QbriteT@Label==4)@exprs[, 6]))
    QB_MFI <- sort(c(one, two, three, four))
     
  #test<-as.data.frame(one)
  #test
    QB<-data.frame(QB_MFI)
    QB
  })
}

)}

and the UI

qBriteUI<-function(id) {
ns<-NS(id)

sidebarLayout(
sidebarPanel(
fileInput(ns("beadFile"), label =ns("QBrite FCS File"), multiple = FALSE, accept = ".FCS", buttonLabel ="Browse"),
fileInput(ns("beadValue"), label =ns("PE Molecule per Bead"), multiple = FALSE, accept = ".CSV", buttonLabel ="Browse")
),

mainPanel(
  tableOutput(ns("Qbrite")),
  splitLayout(cellWidths =c("50%","50%"), plotOutput(ns("beadsHist")), 
              plotOutput(ns("beads"))    
  ))

)}

server<-function(input, output, session) {
v7 <- qBriteServer("QBrite Beads")
}
ui<-fluidPage(
theme= bslib::bs_theme(bootswatch="superhero"),
qBriteUI("QBrite Beads")
)
shinyApp(ui, server)
shinyApp(qBriteUI, qBriteServer)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.