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

Error in auto_copy(): Set copy = TRUE if y can be copied to the same source as x (may be slow). #12

Closed
catsargent opened this issue Jul 13, 2023 · 1 comment

Comments

@catsargent
Copy link

Hi,

when running MNN in step-by-step mode, I get the following error when calling get_DE_info:

Error in `auto_copy()`:
! `x` and `y` must share the same src.
ℹ `x` is a <tbl_df/tbl/data.frame> object.
ℹ `y` is `NULL`.
ℹ Set `copy = TRUE` if `y` can be copied to the same source as `x` (may be slow).
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/rlang_error>
Error in `auto_copy()`:
! `x` and `y` must share the same src.
ℹ `x` is a <tbl_df/tbl/data.frame> object.
ℹ `y` is `NULL`.
ℹ Set `copy = TRUE` if `y` can be copied to the same source as `x` (may be slow).
---
Backtrace:
    ▆
 1. ├─multinichenetr::get_DE_info(...)
 2. │ └─... %>% ...
 3. ├─dplyr::select(., gene, cluster_id, logFC, p_val, p_adj, contrast)
 4. ├─dplyr::inner_join(., contrast_tbl, by = "group")
 5. └─dplyr:::inner_join.data.frame(., contrast_tbl, by = "group")
 6.   └─dplyr::auto_copy(x, y, copy = copy)
Run rlang::last_trace(drop = FALSE) to see 1 hidden frame.
> rlang::last_trace(drop = FALSE)
<error/rlang_error>

It appears to be the last part of the following which is causing the issue:

celltype_de_findmarkers = celltypes %>% lapply(function(celltype_oi, sce){
      genes_expressed = rownames(sce) ## change later if necessary for having a more decent filtering
      sce_oi = sce[intersect(rownames(sce), genes_expressed), SummarizedExperiment::colData(sce)[,celltype_id] == celltype_oi]
      DE_tables_list = scran::findMarkers(sce_oi, test.type="t", groups = SummarizedExperiment::colData(sce_oi)[,group_id])
      conditions = names(DE_tables_list)
      DE_tables_df = conditions %>% lapply(function(condition_oi, DE_tables_list){
        DE_table_oi = DE_tables_list[[condition_oi]]
        DE_table_oi = DE_table_oi %>% data.frame() %>% tibble::rownames_to_column("gene") %>% tibble::as_tibble() %>% dplyr::mutate(cluster_id = celltype_oi, group = condition_oi) %>% dplyr::select(gene, p.value, FDR, summary.logFC, cluster_id, group)  
      }, DE_tables_list) %>% dplyr::bind_rows()
    }, **sce) %>% dplyr::bind_rows() %>% dplyr::rename(logFC = summary.logFC, p_val = p.value, p_adj = FDR) %>% dplyr::inner_join(contrast_tbl, by = "group") %>% dplyr::select(gene, cluster_id, logFC, p_val, p_adj, contrast**)

This is what contrast_tbl looks like (I believe it is set-up fine):

# A tibble: 3 × 2
  contrast                                                   group               
  <chr>                                                      <chr>               
1 Parotid.Gland-(Minor.Salivary.Gland+Submandibular.Gland)/2 Parotid.Gland       
2 Minor.Salivary.Gland-(Parotid.Gland+Submandibular.Gland)/2 Minor.Salivary.Gland
3 Submandibular.Gland-(Minor.Salivary.Gland+Parotid.Gland)/2 Submandibular.Gland 

Have you any ideas what the problem might be?

Thanks,
Catherine

@browaeysrobin
Copy link
Member

browaeysrobin commented Jul 14, 2023

Hi @catsargent

Can you confirm whether you get this error if you use the default parameters get_DE_info(findMarkers = FALSE) since the code snippet you showed is only executed when using get_DE_info(findMarkers = TRUE)?

Note that using get_DE_info(findMarkers = TRUE) is not recommended, except maybe only if you would have 2/3 samples per group. (this option was added for us for internal testing, not to be used by the end users)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants