-
Notifications
You must be signed in to change notification settings - Fork 610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix hvg warnings #2810
Fix hvg warnings #2810
Conversation
sum_total = np.sum(sums_genes).ravel() | ||
sum_total = np.sum(sums_genes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes a 0D array into a 1D array. Later a 0D array is expected, so let’s just not do that.
batch_info = adata.obs[batch_key].values | ||
batch_info = adata.obs[batch_key].to_numpy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.values
is deprecated in favor of .to_numpy()
df.means > min_mean, | ||
df.means < max_mean, | ||
df.dispersions_norm > min_disp, | ||
df.dispersions_norm < max_disp, | ||
df["means"] > min_mean, | ||
df["means"] < max_mean, | ||
df["dispersions_norm"] > min_disp, | ||
df["dispersions_norm"] < max_disp, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using item access instead of attribute access is good style, especially for library code
adata = adata[:1000, :500] | ||
adata = adata[:1000, :500].copy() | ||
sc.pp.filter_cells(adata, min_genes=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoids a warning
np.random.seed(0) | ||
adata.obs["batch"] = np.random.binomial(3, 0.5, size=(adata.n_obs)) | ||
adata.obs["batch"] = adata.obs["batch"].astype("category") | ||
gen = np.random.default_rng(0) | ||
adata.obs["batch"] = pd.array( | ||
gen.binomial(3, 0.5, size=adata.n_obs), dtype="category" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np.random.*
functions are deprecated in favor of np.random.Generator.*
methods.
@@ -50,15 +58,23 @@ def test_highly_variable_genes_basic(): | |||
assert adata.var["highly_variable"].sum() == 3 | |||
assert (highly_var_first_layer != adata.var["highly_variable"]).any() | |||
|
|||
|
|||
def test_highly_variable_genes_no_batch_matches_batch(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
splitting this long sequential test of many features up into individual ones
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #2810 +/- ##
==========================================
- Coverage 72.84% 72.70% -0.14%
==========================================
Files 111 111
Lines 12368 12368
==========================================
- Hits 9009 8992 -17
- Misses 3359 3376 +17
|
some small changes before #2809