digitalcytometry / cytotrace2

CytoTRACE 2 is an interpretable AI method for predicting cellular potency and absolute developmental potential from scRNA-seq data.
Other
85 stars 6 forks source link

Error in names(cytotrace) <- unlist(sample_names) : 'names' attribute [10770] must be the same length as the vector [11] #18

Closed galaxyeee closed 3 months ago

galaxyeee commented 4 months ago

Hi, Thank you for making this useful tool, but I have a problem using it, so I need to ask.

This is my code.

library(CytoTRACE2)

counts_matrix <- data.frame(seu@assays$RNA@counts)
cytotrace <- cytotrace2(counts_matrix)

An error occurs when running the "cytotrace2" function. Error in names(cytotrace) <- unlist(sample_names) : 'names' attribute [10770] must be the same length as the vector [11] I'd appreciate it if you could tell me the answer.

dim(counts_matrix) [1] 17827 53853

An object of class Seurat 17827 features across 53853 samples within 1 assay Active assay: RNA (17827 features, 2000 variable features) 2 dimensional reductions calculated: pca, umap

EUNHA

galaxyeee commented 4 months ago

The error mentioned above has been resolved by adding species = "human". However, I have one more question. If I want to obtain results using the corrected expression values after batch effect correction (ex. harmony, fastMNN), should I put @assays$RNA@scale.data or @assays$RNA@data in the counts_matrix?

savagyan00 commented 3 months ago

Hi and thank you for using CytoTRACE 2,

We're glad that your initial issue has been resolved. Regarding your second question, if you are working with a Seurat object, you can simply pass it to the function cytotrace2 and set is_seurat = TRUE , also specifying the slot name where the data to be used is located.

It's important to note that integration methods like Harmony and fastMNN do not alter expression data directly; instead, they adjust the lower-dimensional embeddings used for clustering and visualization. Therefore, these methods typically do not affect the slots storing expression data (@data or @counts).

If you're using a batch correction method that does modify expression values, you can store this integrated data in a slot that can be accessed with Seurat::GetAssayData(object = object, assay="RNA", slot=slot_type). Then, you can pass the name of this slot to the cytotrace2 function with the slot_type argument.Alternatively, if the integrated data is stored outside of these standard slots, you can extract it from the Seurat object and pass it directly to the function as a data.frame.

We hope this clarifies your query. Please feel free to reach out if you have further questions!