Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem: dec_cci and dec_cci_all #10

Closed
jinyuanchun opened this issue Sep 26, 2022 · 9 comments
Closed

problem: dec_cci and dec_cci_all #10

jinyuanchun opened this issue Sep 26, 2022 · 9 comments
Labels
bug Something isn't working

Comments

@jinyuanchun
Copy link

Hi, When I used dec_cci and dec_cci_all to analysis my data about cell-cell communications
and it pops errors
dec_cci error :

Error in intI(j, n = d[2L], dn[[2L]], give.dn = FALSE): invalid character indexing
Traceback:

1. dec_cci(object = obj, celltype_sender = "Vascular", celltype_receiver = "Differentiated_like", 
 .     use_n_cores = 4)
2. .lr_distance_doParallel(st_data, cell_pair, lrdb, celltype_sender, 
 .     celltype_receiver, per_num, pvalue)
3. st_data[lrdb$ligand, cell_pair$cell_sender]
4. st_data[lrdb$ligand, cell_pair$cell_sender]
5. callGeneric(x, i = i, j = j, drop = TRUE)
6. eval(call, parent.frame())
7. eval(call, parent.frame())
8. x[i = i, j = j, drop = TRUE]
9. x[i = i, j = j, drop = TRUE]
10. subCsp_ij(x, i, j, drop = drop)
11. intI(j, n = d[2L], dn[[2L]], give.dn = FALSE)
12. stop("invalid character indexing")

dec_cci_all error
Note: there are 6 cell types and 30 pair-wise cell pairs
Begin to find LR pairs
Error in {: task 1 failed - "invalid character indexing"
Traceback:

  1. dec_cci_all(object = obj, use_n_cores = 4)
  2. foreach::foreach(i = 1:nrow(celltype_pair), .packages = c("Matrix",
    . "reshape2"), .export = c(".get_cellpair", ".lr_distance",
    . ".get_tf_res", ".get_score")) %dopar% {
    . celltype_sender <- celltype_pair$celltype_sender[i]
    . celltype_receiver <- celltype_pair$celltype_receiver[i]
    . cell_pair <- .get_cellpair(celltype_dist, st_meta, celltype_sender,
    . celltype_receiver, n_neighbor)
    . cell_sender <- st_meta[st_meta$celltype == celltype_sender,
    . ]
    . cell_receiver <- st_meta[st_meta$celltype == celltype_receiver,
    . ]
    . cell_pair_all <- nrow(cell_sender) * nrow(cell_receiver)/2
    . if (nrow(cell_pair) > min_pairs) {
    . if (nrow(cell_pair) > cell_pair_all * min_pairs_ratio) {
    . lrdb <- object@lr_path$lrpairs
    . lrdb <- .lr_distance(st_data, cell_pair, lrdb, celltype_sender,
    . celltype_receiver, per_num, pvalue)
    . max_hop <- object@para$max_hop
    . receptor_tf <- NULL
    . if (nrow(lrdb) > 0) {
    . receptor_tf <- .get_tf_res(celltype_sender, celltype_receiver,
    . lrdb, ggi_tf, cell_pair, st_data, max_hop,
    . co_exp_ratio)
    . if (!is.null(receptor_tf)) {
    . lrdb <- .get_score(lrdb, receptor_tf)
    . }
    . else {
    . lrdb <- NULL
    . }
    . }
    . if (is.data.frame(lrdb)) {
    . if (nrow(lrdb) > 0) {
    . list(lrdb = lrdb, receptor_tf = receptor_tf,
    . cell_pair = cell_pair)
    . }
    . }
    . }
    . }
    . }
  3. e$fun(obj, substitute(ex), parent.frame(), e$data)
@multitalk
Copy link
Collaborator

You can set if_doParallel = FALSE. I will check it later.

@jinyuanchun
Copy link
Author

thank you for you reply. i try, but also have error.

image
image

@multitalk
Copy link
Collaborator

@jinyuanchun I have checked the code and I guess the reason might be that the nrow of obj@lr_path$lrpairs is equal to 1, which will lead to the error when calculating the .lr_distance(). I have fixed the bug considering the above condition. You can try it now. If the error still occurs, please feel free to contact me. Thanks again for your reply.

@multitalk
Copy link
Collaborator

@jinyuanchun Another reason is that the names of cells or spots contain "-". I have added a step to rename the cells or spots in st_data and sc_data over createSpaTalk() and dec_celltype by replacing "-" with "_" to avoid the error in dec_cci() and dec_cci_all(). Thanks again

@multitalk multitalk added the bug Something isn't working label Nov 20, 2022
@hahia
Copy link

hahia commented Feb 15, 2023

@jinyuanchun Another reason is that the names of cells or spots contain "-". I have added a step to rename the cells or spots in st_data and sc_data over createSpaTalk() and dec_celltype by replacing "-" with "_" to avoid the error in dec_cci() and dec_cci_all(). Thanks again

Hi, I also meet the problem
image

names of st_data and names of celltype:
image

obj@lr_path$lrpairs:
image

@multitalk
Copy link
Collaborator

@hahia I guess it might be the names of obj@meta$rawmeta$cell. You could paste a C to the cellname, e.g., C111300, C30834, and re-run the codes starting from createSpaTalk()

@hahia
Copy link

hahia commented Feb 17, 2023

@hahia I guess it might be the names of obj@meta$rawmeta$cell. You could paste a C to the cellname, e.g., C111300, C30834, and re-run the codes starting from createSpaTalk()

Ok! Problem solved.

@jinyuanchun
Copy link
Author

jinyuanchun commented Feb 17, 2023 via email

@liangbolyu
Copy link

Hi here is a question when I use the function dec_cci_all(). I'm doing a simulation to test the method, so I just have 2 cell types and two pathways. But I face the problem here:

0ecd6912bce00d1f14da4d78e4eb546

Could you please help me with it? Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants