SydneyBioX / spicyR

https://sydneybiox.github.io/spicyR/
8 stars 4 forks source link

Error creating SegmentedCells from tibble #1

Closed celsomilne closed 1 year ago

celsomilne commented 4 years ago

When trying to create a SegmentedCells object from a table (i.e. output from a dplyr operation), an error is raised:

> library(spicyR)
> set.seed(51773)
> x <- round(c(runif(200),runif(200)+1,runif(200)+2,runif(200)+3,
>            runif(200)+3,runif(200)+2,runif(200)+1,runif(200)),4)
> y <- round(c(runif(200),runif(200)+1,runif(200)+2,runif(200)+3,
>              runif(200),runif(200)+1,runif(200)+2,runif(200)+3),4)
>
> cellType <- factor(paste('c',rep(rep(c(1:2),rep(200,2)),4),sep = ''))
> imageID <- rep(c('s1', 's2'),c(800,800))
>
> cells <- data.frame(x, y, cellType, imageID)
> cells <- tibble::as_tibble(cells)
>
> cellExpr <- SegmentedCells(cells, cellTypeString = "cellType")

Error in if (xi > xj) 1L else -1L : missing value where TRUE/FALSE needed
In addition: Warning message:
In Ops.factor(xi, xj) : ‘>’ not meaningful for factors

Should tibbles be coerced to a data.frame before when they are passed to SegmentedCells?

ellispatrick commented 4 years ago

hmmm... looks like it. I'll have a look and see if I can figure out if I can make it accept both, or I might just convert tibbles at the data cleaning step.