Skip to content
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

ValueError: b'Extrapolation not allowed with blending' #32

Open
FlowerPurr opened this issue Mar 26, 2024 · 1 comment
Open

ValueError: b'Extrapolation not allowed with blending' #32

FlowerPurr opened this issue Mar 26, 2024 · 1 comment

Comments

@FlowerPurr
Copy link

hi,
A bug occurred when I was using scanpy for high variant gene arithmetic. I learned that the bug originated from scikit-misc, so I came to you for help.

my code:

adata.layers["counts"] = adata.X.copy() sc.pp.normalize_total(adata, target_sum=1e4) adata adata.raw = adata # keep full dimension safe sc.pp.highly_variable_genes( adata, flavor="seurat_v3",# n_top_genes=2000, layer="counts", batch_key="orig.ident", subset=True, span=1 )

error output

`ValueError Traceback (most recent call last)
Cell In[13], line 3
2 adata.raw = adata # keep full dimension safe
----> 3 sc.pp.highly_variable_genes(
4 adata,
5 flavor="seurat_v3",#
6 n_top_genes=2000,
7 layer="counts",
8 batch_key="orig.ident",
9 subset=True,
10 span=1
11 )
13 filename = 'melanoma_sw_high_var.h5ad'
14 adata.write(filename)

File ~/miniconda3/envs/scanpy/lib/python3.12/site-packages/scanpy/preprocessing/_highly_variable_genes.py:441, in highly_variable_genes(adata, layer, n_top_genes, min_disp, max_disp, min_mean, max_mean, span, n_bins, flavor, subset, inplace, batch_key, check_values)
439 sig = signature(_highly_variable_genes_seurat_v3)
440 n_top_genes = cast(int, sig.parameters["n_top_genes"].default)
--> 441 return _highly_variable_genes_seurat_v3(
442 adata,
443 layer=layer,
444 n_top_genes=n_top_genes,
445 batch_key=batch_key,
446 check_values=check_values,
447 span=span,
448 subset=subset,
449 inplace=inplace,
450 )
452 if batch_key is None:
453 df = _highly_variable_genes_single_batch(
454 adata,
455 layer=layer,
(...)
462 flavor=flavor,
463 )

File ~/miniconda3/envs/scanpy/lib/python3.12/site-packages/scanpy/preprocessing/_highly_variable_genes.py:87, in _highly_variable_genes_seurat_v3(adata, layer, n_top_genes, batch_key, check_values, span, subset, inplace)
85 x = np.log10(mean[not_const])
86 model = loess(x, y, span=span, degree=2)
---> 87 model.fit()
88 estimat_var[not_const] = model.outputs.fitted_values
89 reg_std = np.sqrt(10**estimat_var)

File _loess.pyx:927, in _loess.loess.fit()

ValueError: b'Extrapolation not allowed with blending'`

@has2k1
Copy link
Owner

has2k1 commented Mar 26, 2024

This error is makes the most sense when making predictions outside the fitted data (x, the independent observations). There the solution is to use surface="direct" instead of interpolate. i.e. loess(x, y, span=span, degree=2, surface="direct")

In this case it happens when fitting the data which is unexpected. I would need to see the x and y values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants