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

liana_tensor_c2c error: negative dimensions are not allowed #165

Open
csennis opened this issue Jul 23, 2024 · 1 comment
Open

liana_tensor_c2c error: negative dimensions are not allowed #165

csennis opened this issue Jul 23, 2024 · 1 comment

Comments

@csennis
Copy link

csennis commented Jul 23, 2024

Hello,

Thank you for such a wonderful tool! I am trying to run tensor decomposition on my data to compare communication networks in treated vs. untreated samples, but I get the following error I can't seem to work around. I am following the liana_tensor_c2c vignette (https://saezlab.github.io/liana/articles/liana_cc2tensor.html) and am able to successfully run liana_bysample. I saw Issue #149 in which you suggest it could be due to negative values, but I don't see any in my data$logcounts or data$counts slot.

Please note that I have done most of my work in Seurat, and converted my object to a SingleCellExperiment object for this workflow. Within Seurat, I performed SCT (https://satijalab.org/seurat/articles/sctransform_vignette.html) instead of log normalization - I am wondering if this is causing the error?

Please find my code below - I created a conda environment called cell2cell_env in which I have pip installed tensor cell2cell.

Thank you in advance for your help/guidance here!

Code:
sce <- liana_tensor_c2c(sce = sce,
score_col = 'LRscore',
sender_col = "source", # Just added this
receiver_col = "target", # Just added this
ligand_col = "ligand", # Just added this
receptor_col = "receptor", # Just added this
rank = 'None', # set to None to estimate for you data!
how='outer', # defines how the tensor is built
conda_env = "cell2cell_env", # used to pass an existing conda env with cell2cell
use_available = TRUE # detect & load cell2cell if available
)

Error:
Error in py_call_impl(callable, call_args$unnamed, call_args$named) :
ValueError: negative dimensions are not allowed
Run reticulate::py_last_error() for details.
In addition: Warning message:
In liana_tensor_c2c(sce = pdo_sce, score_col = "LRscore", sender_col = "source", :
NAs introduced by coercion

R Traceback ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  1. └─liana::liana_tensor_c2c(...)
  2. └─tensor$compute_tensor_factorization(...)
  3. └─reticulate:::py_call_impl(callable, call_args$unnamed, call_args$named)
    
@dbdimitrov
Copy link
Collaborator

dbdimitrov commented Aug 6, 2024

Hi @csennis,

Thanks for using liana and apologies for the delayed response.

Hmmm, if I remember correctly about SCT transform as long as you use the counts rather than the residuals, it should be okay, since they are drawn from NB/Poisson and are hence non-negative. Maybe make sure that you pass the correct assay to liana so that you indeed use the non-negative counts.

You could also check the liana results, for some unexpected values, e.g. NaNs, as likely there is some issue there (some dimension form the tensor is probably being dropped because of invalid values).

Finally, I recommend following the updated version of tutorial, along with more in-depth tutorials: https://ccc-protocols.readthedocs.io/en/latest/notebooks/ccc_R/QuickStart_pbmc.html

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