Sparse matrix error using totalVI integration

Hi all,
I have a CITE-seq dataset from 5 different donor that I’m trying to integrate using muon and totalVI. I started by concatenating the ADT and RNA data for each donor separately using the concatenate function in scanpy. After that i created a muon object using mu.MuData({“rna”: RNAdata, “protein”: Protdata}).

When I start the training of my model I directly get the following error message:

" INFO Computing empirical prior initialization for protein background.

--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[208], line 1 ----> 1 vae = scvi.model.TOTALVI(posdata1) File ~/anaconda3/envs/Scanpy2/lib/python3.11/site-packages/scvi/model/, in TOTALVI.init(self, adata, n_latent, gene_dispersion, protein_dispersion, gene_likelihood, latent_distribution, empirical_protein_background_prior, override_missing_proteins, **model_kwargs) 136 emp_prior = ( 137 empirical_protein_background_prior 138 if empirical_protein_background_prior is not None 139 else (self.summary_stats.n_proteins > 10) 140 ) 141 if emp_prior: → 142 prior_mean, prior_scale = self._get_totalvi_protein_priors(adata) 143 else: 144 prior_mean, prior_scale = None, None File ~/anaconda3/envs/Scanpy2/lib/python3.11/site-packages/scvi/model/, in TOTALVI._get_totalvi_protein_priors(self, adata, n_cells) 1161 for c in batch_pro_exp: 1162 try: → 1163, 1))) 1164 # when cell is all 0 1165 except ConvergenceWarning: File ~/anaconda3/envs/Scanpy2/lib/python3.11/site-packages/sklearn/mixture/, in, X, y) 155 “”"Estimate model parameters with the EM algorithm.

538 ) 539 elif isinstance(accept_sparse, (list, tuple)): 540 if len(accept_sparse) == 0: TypeError: A sparse matrix was passed, but dense data is required. Use X.toarray() to convert to a dense numpy array."

Can any of you make any sense of this? I’ve tried converting my matrixes to dense but i still get the same error message.

Very thankful for any response

I upload the ADT data in this way:

    # Load the ADT data
    adt_counts_sparse = mmread(adt_counts_file).tocsr()

    adt_barcodes = pd.read_csv(adt_barcodes_file, compression='gzip', sep='\t', header=None).values.flatten()
    adt_barcodes = [barcode + "-1" for barcode in adt_barcodes]
    adt_tags = pd.read_csv(adt_tags_file, compression='gzip', header=None).values.flatten()

    # Make sure the counts, barcodes, and tags align
    if adt_counts_sparse.shape != (len(adt_barcodes), len(adt_tags)):
        adt_counts_sparse = adt_counts_sparse.transpose()

    # Create the ADT AnnData object
    globals()[donor_name + '_adt'] = sc.AnnData(X=adt_counts_sparse, 

    # Change the matrix format in the uploaded ADT
    globals()[donor_name + '_adt'].X = csr_matrix(globals()[donor_name + '_adt'].X)
    return globals()[donor_name + '_adt']