MarcElosua / SPOTlight

Spatial Transcriptomics Capture Location Deconvolution
https://marcelosua.github.io/SPOTlight
GNU General Public License v3.0
164 stars 25 forks source link

Error in trainNMF(x = x, y = y, groups = groups, mgs = mgs, n_top = n_top, : ids %in% names(mgs) are not TRUE #83

Closed BenjaminDEMAILLE closed 1 year ago

BenjaminDEMAILLE commented 1 year ago

Hi I wanted to use SPLOTlight on spatial data but I'm facing some issue. can you help me ?

I run like this :

load("/Users/benjamin/Dropbox (U932)/Salmon team/Data_storage/Seq_data/scRNASeq/public_data/Lung/Grout_Leader_data_dn1000_SCT.RData")
genes <- !grepl(pattern = "^RP[L|S]|MT", x = rownames(Grout_Leader_data))
Grout_Leader_data <- subset(x = Grout_Leader_data, Cell_subtype %in% unique(mgs_df$cluster))
Grout_Leader_data <- subset(x = Grout_Leader_data, Cell_subtype %in% c("Mitocondrials", "Junk"), invert = T)

mgs <- scoreMarkers(as.SingleCellExperiment(Grout_Leader_data), 
                    groups = Grout_Leader_data$Cell_subtype, 
                    BPPARAM=MulticoreParam(parallel::detectCores()))

mgs_fil <- lapply(names(mgs), function(i) {
    x <- mgs[[i]]
    # Filter and keep relevant marker genes, those with AUC > 0.8
    x <- x[x$mean.AUC > 0.8, ]
    if (dim(x)[1]>0) {
      # Sort the genes from highest to lowest weight
      x <- x[order(x$mean.AUC, decreasing = TRUE), ]
      # Add gene and cluster id to the dataframe
      x$gene <- rownames(x)
      x$cluster <- i
      data.frame(x)
    }
})

mgs_df <- do.call(rbind, mgs_fil)

Grout_Leader_data <- subset(x = Grout_Leader_data, Cell_subtype %in% names(mgs))

Grout_Leader_data$Cell_subtype <- as.character(Grout_Leader_data$Cell_subtype)

Idents(Grout_Leader_data) <- as.character(Grout_Leader_data$Cell_subtype)

DefaultAssay(Grout_Leader_data) <- "RNA"
res <- SPOTlight(
    x = Grout_Leader_data,
    y = Plasticity_spatial.integrated,
    groups = as.character(Grout_Leader_data$Cell_subtype),
    mgs = mgs,
    weight_id = "median.AUC",
    group_id = "cluster",
    gene_id = "gene")

When I did :

names(mgs) %in% unique(Grout_Leader_data$Cell_subtype)

I got

 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[33] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE

How can I do ?

thanks for your help

Both are Seurat object

feasiblee commented 1 year ago

Hello, how did you solve it, thank you.

MarcElosua commented 10 months ago

Hi apologies for the late response here, would it be possible to get a more extended error message to help me debug this?