Repository navigation
Add calculate_qc_metrics function - #316
Conversation
|
Cool! Just the first question for now: any sparse matrix is allowed for |
|
All of this looks really good! Awesome! 😄 Most important thing that misses: making use of it already in a tutorial? Do you think it fits in the standard clustering tutorial? I just think that you should probably also add the top-level function to the |
Sparse matrix supportI took the easy way out for calculations on other sparse matrices types – just converted them to a I'd probably try an online sort (insertion?) for each cell, keeping only the top NumbaThis currently throws a lot of warnings about
|
718296c to
6a53d01
Compare
|
|
||
| conda create -n testenv --yes python=$TRAVIS_PYTHON_VERSION pip pytest hdf5 \ | ||
| numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION numba scikit-learn statsmodels | ||
| conda create -n testenv --yes python=$TRAVIS_PYTHON_VERSION pip pytest |
There was a problem hiding this comment.
Well, pip doesn't install them a second time but already sees the latest versions, doesn't it? Anyways, if numba installs fine with pip these days, there is no reason to install it with conda; so this is good.
There was a problem hiding this comment.
I think that's the case most of the time, but not always.
Since conda wasn't following the versioning in requirements.txt, it was installing numba v0.39.0 for python v3.5. This made pip install a different version, but not remove the old one. I think the older numba was being imported, causing the errors.
Here're the relevant lines from the build for a2c0d2b:
numba-0.39.0 | 2.4 MB | ##################################### | 100% # Line 589
Collecting numba>=0.40.0 (from -r requirements.txt (line 13)) # Line 706
I tried specifying the numba version a bit higher for conda, but was getting conflicts in dependency resolution. I figured if everything could be installed by pip, I knew the requirements.txt would be followed.
Yes to both! :) Let me know when I should merge this. |
|
I've pretty much just gotta write the docs and rebase on my other PR, and this should be good to go. For adding |
|
I'd say that if the user is supposed to work with or if you don't like If you provide examples for your stuff here on this PR (simply paste a few pictures with a few lines of code), then we can discuss on a better name. Maybe @fidelram also has some opinion on this. |
|
As mentioned before, can you move everything you currently have in |
Initial commit for adding `calculate_qc_metrics` based on functionality from `scater`.
Bump numba version to change errors to warnings. Install more dependencies with pip to avoid having conflicts between conda and pip installed packages.
This has been done the easy way, with converting sparse matrix types to csr. Alternative, more specialized method possible, but would take more work.
Probably should be two commits, but the code was kinda intertwinned by the time I got there. First, I've added support for COO sparse matrices, which required converting them, as they can't be subsetted, which means they raise a lot of errors. Next, I've added a bunch of features. This includes setting `feature_controls` and including log scaling for a few metrics.
Sadly, this makes for ugly code.
|
Oh, I think I misunderstood earlier when you said:
I wasn't sure if you meant move Otherwise, I think this might be good for now. I was thinking I'd update the tutorial to use this function after the PR is merged. Once that's done, is there a script to update the tests under |
|
Thank you, great! I meant moving Updating the tutorial after this is good! The tests under 😄 |
|
Would you mind adding a note to the release notes and adding the function to the docs to complete the whole PR: https://github.com/theislab/scanpy/blob/master/docs/release_notes.rst? |
|
I think I got the docs right, let me know if there are any issues. I'm noticing some conflict with convention for metric names. I'm copying It'd be nice for there to be a consistent default key for these features. For example, while updating the clustering tutorial, I ended up with both As changing the defaults could break some code, what's the right path forward? When |
|
Hm, Yes, we'd deprecate old names and output a warning, too. |
|
So, this is really awesome! Thank you so much! Added you to the author list just before... 😄 |
|
Thanks for the tutorial! Let's get most of this right now that no one has still used the function. We don't want to be consistent with Scater, we want to be consistent with the rest of Scanpy and the other python ecosystem.
Regarding I really like that you use an |
|
No problem!
I think Yeah, I figured I didn't want to make a whole copy of the object if I didn't want update or add all the metrics. About places in the codebase where naming would need to change, I'd argue the default shouldn't be to use a pre-computed value. I hadn't realized that |
|
thank you for your thoughts and suggestions! great! 😄
|
|
PS: I like your use of |
Here's what I'm thinking it'll look like right now (pending For obs:
For var:
|
Sorry about the late response. The week passes so quickly and depending on how it goes, I can only go back to Scanpy during the weekends these days... I like your new table much better than the previous one. If you'd put that forward in a PR, I'd be super happy! PS: I think |
Metrics were renamed following discussion in scverse#316. Additionally, I've fixed some bugs I caused while optimizing for sparse matrices. Pretty much all that's changed is there are sparse and dense specific methods for calculating nonzero genes, and mean expression.
|
No problem, gave a chance to optimize the code a bit (peak memory was about 3x AnnData size, now down to about 2x). |
Metrics were renamed following discussion in #316. Additionally, I've fixed some bugs I caused while optimizing for sparse matrices. Pretty much all that's changed is there are sparse and dense specific methods for calculating nonzero genes, and mean expression.
calculate_qc_metrics functioncalculate_qc_metrics function
I like the
calculateQCMetricsfunction fromscater, and have had a half finished python version drifting between my notebooks for a while. Is there is interest in adding this to scanpy?I'm aiming to mostly copy the interface of
calculateQCMetricswhile being memory efficient, since this is likely run before filtering.Todo
feature_controlargument, possiblyvariable_controlQuestions
adata.Xexpected to be any of the matrix types, or is it more limited? Just trying to figure out how much effort I should put into that.