saezlab / liana

LIANA: a LIgand-receptor ANalysis frAmework
https://saezlab.github.io/liana/
GNU General Public License v3.0
169 stars 30 forks source link

Inherit levels of idents #99

Closed fbnrst closed 10 months ago

fbnrst commented 1 year ago

This is more a nice-to-have feature request, but I came across this now a couple of times. For me, it would be nice, if liana_wrap would inherit the levels of the cluster identities, because this would ensure consistent order of clusters in plotting. Using the tutorial example:

library(liana)
library(Seurat)
liana_path <- system.file(package = "liana")
testdata <-
  readRDS(file.path(liana_path , "testdata", "input", "testdata.rds"))

liana_test <- liana_wrap(testdata, method=c("sca"), )

Here, the clusters in the testdata Seurat object are a factor:

> levels(Idents(testdata))
'B''CD8 T''NK'

and it would be nice if those levels would be inherited to source and target in liana_test, I think. Currently, liana_test does not return factors for those:

> levels(liana_test$source)
NULL

Of course, one can just convert the source and target columns to factors manually as a workaround.

dbdimitrov commented 1 year ago

Hi @fbnrst,

Great point! I'll make sure to keep the levels in next update.

Daniel

dbdimitrov commented 10 months ago

LIANA now properly inherits these :)