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

fail to use the sca.models.SCVI #206

Open
melancholy12 opened this issue Jul 25, 2023 · 7 comments
Open

fail to use the sca.models.SCVI #206

melancholy12 opened this issue Jul 25, 2023 · 7 comments
Assignees

Comments

@melancholy12
Copy link

vae = sca.models.SCVI(
adata_ref,
n_layers=2,
encode_covariates=True,
deeply_inject_covariates=False,
use_layer_norm="both",
use_batch_norm="none",
)

ValueError: Expected parameter loc (Tensor of shape (128, 10)) of distribution Normal(loc: torch.Size([128, 10]), scale: torch.Size([128, 10])) to satisfy the constraint Real(), but found invalid values:
tensor([[ nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan],
[ 0.260, 0.540, 0.078, -0.767, 0.169, 0.835, -0.062, 0.543, -0.479,
-0.110],
[ nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan],
[ 0.320, 0.559, 0.204, -0.554, 0.267, 1.067, 0.112, 0.654, -0.443,
-0.260],
[ 0.516, 0.640, -0.024, -0.396, 0.299, 0.797, -0.157, 0.369, -0.568,
-0.112],
[ nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan],
[ nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan],
...,
[ nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan],
[ 0.260, 0.063, -0.155, -0.576, 0.270, 0.842, 0.015, 0.408, -0.723,
-0.015],
[ 0.204, 0.617, 0.028, -0.464, 0.411, 0.688, -0.238, 0.208, -0.392,
0.019],
[-0.025, 0.790, 0.028, -0.647, 0.395, 0.345, -0.034, 0.466, -0.304,
-1.005],
[ 0.406, 0.497, 0.257, -0.780, 0.227, 0.585, 0.059, 0.210, -0.440,
-0.059],
[ nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan],
[ 0.384, 0.563, -0.295, -0.336, 0.161, 0.682, 0.300, 0.584, -0.774,
-0.457]], grad_fn=)

@Koncopd
Copy link
Member

Koncopd commented Aug 3, 2023

Could you provide more information? Maybe your input is not raw counts?

@melancholy12
Copy link
Author

@Koncopd No.. It is the processed data.

@Koncopd
Copy link
Member

Koncopd commented Aug 3, 2023

Still could you give me more info? versions of the packages, when exactly this error happens etc.
The data should not be preprocessed, it should contain raw counts.

@melancholy12
Copy link
Author

Thanks for your hand. I didn't check the email. Sorry for the delay.
scvi-tools 1.0.2
seaborn 0.12.2
scikit-learn 1.3.0
scanpy 1.9.3
scArches 0.5.9

@sojichld
Copy link

Any developments on this issue? I am having the same problem. I have a target dataset with raw data but the atlas does not contain the raw matrix.

@Koncopd
Copy link
Member

Koncopd commented Oct 25, 2023

How do you SCVI.setup_anndata? The raw counts normally should be in adata.X to use with SCVI.

@sojichld
Copy link

sojichld commented Oct 25, 2023

For me it is sca.models.SCVI.setup_anndata(source_adata, batch_key=condition_key)

This source_data is a reference atlas, that has no adata.raw object. The data was not formatted similarly to the target and some transformation had to be done, so its the best that I have at the moment.

That setup_anndata method will run, the code fails when I run model.train() with the target. From that method I get a similar error to the original issue.

However, it seems that without the raw data available it is not possible to use these methods? I may just have to find alternative methods or backtrack to find some earlier versions of the project.

Update: I was able to do this with just the raw target data. This solved the issue as the atlas has long since been transformed.

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

3 participants