theislab / multimil

Multimodal weakly supervised learning to identify disease-specific changes in single-cell atlases
https://multimil.rtfd.io/
BSD 3-Clause "New" or "Revised" License
18 stars 3 forks source link

tutorial for the or snipet for case where we only have 1 modality #44

Open M0hammadL opened 2 years ago

M0hammadL commented 2 years ago

The way to enocde the data and dataloader for single-modality datasets is not clear

Nusob888 commented 1 month ago

Hi all, great tool! Just checking if any update on this?

I have tried a few variations to input only scRNAseq data by itself with no other modes, but the model seems to fail to fully train.

I am doing the following:

` adata = mtm.data.organize_multimodal_anndatas( adatas=[[adata_ref]], # a list of anndata objects per modality, RNA-seq always goes first layers=[["counts"]], # if need to use data from .layers, if None use .X )

adata_indices_end = adata.shape[1]

mtm.model.MultiVAE.setup_anndata( adata, categorical_covariate_keys=["batch"], rna_indices_end= adata_indices_end, )

vae = mtm.model.MultiVAE( adata, losses=["nb"], )

vae.train() `

I get the following error: Expected parameter loc (Tensor of shape (256, 16)) of distribution Normal(loc: torch.Size([256, 16]), scale: torch.Size([256, 16])) to satisfy the constraint Real(), but found invalid values: tensor([[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], [nan, nan, nan, ..., nan, nan, nan]], device='cuda:0', grad_fn=)

Which I presume has something to do with my single modality approach, as I can train the same dataset using scVI, MultiVI and scPoli fine (with the same hvg selections and preprocessing).

Any help would be much appreciated.