tanlabcode / CytoTalk

A novel computational method for inferring cell-type-specific signaling networks using single-cell transcriptomics data for better characterization of cell-cell communication.
Other
34 stars 11 forks source link

Dimension issue while running "run_cytotalk" #8

Open mkyriak opened 2 years ago

mkyriak commented 2 years ago

Hello! I am trying to am trying to run CytoTalk to find out cell-cell interactions in my data that I obtained using cellphonedb. Hence, I have two matrices: one with the counts (format_counts.txt) and another with the metadata (forma_meta.txt) that maps the cell types to columns. The count matrix contains 5790 cells (columns) and 10570 genes (rows), along with the corresponding 5790 cells in the metadata file.

I am loading the data as follows and when I am trying to run run_cytotalk I get this error:

`fpath_mat <- "format_counts.txt" fpath_meta <- "format_meta.txt" lst_scrna <- CytoTalk::read_matrix_with_meta(fpath_mat, fpath_meta) table(lst_scrna$cell_types) type_a <- "Inh_1" type_b <- "Inh_1" results <- CytoTalk::run_cytotalk(lst_scrna, type_a, type_b)

CytoTalk_Error

` Could you please help me figure out what is going on?

CytoTalk_Error
dellebelle2500 commented 2 years ago

I also get the same error. According to cytotalk.R, line 104, vec_nst_a <- nonselftalk(mat_a, lrp) returns error message. Matrices must have same dimensions in e1 + diag2Tsmart(e2, e1, "d") In my case, mouse sample is used for analysis. Below is my command. ################## GPC1 <- subset(x = seuratObj, idents = "GPC1") GPC1_mat <- as.matrix(GPC1@assays$integrated@scale.data) common_genes <- intersect(CytoTalk::pcg_mouse, rownames(GPC1_mat)) GPC1_mat <- GPC1_mat[common_genes,] GPC1_mat <- na.omit(GPC1_mat) write.csv(GPC1_mat, file="~/single/cytotalk/scRNAseq_GPC1.csv")

GPC2 <- subset(x = seuratObj, idents = "GPC2") GPC2_mat <- as.matrix(GPC2@assays$integrated@scale.data) common_genes2 <- intersect(CytoTalk::pcg_mouse, rownames(GPC2_mat)) GPC2_mat <- GPC2_mat[common_genes2,] GPC2_mat <- na.omit(GPC2_mat) write.csv(GPC2_mat, file="~/single/cytotalk/scRNAseq_GPC2.csv")

lst_scrna <- CytoTalk::read_matrix_folder("~/single/cytotalk") table(lst_scrna$cell_types)

cell_type_a <- "GPC1" cell_type_b <- "GPC2"

results <- CytoTalk::run_cytotalk(lst_scrna, cell_type_a, cell_type_b, pcg = CytoTalk::pcg_mouse, lrp = CytoTalk::lrp_mouse) ################## I think index <- which(Matrix::rowSums(mat_type != 0) == 0) makes error in my case. Is it necessary to scale each data after subset?