Elisseeff-Lab / domino

A software package for connecting cell level features in single cell RNA sequencing data with receptor ligand activity. Please be aware that an improved package, dominoSignal, is available.
https://fertiglab.github.io/dominoSignal/
GNU General Public License v3.0
15 stars 8 forks source link

Error in create_domino(): "features[, colnames(dom@z_scores)] : subscript out of bounds" #17

Closed bhavyaac closed 2 years ago

bhavyaac commented 2 years ago

Hello!

I got the following strange error message when trying to run the function create_domino() in an R script:

Error in features[, colnames(dom@z_scores)] : subscript out of bounds
Calls: <Anonymous>
In addition: Warning message:
In if (class(features) == "character") { :
  the condition has length > 1 and only the first element will be used

Do you have any idea what could be causing this error?

This is my code for your reference:

# Load Seurat object
ser <- loadRData(here(glue("data/original/{sample}_seurat.Rda")))

# Set cluster idents as the cell types
ser <- SetIdent(ser, value = "Cell_type_consensus")

# Store required values for creating Domino object
counts <- ser@assays$RNA@counts

z_scores <- ser@assays$RNA@scale.data

clusters <- ser@active.ident

auc <- t(read.table(
  here(glue("data/original/{sample}_SCENIC/output.default/auc_mtx.csv")), 
  header = TRUE, row.names = 1, 
  stringsAsFactors = FALSE, sep = ','))

# Create domino object using CellphoneDB database and SCENIC outputs of sample
pbmc_dom <- domino::create_domino(
  signaling_db = "/lustre06/project/6004736/modules/software/pyscenic-db/ligand-receptor-db-cpdb", 
  features = auc, counts = counts, z_scores = z_scores, clusters = clusters, 
  df = here(glue("data/original/{sample}_SCENIC/output.default/motifs.csv")))

Thank you for your help!

bhavyaac commented 2 years ago

Closing this issue since I no longer need help. The problem was that the pySCENIC results (stored in auc) only contained a subset of the cells present in the Seurat object. For reference, after removing all cells from z_scores, counts, and clusters that did not exist in the auc file and retrying create_domino(), I received another error which I was unable to resolve:

Error in dom@z_scores[rec, keep_id] : subscript out of bounds
bhavyaac commented 2 years ago

For any others with similar issues in the future, I am updating about the error from my previous comment:

Error in dom@z_scores[rec, keep_id] : subscript out of bounds

The issue in the end was that my Seurat object's scale.data slot contained only the top 2000 genes (as is the default for the ScaleData() function), and so dom@z_scores did not contain all of the genes that were in dom@counts. I resolved it by rerunning ScaleData() for all genes.

Since this likely to be a common issue, I think that the package would benefit from a warning to the user if this is detected.