SingleR-inc / SingleR

Clone of the Bioconductor repository for the SingleR package.
https://bioconductor.org/packages/devel/bioc/html/SingleR.html
GNU General Public License v3.0
165 stars 19 forks source link

Error in is.null(rownames(x)) && nrow(x) : invalid 'y' type in 'x && y' #223

Closed msteph11 closed 1 year ago

msteph11 commented 2 years ago

Hello,

When running the following code:

pred <- SingleR(test = target_dataset, 
                ref = ref_dataset, 
                labels = ref_dataset$sample_id, 
                assay.type.test=1)

I get the error: Error in is.null(rownames(x)) && nrow(x) : invalid 'y' type in 'x && y'

I was wondering if you could provide some guidance as to why this is occurring. I think the problem might be with target_dataset, because when I run the code using the ImmGen reference dataset instead of my own one it gives the same error. Here's the code I use to create my target dataset:

target_matrix <- read.delim(target_matrix_path)
test_target_matrix <- as.matrix(target_matrix[,2])
row.names(test_target_matrix) <- target_matrix$X
colnames(test_target_matrix) <- c("mb_crl")

target_dataset <- SummarizedExperiment(list(counts=test_target_matrix),
                                       colData=DataFrame(label=colnames(test_target_matrix)),
                                       rowData=DataFrame(length=row.names(test_target_matrix)))

And this is what the object looks like:

Screen Shot 2022-05-24 at 11 08 09 AM

Also, for reference, here is what the ref_dataset looks like:

Screen Shot 2022-05-24 at 12 09 14 PM
LTLA commented 2 years ago

I have no idea; never seen this error before. I'm guessing that nrow() on your test dataset is returning NULL, leading to the observed error message. If you can create a minimum reproducible example, I can have a look at it. You could also debug(SingleR:::.to_clean_matrix) and step through the function to see what the value of x is.

Jasemineonly commented 8 months ago

maybe your ref_dataset have some problem.I also encounted this error ,I find my ref is like this image but it should be a SummarizedExperiment, so I redownload the dataset and load it.

celldex::HumanPrimaryCellAtlasData hpca.se <- HumanPrimaryCellAtlasData()

then my code run successfully.