batch_key of highly_variable_genes not working
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 779
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 27
Description
Hey!
I'm currently having an issue with the batch_key functionality of sc.pp.highly_variable_genes introduced in https://github.com/theislab/scanpy/pull/622 by @gokceneraslan.
If I try setting batch_key, I get a TypeError:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
----> 1 sc.pp.highly_variable_genes(adata, batch_key="sample", flavor='cell_ranger', n_top_genes=4000, inplace=False)
~/.conda/envs/sc-tutorial/lib/python3.7/site-packages/scanpy/preprocessing/_highly_variable_genes.py in highly_variable_genes(adata, min_disp, max_disp, min_mean, max_mean, n_top_genes, n_bins, flavor, subset, inplace, batch_key)
336 dtypes.append([('highly_variable_nbatches', int),
337 ('highly_variable_intersection', np.bool_)])
--> 338 return np.rec.fromarrays(arrays, dtype=dtypes)
~/.conda/envs/sc-tutorial/lib/python3.7/site-packages/numpy/core/records.py in fromarrays(arrayList, dtype, shape, formats, names, titles, aligned, byteorder)
606
607 if dtype is not None:
--> 608 descr = sb.dtype(dtype)
609 _names = descr.names
610 else:
TypeError: data type not understood
I have tried with multiple categorical columns and it worked with none of them.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in scanpy/preprocessing/_highly_variable_genes.py at the highly_variable_genes path handling batch_key and the np.rec.fromarrays call shown in the traceback. Reproduce the failure with a categorical batch_key and verify that the function completes without the TypeError and returns the expected highly-variable-gene results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- bioinformatics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100