jaydu1 / VITAE

Joint Trajectory Inference for Single-cell Genomics Using Deep Learning with a Mixture Prior
https://jaydu1.github.io/VITAE/
MIT License
26 stars 8 forks source link

Issue in model.pre_train when setting processed=True in model.preprocess_data #3

Closed rmathieu25 closed 3 years ago

rmathieu25 commented 3 years ago

Hello,

I have an issue at the step in which the autoencoder is pretrained only when I give a preprocess anndata object (it works if the adata object is not preprocessed beforehand):

# fit in data
model.get_data(adata=data,                   # count or expression matrix, (dense or sparse) numpy array 
               labels = data.obs['cluster_label'],       # (optional) labels, which will be converted to string
               gene_names = data.var['features'], # (optional) gene names, which will be converted to string
               cell_names = data.obs['sample_name']    # (optional) cell names, which will be converted to string
              )

# preprocess data
model.preprocess_data(gene_num = 2000,        # (optional) maximum number of influential genes to keep (the default is 2000)
                     data_type = 'Gaussian', # (optional) data_type can be 'UMI', 'non-UMI' or 'Gaussian' (the default is 'UMI')
                      npc = 64,         # (optional) number of PCs to keep if data_type='Gaussian' (the default is 64)
                     processed=True)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-2da55840b803> in <module>
      3                 batch_size=256,              # (Optional) the batch size for pre-training (the default is 32).
      4                 alpha=0.10,                  # (Optional) the value of alpha in [0,1] to encourage covariate adjustment. Not used if there is no covariates.
----> 5                 num_epoch = 300,             # (Optional) the maximum number of epoches (the default is 300).
      6                 ) 

~/anaconda3/lib/python3.7/site-packages/VITAE/VITAE.py in pre_train(self, stratify, test_size, random_state, learning_rate, batch_size, L, alpha, num_epoch, num_step_per_epoch, early_stopping_patience, early_stopping_tolerance, path_to_weights)
    274                                                 batch_size,
    275                                                 self.X[id_train].astype(tf.keras.backend.floatx()),
--> 276                                                 self.scale_factor[id_train].astype(tf.keras.backend.floatx()))
    277         self.test_dataset = train.warp_dataset(self.X_normalized[id_test], 
    278                                                 None if self.c_score is None else self.c_score[id_test].astype(tf.keras.backend.floatx()),

TypeError: 'NoneType' object is not subscriptable

Thank you in advance.

Best regards.

jaydu1 commented 3 years ago

Thanks for reporting the issue, which has been fixed in v1.1.7.