Teichlab / bbknn

Batch balanced KNN
MIT License
149 stars 25 forks source link

Export BBKNN results to R software #45

Closed edroaldo closed 3 years ago

edroaldo commented 3 years ago

Dear BBKNN team,

I am using BBKNN in R as indicated in this github page and I am wondering how I could, for instance, export BBKNN results to perform UMAP/clustering/trajectory analysis with some customized scripts in R.

This is not an issue with the software at all, but I could not find the "batch-corrected data" to export from the anndata object (I am aware that the algorithm does not change the data matrix), but then which data I could use as input, for instance, to run umap with the umap R package?

Thank you in advance!

ktpolanski commented 3 years ago

The output of BBKNN is the neighbour graph. If you use bbknn.matrix.bbknn(), you can catch it directly. If using the more popular Scanpy version, it's saved in .obsp of the object. In python, the neighbour graph is a sparse matrix. A cursory search reveals reticulate to be able to handle those in principle.