nichenetr icon indicating copy to clipboard operation
nichenetr copied to clipboard

assign_ligands_to_celltype erroe message

Open wang2034 opened this issue 1 year ago • 2 comments

Hi, When I ran: igand_type_indication_df <- assign_ligands_to_celltype(seuratObj, nichenet_output$top_ligands, celltype_col = "cell_type2") I got a error:

Error in h(simpleError(msg, call)) : error in evaluating the argument 'j' in selecting a method for function '[': comparison of these types is not implemented In addition: Warning message: In seuratObj_subset[, seuratObj_subset[[celltype_col]] == celltype] : Incompatible methods ("Ops.data.frame", "Ops.factor") for "=="

My Seurat object was created using Seurat V5.

wang2034 avatar Sep 13 '24 20:09 wang2034

Hi,

I think this occurred because the cell type column is a factor. A workaround for now would be to create a new metadata column as a character, as follows:

seuratObj$celltype_char <- as.character(seuratObj$cell_type2)
ligand_type_indication_df <- assign_ligands_to_celltype(seuratObj,
    nichenet_output$top_ligands,
    celltype_col = "celltype_char")

I will implement a fix for this in the next patch.

csangara avatar Sep 20 '24 13:09 csangara

thx this helped!

Kiliankleemann avatar Mar 13 '25 10:03 Kiliankleemann