liana icon indicating copy to clipboard operation
liana copied to clipboard

getting error when running gsea

Open ChenyuZhang97 opened this issue 5 months ago • 0 comments

Hi, I am trying to run the code pasted below, and get this error:

LR_List <- liana::select_resource('CellChatDB')[[1]] %>%
            select(ligand = source_genesymbol,
                   receptor = target_genesymbol) %>%
            unite('interaction',
                  ligand,
                  receptor,
                  sep = '^') %>%
            pull(interaction)
          
          LR_Set <- c2c$external$generate_lr_geneset(lr_list = LR_List,
                                                     complex_sep = '_', # Separation symbol of the genes in the protein complex
                                                     lr_sep = '^', # Separation symbol between a ligand and a receptor complex
                                                     organism = 'mouse', #using mouse doesn't support pathwaydb="KEGG", you have to change it to pathwaydb="GOBP" or pathwaydb="Reactome"
                                                     pathwaydb = 'GOBP', #GOBP, KEGG,  Reactome
                                                     readable_name = TRUE)
         
          LR_Loadings <- factors[['interactions']] %>%
            column_to_rownames("lr")
          
          GSEA_Results <- c2c$external$run_gsea(loadings = LR_Loadings,
                                                lr_set = LR_Set,
                                                output_folder = 'D:\\LIANA\\Comparison\\Results',
                                                weight = as.integer(1),
                                                min_size = as.integer(5),
                                                permutations = as.integer(999),
                                                processes = as.integer(6),
                                                random_state = as.integer(6),
                                                significance_threshold = as.numeric(0.05))



  0%|          | 0/11 [00:00<?, ?it/s]2024-09-26 23:56:28,134 [WARNING] Duplicated values found in preranked stats: 0.17% of genes
The order of those genes will be arbitrary, which may produce unexpected results.
  0%|          | 0/11 [00:00<?, ?it/s]
Error in py_call_impl(callable, call_args$unnamed, call_args$named) : 
  Exception: Error parsing gmt parameter for gene sets

And by running this command reticulate::py_last_error(), I got:

Traceback (most recent call last):
  File "D:\Softwares\Anaconda\Lib\site-packages\cell2cell\external\gseapy.py", line 223, in run_gsea
    gseapy.prerank(rnk=test,
  File "D:\Softwares\Anaconda\Lib\site-packages\gseapy\__init__.py", line 357, in prerank
    pre.run()
  File "D:\Softwares\Anaconda\Lib\site-packages\gseapy\gsea.py", line 426, in run
    gmt = self.load_gmt(gene_list=dat2.index.values, gmt=self.gene_sets)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Softwares\Anaconda\Lib\site-packages\gseapy\base.py", line 206, in load_gmt
    genesets_dict = self.load_gmt_only(gmt)
                    ^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Softwares\Anaconda\Lib\site-packages\gseapy\base.py", line 195, in load_gmt_only
    raise Exception("Error parsing gmt parameter for gene sets")
Exception: Error parsing gmt parameter for gene sets

── R Traceback ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    ▆
 1. └─c2c$external$run_gsea(...)
 2.   └─reticulate:::py_call_impl(callable, call_args$unnamed, call_args$named)
 

I'm able to run the Liana x tensor-cell2cell R tutorials up to this point. Any suggestion for this? Thanks!

ChenyuZhang97 avatar Sep 26 '24 16:09 ChenyuZhang97