STdeconvolve icon indicating copy to clipboard operation
STdeconvolve copied to clipboard

Error when using annotateCellTypesGSEA

Open d-henness opened this issue 1 year ago • 3 comments

I'm trying to annotate cell types of visium 10x data using the annotateCellTypesGSEA function. This is a minimal script to reproduce the error

library(STdeconvolve)
library(SpatialExperiment)



se <- SpatialExperiment::read10xVisium(samples = "./116_run",
           type = "sparse",
           data = "filtered")
se

# this is the genes x barcode sparse count matrix
cd <- se@assays@data@listData$counts
pos <- SpatialExperiment::spatialCoords(se)

# change column names to x and y
# for this dataset, we will visualize barcodes using "pxl_col_in_fullres" = "y" coordinates, and "pxl_row_in_fullres" = "x" coordinates
colnames(pos) <- c("y", "x")

counts <- cleanCounts(cd, min.lib.size = 100, min.reads = 10)
corpus <- restrictCorpus(counts, removeAbove=1.0, removeBelow = 0.05, nTopOD = 1000)

#ldas <- fitLDA(t(as.matrix(corpus)), Ks = seq(2, 15, by = 1),
ldas <- fitLDA(t(as.matrix(corpus)), Ks = 10,
               perc.rare.thresh = 0.05,
               plot=TRUE,
               verbose=TRUE)

optLDA <- optimalModel(models = ldas, opt = "min")

results <- getBetaTheta(optLDA, perc.filt = 0.05, betaScale = 1000)
deconProp <- results$theta
deconGexp <- results$beta



gset <- list(
  test_type1 = c("FLG", "FLG2"),
  test_type2 = c("KTR25", "KTR71")
)

celltype_annotations <- annotateCellTypesGSEA(beta = results$beta, gset = gset, qval = 0.05)

The error itself is

initial: [1e+02 - Error in stats::ecdf(as.numeric(rvl$p/s.pm)) :
  'x' must have 1 or more non-missing values
Calls: annotateCellTypesGSEA -> <Anonymous> -> bulk.gsea -> <Anonymous>
Execution halted

I can provide the dataset by email if needed

d-henness avatar Feb 27 '24 22:02 d-henness

I am running STdeconvolve 1.3.1 and I get the same error when trying to run annotateCellTypesGSEA. The example commands with the test data in the Annotating Deconvolved Cell Types tutorial work for me, and other STdeconvolve functions work with my dataset.

ChristineHOconnor avatar Apr 30 '24 15:04 ChristineHOconnor

@ChristineHOconnor and @d-henness ...did you guys fix this issue?

Umaarasu avatar May 26 '24 17:05 Umaarasu

Hi @d-henness,

So sorry for the delayed response. My guess is that the number of genes in each of your example test cell types is too small or not well represented in your dataset. I would be happy to take a closer look if you are able to provide your dataset and cell type markers that are causing this error. I admit though that I am in a new position and my time is limited so my response will likely take some time.

Hope this helps and sorry again, Brendan

bmill3r avatar Jun 07 '24 20:06 bmill3r