Repository navigation
Cell hashing - #797
Cell hashing#797njbernstein wants to merge 5 commits into
Conversation
|
@flying-sheep Let me know next steps |
|
The test is failing because |
| adata | ||
| The annotated data matrix of shape ``n_obs`` × ``n_vars``. Rows correspond | ||
| to cells and columns to genes. | ||
| percentile_candidates |
There was a problem hiding this comment.
Can you add if the adata object needs any particular formatting or pre-processing steps? Maybe here or in the description. For example for 10x, just processing the sample with cell ranger is enough or other steps are required?
| which cell hashing barcodes a cell has | ||
| """ | ||
| barcodes_hits = [] | ||
| number_of_barcodes = adata.X.shape[1] |
There was a problem hiding this comment.
I am not sure about the logic here. Normally, the columns contain genes, I assume that in cell-hashing there will be barcodes, but could the data be mixed ? Maybe if you clarify what is needed/expected in the description of the function would make the code easy to read.
There was a problem hiding this comment.
I think these are the columns here represent hashing barcodes, not genes. @njbernstein I think both RNA UMIs and hashing barcode counts should be stored in the same AnnData object. Hashing barcodes can be stored in adata.obs or adata.obsm but definitely not in adata.X.
I think it makes more sense to first discuss 1) how to store hashing barcodes and 2) how to demultiplex them either in the PR or in the #351 issue.
| The annotated data matrix of shape ``n_obs`` × ``n_vars``. Rows correspond | ||
| to cells and columns to genes. | ||
| percentile_candidates | ||
| Choose exact percentiles to evaluate thresholding at |
There was a problem hiding this comment.
This percentiles refer to what exactly? Can you elaborate a bit?
|
@fidelram lemme know if the new comments make things more clear |
|
@ivirshup @flying-sheep I would like to merge this code but I have some questions:
|
@flying-sheep and I have put some effort into reducing import times for scanpy (they were getting up to a few seconds). This can most effectively be done by deferring the import of slow-to-import packages until they're actually needed. Phil added a test which blacklists top level import of some of particularly egregious packages (scipy and seaboarn for example). Here, the imports for
I think I would be fine with this going in preprocessing, since it isn't tied to another tool/ code base. I'm also not too familiar with the current state of demultiplexing techniques so I'd be fine to defer to you on this. Could you elaborate on why you think it should go in external? |
|
@ivirshup : Thanks for the background explanation. @njbernstein Can you move the import statements inside the I think the tool should go to |
|
Hmm, I’m pretty happy with my self-documented test code: def test_deferred_imports(imported_modules):
slow_to_import = {
'umap', # neighbors, tl.umap
'seaborn', # plotting
'sklearn.metrics', # neighbors
'scipy.stats', # tools._embedding_density
'networkx', # diffmap, paga, plotting._utils
# TODO: 'matplotlib.pyplot',
# TODO (maybe): 'numba',
}
falsely_imported = slow_to_import & imported_modules
> assert not falsely_imported
E AssertionError: assert not {'scipy.stats'}Do you think this could be clearer? |
|
@flying-sheep I think the output is clear once you know what is about. Since this error may happen to future contributions that are not aware of the efforts to reduce import times, I think is better to be explicit. Something like: "Slow import detected (scipy.stats). Please check that slow-to-import packages are not in top level calls but inside the functions that require them". |
Here is a stab at adding cell hashing demultiplexing to scanpy. This will address #351.