Repository navigation
Let Scanpy read from Cell Ranger 3.0 outputs - #1
Conversation
pmarks
left a comment
There was a problem hiding this comment.
Awesome! This looks great, thanks Qiang. Once Nigel has a quick look, let's send this on to scanpy.
|
Great PR @qianggong11 Good job! Keep it rolling in |
evolvedmicrobe
left a comment
There was a problem hiding this comment.
Yay! Looks great overall, nice job!
I made a few comments to address throughout. Another request I would make is that you add tests for this functionality. This repo uses a CI testing framework, and by adding tests you make the code a lot easier to review, as people can see exactly how the new function works, and also let's people verify that the testing you've clearly already done, are good tests. Perhaps most importantly, you also guard against future changes people make, as there are a lot of ways to break stuff in python by having name conflicts or just small changes that have unintended consequences. Finally, at some point later, a refactoring may be called for, and this is a lot easier todo if there are some basic tests around.
You don't have to move all the testing you did over, but some small ones would be good. I made some small test files for equivalent Seurat pull that you can grab here if it helps:
| Filename. | ||
| genome : :class:`str`, optional (default: ``'mm10'``) | ||
| Genome group in hdf5 file. | ||
| gex_only : :class:`bool`, optional (default: ``True``) |
There was a problem hiding this comment.
I am not deeply familiar with the documentation system, but noticed other doc strings in the file are formatted like so:
make_unique : `bool`, optional (default: `True`)
Where :class: doesn't seemed to be used for primitive types like int or str, the default value True only has one set of strings around it. Just verifying, have you checked if the documentation this produces looks okay?
There was a problem hiding this comment.
Changing to one set of strings. As there the authors use :class: to elsewhere, I'm keeping it there as we do not intend to change the style.
There was a problem hiding this comment.
Where do you see them use :class:? I count 123 instances in this repo where the primitive type bool is not decorated with :class:, 0 where it is.
grep -rnw \`bool\` .
./scanpy/tools/dpt.py:67: allow_kendall_tau_shift : `bool`, optional (default: `True`)
./scanpy/tools/dpt.py:71: copy : `bool`, optional (default: `False`)
./scanpy/tools/sim.py:44: params_file : `bool`, (default: `True`)
./scanpy/tools/sim.py:48: branching : `bool`, optional (default: `None`)
./scanpy/tools/phate.py:83: verbose : `bool`, `int` or `None`, optional (default: `sc.settings.verbosity`)
./scanpy/tools/phate.py:86: copy : `bool` (default: `False`)
./scanpy/tools/paga.py:44: use_rna_velocity : `bool` (default: `False`)
./scanpy/tools/paga.py:51: copy : `bool`, optional (default: `False`)
./scanpy/tools/rank_genes_groups.py:35: use_raw : `bool`, optional (default: `True`)
./scanpy/tools/rank_genes_groups.py:53: rankby_abs : `bool`, optional (default: `False`)
./scanpy/tools/louvain.py:51: use_weights : `bool`, optional (default: `False`)
./scanpy/tools/louvain.py:59: copy : `bool` (default: `False`)
./scanpy/tools/umap.py:84: copy : `bool` (default: `False`)
./scanpy/tools/draw_graph.py:56: proceed : `bool`, optional (default: `None`)
./scanpy/tools/draw_graph.py:60: copy : `bool` (default: `False`)
./scanpy/tools/score_genes.py:47: copy : `bool`, optional (default: `False`)
./scanpy/tools/score_genes.py:49: use_raw : `bool`, optional (default: `False`)
./scanpy/tools/score_genes.py:147: copy : `bool`, optional (default: `False`)
./scanpy/tools/diffmap.py:25: copy : `bool` (default: `False`)
./scanpy/tools/tsne.py:58: use_fast_tsne : `bool`, optional (default: `True`)
./scanpy/tools/tsne.py:62: copy : `bool` (default: `False`)
./scanpy/readwrite.py:53: cache : `bool`, optional (default: `False`)
./scanpy/readwrite.py:62: first_column_names : `bool`, optional (default: `False`)
./scanpy/readwrite.py:150: make_unique : `bool`, optional (default: `True`)
./scanpy/readwrite.py:153: cache : `bool`, optional (default: `False`)
./scanpy/plotting/tools/__init__.py:34: use_raw : `bool`, optional (default: `True`)
./scanpy/plotting/tools/__init__.py:39: save : `bool` or `str`, optional (default: `None`)
./scanpy/plotting/tools/__init__.py:66: save : `bool` or `str`, optional (default: `None`)
./scanpy/plotting/tools/__init__.py:84: save : `bool` or `str`, optional (default: `None`)
./scanpy/plotting/tools/__init__.py:171: sharey: `bool`, optional (default: True)
./scanpy/plotting/tools/__init__.py:468: use_raw : `bool`, optional (default: `None`)
./scanpy/plotting/tools/__init__.py:471: split : `bool`, optional (default: `True`)
./scanpy/plotting/tools/__init__.py:475: strip : `bool`, optional (default: `True`)
./scanpy/plotting/tools/__init__.py:477: jitter : `int`, `float`, `bool`, optional (default: `True`)
./scanpy/plotting/tools/__init__.py:552: save : `bool` or `str`, optional (default: `None`)
./scanpy/plotting/tools/paga.py:215: single_component : `bool`, optional (default: `False`)
./scanpy/plotting/tools/paga.py:240: export_to_gexf : `bool`, optional (default: `None`)
./scanpy/plotting/tools/paga.py:243: normalize_to_color : `bool`, optional (default: `False`)
./scanpy/plotting/tools/paga.py:254: add_pos : `bool`, optional (default: `True`)
./scanpy/plotting/tools/paga.py:258: frameon : `bool`, optional (default: `None`)
./scanpy/plotting/tools/paga.py:260: show : `bool`, optional (default: `None`)
./scanpy/plotting/tools/paga.py:262: save : `bool` or `str`, optional (default: `None`)
./scanpy/plotting/tools/paga.py:812: use_raw : `bool`, optional (default: `True`)
./scanpy/plotting/tools/paga.py:830: as_heatmap : `bool`, optional (default: `True`)
./scanpy/plotting/tools/paga.py:833: show_node_names : `bool`, optional (default: `True`)
./scanpy/plotting/tools/paga.py:835: show_colorbar : `bool`, optional (default: `True`)
./scanpy/plotting/tools/paga.py:837: show_yticks : `bool`, optional (default: `True`)
./scanpy/plotting/tools/paga.py:839: normalize_to_zero_one : `bool`, optional (default: `True`)
./scanpy/plotting/tools/paga.py:841: return_data : `bool`, optional (default: `False`)
./scanpy/plotting/tools/paga.py:843: show : `bool`, optional (default: `None`)
./scanpy/plotting/tools/paga.py:845: save : `bool` or `str`, optional (default: `None`)
./scanpy/plotting/anndata.py:71: use_raw : `bool`, optional (default: `None`)
./scanpy/plotting/anndata.py:578: log : `bool`, optional (default: `False`)
./scanpy/plotting/anndata.py:580: use_raw : `bool`, optional (default: `None`)
./scanpy/plotting/anndata.py:582: multi_panel : `bool`, optional (default: `False`)
./scanpy/plotting/anndata.py:584: stripplot : `bool` optional (default: `True`)
./scanpy/plotting/anndata.py:587: jitter : `float` or `bool`, optional (default: `True`)
./scanpy/plotting/anndata.py:706: use_raw : `bool`, optional (default: `None`)
./scanpy/plotting/anndata.py:779: log : `bool`, optional (default: `False`)
./scanpy/plotting/anndata.py:781: use_raw : `bool`, optional (default: `None`)
./scanpy/plotting/anndata.py:787: stripplot : `bool` optional (default: `True`)
./scanpy/plotting/anndata.py:790: jitter : `float` or `bool`, optional (default: `True`)
./scanpy/plotting/anndata.py:815: swap_axes: `bool`, optional (default: `False`)
./scanpy/plotting/anndata.py:993: log : `bool`, optional (default: `False`)
./scanpy/plotting/anndata.py:995: use_raw : `bool`, optional (default: `None`)
./scanpy/plotting/anndata.py:1141: log : `bool`, optional (default: `False`)
./scanpy/plotting/anndata.py:1143: use_raw : `bool`, optional (default: `None`)
./scanpy/plotting/anndata.py:1349: log : `bool`, optional (default: `False`)
./scanpy/plotting/anndata.py:1351: use_raw : `bool`, optional (default: `None`)
./scanpy/plotting/anndata.py:1460: log : `bool`, optional (default: `False`)
./scanpy/plotting/anndata.py:1462: use_raw : `bool`, optional (default: `None`)
./scanpy/plotting/docs.py:11:use_raw : `bool`, optional (default: `None`)
./scanpy/plotting/docs.py:18:edges : `bool`, optional (default: `False`)
./scanpy/plotting/docs.py:24:arrows : `bool`, optional (default: `False`)
./scanpy/plotting/docs.py:30:sort_order : `bool`, optional (default: `True`)
./scanpy/plotting/docs.py:53:frameon : `bool`, optional (default: `True`)
./scanpy/plotting/docs.py:71:show : `bool`, optional (default: `None`)
./scanpy/plotting/docs.py:73:save : `bool` or `str`, optional (default: `None`)
./scanpy/plotting/preprocessing.py:20: log : `bool`
./scanpy/plotting/preprocessing.py:24: save : `bool` or `str`, optional (default: `None`)
./scanpy/settings.py:91: scanpy : `bool`, optional (default: `True`)
./scanpy/settings.py:98: frameon : `bool`, optional (default: `True`)
./scanpy/settings.py:100: vector_friendly : `bool`, optional (default: `True`)
./scanpy/settings.py:106: transparent : `bool`, optional (default: `True`)
./scanpy/preprocessing/magic.py:64: verbose : `bool`, `int` or `None`, optional (default: `sc.settings.verbosity`)
./scanpy/preprocessing/magic.py:67: copy : `bool` or `None`, optional. Default: `None`.
./scanpy/preprocessing/dca.py:49: normalize_per_cell : `bool`, optional. Default: `True`.
./scanpy/preprocessing/dca.py:55: scale : `bool`, optional. Default: `True`.
./scanpy/preprocessing/dca.py:59: log1p : `bool`, optional. Default: `True`.
./scanpy/preprocessing/dca.py:67: batchnorm : `bool`, optional. Default: `True`.
./scanpy/preprocessing/dca.py:89: verbose : `bool`, optional. Default: `False`.
./scanpy/preprocessing/dca.py:93: return_model : `bool`, optional. Default: `False`.
./scanpy/preprocessing/dca.py:95: return_info : `bool`, optional. Default: `False`.
./scanpy/preprocessing/dca.py:100: copy : `bool`, optional. Default: `False`.
./scanpy/preprocessing/recipes.py:90: log : `bool`, optional (default: `True`)
./scanpy/preprocessing/recipes.py:92: plot : `bool`, optional (default: `True`)
./scanpy/preprocessing/recipes.py:94: copy : `bool`, optional (default: `False`)
./scanpy/preprocessing/mnn_correct.py:50: cos_norm_in : `bool`, optional (default: True)
./scanpy/preprocessing/mnn_correct.py:53: cos_norm_out : `bool`, optional (default: True)
./scanpy/preprocessing/mnn_correct.py:59: var_adj : `bool`, optional (default: True)
./scanpy/preprocessing/mnn_correct.py:62: compute_angle : `bool`, optional (default: False)
./scanpy/preprocessing/mnn_correct.py:73: do_concatenate : `bool`, optional (default: True)
./scanpy/preprocessing/mnn_correct.py:75: save_raw : `bool`, optional (default: False)
./scanpy/preprocessing/simple.py:70: copy : `bool`, optional (default: `False`)
./scanpy/preprocessing/simple.py:179: copy : `bool`, optional (default: `False`)
./scanpy/preprocessing/simple.py:287: log : `bool`, optional (default: `True`)
./scanpy/preprocessing/simple.py:289: subset : `bool`, optional (default: `True`)
./scanpy/preprocessing/simple.py:292: copy : `bool`, optional (default: `False`)
./scanpy/preprocessing/simple.py:452: copy : `bool`, optional (default: `False`)
./scanpy/preprocessing/simple.py:493: copy : `bool`, optional (default: `False`)
./scanpy/preprocessing/simple.py:531: zero_center : `bool` or `None`, optional (default: `True`)
./scanpy/preprocessing/simple.py:542: return_info : `bool`, optional (default: `False`)
./scanpy/preprocessing/simple.py:545: use_highly_variable : `bool`, optional (default: `None`)
./scanpy/preprocessing/simple.py:549: copy : `bool`, optional (default: `False`)
./scanpy/preprocessing/simple.py:552: chunked : `bool`, optional (default: `False`)
./scanpy/preprocessing/simple.py:695: copy : `bool`, optional (default: `False`)
./scanpy/preprocessing/simple.py:833: copy : `bool`, optional (default: `False`)
./scanpy/preprocessing/simple.py:951: zero_center : `bool`, optional (default: `True`)
./scanpy/preprocessing/simple.py:956: copy : `bool`, optional (default: `False`)
./scanpy/preprocessing/simple.py:1007: copy : `bool`, optional (default: `False`)
./scanpy/preprocessing/simple.py:1054: copy : `bool`, optional (default: `False`)
./scanpy/neighbors/__init__.py:738: density_normalize : `bool`
./scanpy/neighbors/__init__.py:778: sym : `bool`
There was a problem hiding this comment.
You are right. It seems this function (read_10x_h5) is the only place of such use. Although it was from the authors, I will correct it. Thank you.
There was a problem hiding this comment.
Ah, I see how we both had the impressions we did now! Thanks for clarifying.
- Move four functions (read_v3_* and read_legacy_*) as internal - Use os.path.join for potential Windows users.
- Some stylish editing.
|
Thank @evolvedmicrobe's comments which are all very helpful. Testing datasets (v2 and v3 matrix and HDF5 files) and the testing code ( |
|
Excellent! This is really cool! LGTM and good to merge. One final comment, at some 10X repositories we have the "squash and merge" option enabled on GitHub, which combines a series of commits in one pull request into a single commit to be merged into the repo. Prior to this feature, to keep commit logs simple and make things look cleaner, it was common for people to I looked at one PR for this repo here, scverse#289, and it appears they merge without squashing so you'll have this entire commit history as part of the repo going forward. If you felt like it, it might make for a cleaner commit to squash it first, but this isn't at all necessary as the code will work just as well either way. |
|
👍 Good point. Will do. |
|
Great work Qiang! Let's send this on to the scanpy folks!
…On Fri, Oct 26, 2018 at 7:14 PM Qiang Gong ***@***.***> wrote:
👍 Good point. Will do.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#1 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AACzAwBmOyzN0spTwdxVt897umAdSNLwks5uo8GOgaJpZM4XvXL8>
.
|
|
FYI, this PR has been merged to |
|
Great work Qiang!
…On Mon, Oct 29, 2018 at 2:21 PM Qiang Gong ***@***.***> wrote:
FYI, this PR has been merged to theislab/scanpy:master
<https://github.com/theislab/scanpy>. Thanks.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#1 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AACzA7yQkCE4GalZDR12vXcXDBgykuK3ks5up3FKgaJpZM4XvXL8>
.
|
update to match upstream
Updated
read_10x_h5:read_10x_h5asread_legacy_10x_h5;read_v3_10x_h5to read the new Cell Ranger output format;read_10x_h5determines the version of HDF5 input by the presence of thematrixkey, and wraps the above two functions. In addition, it takes agex_onlyargument which filters out feature barcoding counts from the outcome object when it isTrue(default). Otherwise, the full matrix will be retained.feature_typesandgenomewere added into the outcome object as new attributes.Updated
read_10x_mtx:read_10x_mtxasread_legacy_10x_mtx;read_v3_10x_mtxto read the new Cell Ranger output format;read_10x_mtxdetermines the version of matrix input by the presence of thegenes.tsvfile under the input directory, and wraps the above two functions. In addition, it takes agex_onlyargument which filters out feature barcoding counts from the outcome object when it isTrue(default). Otherwise, the full matrix will be retained.feature_typeswas added into the outcome object as a new attribute.Note for the
genomeargument:genomeargument in Scanpy'sread_10x_h5function but not inread_10x_mtxas the genome was already specified by the path of input directory. The outcome object of the two functions should be the same which always take one genome at a time.read_10x_mtxalways read them all, whereasread_10x_h5always need to specify one of them (Scanpy makesmm10by default).The following datasets have been tested for both HDF5 and MEX reading. Downstream analytic functions (PCA, umap, clustering, DEG, plotting, etc) have been test for 1 v2 dataset and 2 v3 datasets. Related notebooks are under the custom analysis repo CA00063.