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 #27

Open
tongjiezhao opened this issue Jul 1, 2022 · 4 comments
Open

ValueError #27

tongjiezhao opened this issue Jul 1, 2022 · 4 comments

Comments

@tongjiezhao
Copy link

tongjiezhao commented Jul 1, 2022

Hi I got this error when running hs = hotspot.Hotspot(
... adata,
... layer_key="csc_counts",
... model='bernoulli',
... latent_obsm_key="spatial",
... umi_counts_obs_key="total_counts",
... )

Traceback (most recent call last):
File "", line 1, in
File "python3.8/site-packages/hotspot/hotspot.py", line 135, in init
raise ValueError(
ValueError:
Detected all zero genes. Please filter adata and reinitialize.

and I try

sc.pp.filter_cells(adata, min_genes=200)
sc.pp.filter_genes(adata, min_cells=3)

it still shows this error
my anndata looks like this
AnnData object with n_obs × n_vars = 1404 × 29522
obs: 'n_genes', 'total_counts'
var: 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'mean', 'std', 'n_cells'
uns: 'hvg', 'log1p', 'neighbors', 'pca'
obsm: 'X_pca', 'spatial'
varm: 'PCs'
layers: 'csc_counts'
obsp: 'connectivities', 'distances'
and adata.X looks like this
(0, 0) -9.273971
(1, 0) -1.1690428
(2, 0) -2.1527452
(3, 0) 0.29593784
(4, 0) 2.888746
(5, 0) -0.5670085
(6, 0) 0.022515705
(7, 0) -0.3287619
(8, 0) -0.60607976
(9, 0) 3.9856915
(10, 0) 0.59192413
(11, 0) 5.258427
(12, 0) 0.060307246
(13, 0) 0.1517446
(14, 0) 0.29431388
(15, 0) -15.718134
(16, 0) 6.711702
(17, 0) -5.2702594
(18, 0) 0.48261452
(19, 0) 2.9903271
(20, 0) 8.463634
(21, 0) 1.5748714
(22, 0) 1.0938092
(23, 0) 0.44068232
(24, 0) 1.1826563

@Polligator
Copy link

encountered the same error, did you figure out how to resolve it?

@coleruoff
Copy link

I am also encountering this issue...

@Polligator
Copy link

One workaround for me was to filter the cell and genes with higher cutoffs, like set min_cell to 20, you just need to tweak on the values.

@deto
Copy link
Member

deto commented Jul 31, 2022

Hi everyone, it's hard to guess at what's happening here without your data/code, but if we extract the relevant bits in hotspot.py the check for this essentially does:

counts = adata.layers[layer_key] if layer_key is not None else adata.X
counts = counts.transpose()
valid_genes = counts.sum(axis=1) > 0
n_invalid = counts.shape[0] - valid_genes.sum()
if n_invalid > 0:
     raise ValueError(
          "\nDetected all zero genes. Please filter adata and reinitialize."
     )

So as long you had done filtering with sc.pp.filter_genes and min_cell >= 1 it should pass as all remaining genes should have a nonzero sum when summing across cells. Maybe you can run that snippet on your anndata object and it will shed light on why it's not passing the check?

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

4 participants