scverse / scanpy

Single-cell analysis in Python. Scales to >1M cells.
https://scanpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.89k stars 594 forks source link

bbknn integrates multiple variables #2004

Open woshiyangsi opened 3 years ago

woshiyangsi commented 3 years ago

Dear author,

Can bbknn integrate multiple variables?such as Platform and Individual.

Looking forward your reply Siyu

sc.external.pp.bbknn(mydata, batch_key=["Platform","Individual_2"],n_pcs=50,set_op_mix_ratio=ratio)

computing batch balanced neighbors Traceback (most recent call last): File "", line 1, in File "/home/scCell2/miniconda3/lib/python3.8/site-packages/scanpy/external/pp/_bbknn.py", line 134, in bbknn return bbknn( File "/home/scCell2/miniconda3/lib/python3.8/site-packages/bbknn/init.py", line 110, in bbknn if batch_key not in adata.obs: File "/home/scCell2/miniconda3/lib/python3.8/site-packages/pandas/core/generic.py", line 1721, in contains return key in self._info_axis File "/home/scCell2/miniconda3/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 4071, in contains hash(key) TypeError: unhashable type: 'list

f6v commented 3 years ago

Not an author, but I don't think that's supported. You can look at the bnknn docs. I'm also interested in defining a complex batch structure. How would you imagine these two keys to interact with each other in the context of the bknn?