Skip to content

Commit

Permalink
Prep 1.7.2 release (#1785)
Browse files Browse the repository at this point in the history
* Set release date
* Remove unused rubrics from release notes
* enables highly_variable_genes_seurat_v3 to accept pseudocounts (#1679) 
* Add hvg change to release notes

Co-authored-by: Isaac Virshup <[email protected]>
Co-authored-by: giovp <[email protected]>
  • Loading branch information
ivirshup and giovp authored Apr 7, 2021
1 parent 661c44c commit 8fe1cf9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
9 changes: 2 additions & 7 deletions docs/release-notes/1.7.2.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
1.7.2 :small:`the future`
1.7.2 :small:`2021-04-07`
~~~~~~~~~~~~~~~~~~~~~~~~~

.. rubric:: Performance enhancements

.. rubric:: Bug fixes

- :func:`scanpy.logging.print_versions` now works when `python<3.8` :pr:`1691` :smaller:`I Virshup`
- :func:`scanpy.pp.regress_out` now uses `joblib` as the parallel backend, and should stop oversubscribing threads :pr:`1694` :smaller:`I Virshup`
- :func:`scanpy.pp.highly_variable_genes` with `flavor="seurat_v3"` now returns correct gene means and -variances when used with `batch_key` :pr:`1732` :smaller:`J Lause`

.. rubric:: Deprecations

.. rubric:: Documentation
- :func:`scanpy.pp.highly_variable_genes` now throws a warning instead of an error when non-integer values are passed for method `"seurat_v3"`. The check can be skipped by passing `check_values=False`. :pr:`1679` :smaller:`G Palla`

.. rubric:: Ecosystem

Expand Down
17 changes: 11 additions & 6 deletions scanpy/preprocessing/_highly_variable_genes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import warnings
from typing import Optional

import numpy as np
import pandas as pd
import scipy.sparse as sp_sparse
Expand All @@ -21,7 +20,8 @@ def _highly_variable_genes_seurat_v3(
layer: Optional[str] = None,
n_top_genes: int = 2000,
batch_key: Optional[str] = None,
span: Optional[float] = 0.3,
check_values: bool = True,
span: float = 0.3,
subset: bool = False,
inplace: bool = True,
) -> Optional[pd.DataFrame]:
Expand Down Expand Up @@ -58,10 +58,10 @@ def _highly_variable_genes_seurat_v3(
df = pd.DataFrame(index=adata.var_names)
X = adata.layers[layer] if layer is not None else adata.X

if check_nonnegative_integers(X) is False:
raise ValueError(
"`pp.highly_variable_genes` with `flavor='seurat_v3'` expects "
"raw count data."
if check_values and not check_nonnegative_integers(X):
warnings.warn(
"`flavor='seurat_v3'` expects raw count data, but non-integers were found.",
UserWarning,
)

df['means'], df['variances'] = _get_mean_var(X)
Expand Down Expand Up @@ -300,6 +300,7 @@ def highly_variable_genes(
subset: bool = False,
inplace: bool = True,
batch_key: Optional[str] = None,
check_values: bool = True,
) -> Optional[pd.DataFrame]:
"""\
Annotate highly variable genes [Satija15]_ [Zheng17]_ [Stuart19]_.
Expand Down Expand Up @@ -366,6 +367,9 @@ def highly_variable_genes(
by how many batches they are a HVG. For dispersion-based flavors ties are broken
by normalized dispersion. If `flavor = 'seurat_v3'`, ties are broken by the median
(across batches) rank based on within-batch normalized variance.
check_values
Check if counts in selected layer are integers. A Warning is returned if set to True.
Only used if `flavor='seurat_v3'`.
Returns
-------
Expand Down Expand Up @@ -417,6 +421,7 @@ def highly_variable_genes(
layer=layer,
n_top_genes=n_top_genes,
batch_key=batch_key,
check_values=check_values,
span=span,
subset=subset,
inplace=inplace,
Expand Down
8 changes: 8 additions & 0 deletions scanpy/tests/test_highly_variable_genes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
import pandas as pd
import numpy as np
import scanpy as sc
Expand Down Expand Up @@ -149,6 +150,13 @@ def test_higly_variable_genes_compare_to_seurat_v3():
seu = pd.Index(seurat_hvg_info_batch['x'].values)
assert len(seu.intersection(df.index)) / 4000 > 0.95

sc.pp.log1p(pbmc)
with pytest.warns(
UserWarning,
match="`flavor='seurat_v3'` expects raw count data, but non-integers were found.",
):
sc.pp.highly_variable_genes(pbmc, n_top_genes=1000, flavor='seurat_v3')


def test_filter_genes_dispersion_compare_to_seurat():
seurat_hvg_info = pd.read_csv(FILE, sep=' ')
Expand Down

0 comments on commit 8fe1cf9

Please sign in to comment.