drieslab / Giotto

Spatial omics analysis toolbox
https://drieslab.github.io/Giotto_website/
Other
258 stars 98 forks source link

one error when using DWLS spatial deconvolution to do Cell type enrichment in 10X visium spatial data #613

Closed xhNorthwestern closed 1 year ago

xhNorthwestern commented 1 year ago

Hi,

I used Giotto to analyze my 10X Visium spatial data, and I encountered an error when using DWLS spatial deconvolution to do Cell type enrichment. Following is the code and error:

dwls_signature_matrix <- makeSignMatrixDWLSfromMatrix(matrix = normalized_sc_matrix,

I pulled out normalized expression, got cell type vector and created sign_list according to your "giotto_current_protocols/cp_walkthrough.Rmd".

Could you give me some advice to solve this problem? Look forward to your response, and I would really appreciate your help.

Thanks a lot!

mattobny commented 1 year ago

Hello @xhNorthwestern,

Please note that the repository you reference contains R markdown files which are to be paired with the manuscript "Analyzing Spatial Transcriptomics Data Using Giotto" (Current Protocols). This manuscript was written for Giotto's master version; as such, there are arguments, classes, and functions within this file which have since been deprecated, and various lines must be adjusted to run that file seamlessly with Giotto Suite.

For instance, this issue details one such line. When utilizing Giotto Suite (v3.2+), normalized_sc_matrix is no longer an object of class data.frame, data.table, or Matrix, but rather, it is of class exprObj. This explains the error message, since R cannot coerce this S4 class to a vector. To access the matrix with the relevant data within this exprObj, simply add brackets to the end of its call. Executing this should run smoothly:

dwls_signature_matrix <- makeSignMatrixDWLSfromMatrix(matrix = normalized_sc_matrix[],
                                                      sign_gene = unlist(sign_list), 
                                                      cell_type_vector = cell_type_vector)

Please let me know if I can be of further assistance.

xhNorthwestern commented 1 year ago

Hi @mattobny,

Thanks for your suggestions, and it worked! I really appreciate your help.