Open giulialopatriello95 opened 3 weeks ago
Hi there! I am using TACCO to annotate my spatial single cell data with a pubblished datasets. In particular, I am having issues with this dataset. I would like to ask and to understand which is the problem and I can solve it.
Best regards, Giulia L.
` import tacco as tc
tc.tl.annotate(adata, reference, annotation_key='tissue_type',counts_location='X', result_key='cell_type',max_annotation=1,assume_valid_counts=True,multi_center=0)`
Annotation profiles were not found in `reference.varm["tissue_type"]`. Constructing reference profiles with `tacco.preprocessing.construct_reference_profiles` and default arguments... Finished preprocessing in 6.31 seconds. There is no expression data available in the `reference` (`np.prod(reference.shape) == 0`)! Therefore no platform normalization is performed even though `platform_iterations=0`. Starting annotation of data with shape (126176, 0) and a reference of shape (79522, 0) using the following wrapped method: +- maximum annotation: max_annotation=1 +- multi center: multi_center=0 multi_center_amplitudes=True +- bisection boost: bisections=4, bisection_divisor=3 +- core: method=OT annotation_prior=None bisection run on 1 --------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[18], line 3 1 import tacco as tc 2 #tc.tl.annotate(adata, reference, annotation_key='Detailed_Cell_Type', result_key='cell_type',max_annotation=1,assume_valid_counts=True,method='svm') ----> 3 tc.tl.annotate(adata, reference, annotation_key='tissue_type',counts_location='X', result_key='cell_type',max_annotation=1,assume_valid_counts=True,multi_center=0) File [~/.conda/envs/seurat/lib/python3.9/site-packages/tacco/tools/_annotate.py:820](http://localhost:50188/~/.conda/envs/seurat/lib/python3.9/site-packages/tacco/tools/_annotate.py#line=819), in annotate(adata, reference, annotation_key, result_key, counts_location, method, bisections, bisection_divisor, platform_iterations, normalize_to, annotation_prior, multi_center, multi_center_amplitudes, reconstruction_key, max_annotation, min_counts_per_gene, min_counts_per_cell, min_cells_per_gene, min_genes_per_cell, remove_constant_genes, remove_zero_cells, min_log2foldchange, min_expression, remove_mito, n_hvg, skip_checks, assume_valid_counts, return_reference, gene_keys, verbose, **kw_args) 818 print('\n'.join(method_construction_info[::-1])) 819 start = time.time() --> 820 cell_type = _method(tdata, reference, annotation_key, annotation_prior, verbose) 821 if verbose > 0: 822 print(f'Finished annotation in {np.round(time.time() - start, 2)} seconds.') File [~/.conda/envs/seurat/lib/python3.9/site-packages/tacco/tools/_annotate.py:499](http://localhost:50188/~/.conda/envs/seurat/lib/python3.9/site-packages/tacco/tools/_annotate.py#line=498), in max_annotation_method.<locals>._method(adata, reference, annotation_key, annotation_prior, verbose) 495 def _method(adata, reference, annotation_key, annotation_prior, verbose): 497 nonlocal annotation_method, max_annotation, prepare_reconstruction --> 499 cell_type = annotation_method(adata, reference, annotation_key, annotation_prior, verbose) 501 if max_annotation is not None and max_annotation > 0: 502 _cell_type = cell_type.to_numpy() File [~/.conda/envs/seurat/lib/python3.9/site-packages/tacco/tools/_annotate.py:381](http://localhost:50188/~/.conda/envs/seurat/lib/python3.9/site-packages/tacco/tools/_annotate.py#line=380), in multi_center_annotation_method.<locals>._method(adata, reference, annotation_key, annotation_prior, verbose) 378 nonlocal annotation_method, multi_center, prepare_reconstruction 380 if multi_center is None or multi_center <= 1: --> 381 cell_type = annotation_method(adata, reference, annotation_key, annotation_prior, verbose) 382 if prepare_reconstruction is not None: 383 prepare_reconstruction['annotation'] = cell_type.copy() File [~/.conda/envs/seurat/lib/python3.9/site-packages/tacco/tools/_annotate.py:208](http://localhost:50188/~/.conda/envs/seurat/lib/python3.9/site-packages/tacco/tools/_annotate.py#line=207), in boost_annotation_method.<locals>._method(adata, reference, annotation_key, annotation_prior, verbose) 205 if verbose > 0: 206 print(f'bisection run on {todo}') --> 208 cell_type = annotation_method(adata, reference, annotation_key, annotation_prior, verbose) 210 #print('update result with weight', current) 211 cell_type *= 1 / cell_type.sum(axis=1).to_numpy()[:, None] File [~/.conda/envs/seurat/lib/python3.9/site-packages/tacco/tools/_annotate.py:115](http://localhost:50188/~/.conda/envs/seurat/lib/python3.9/site-packages/tacco/tools/_annotate.py#line=114), in annotation_method.<locals>._method(adata, reference, annotation_key, annotation_prior, verbose) 112 else: 113 _annotation_prior = annotation_prior(adata, reference, annotation_key) --> 115 cell_type = annotate(adata, reference, annotation_key, annotation_prior=_annotation_prior, **verbose_arg, **kw_args) 117 #cell_type/cell_type.sum(axis=1)[:,None] 118 else: 119 cell_type = annotate(adata, reference, annotation_key, **verbose_arg, **kw_args) File [~/.conda/envs/seurat/lib/python3.9/site-packages/tacco/tools/_OT.py:66](http://localhost:50188/~/.conda/envs/seurat/lib/python3.9/site-packages/tacco/tools/_OT.py#line=65), in _annotate_OT(adata, reference, annotation_key, annotation_prior, epsilon, lamb, decomposition, deconvolution, **kw_args) 59 """\ 60 Implements the functionality of :func:`~annotate_OT` without data 61 integrity checks. 62 """ 64 cell_prior = helper.prep_cell_priors(adata, reads=True) ---> 66 type_cell_dist = helper.prep_distance(adata, reference, annotation_key, decomposition=decomposition, deconvolution=deconvolution, **kw_args) 67 if decomposition: 68 type_cell_dist, mixtures = type_cell_dist File [~/.conda/envs/seurat/lib/python3.9/site-packages/tacco/tools/_helper.py:74](http://localhost:50188/~/.conda/envs/seurat/lib/python3.9/site-packages/tacco/tools/_helper.py#line=73), in prep_distance(tdata, reference, type_key, n_pca, zero_center, log_norm, scale, metric, min_distance, decomposition, deconvolution) 71 raise ValueError('The deconvolution and decomposition workflow dont work together!') 73 if (np.array(tdata.X.sum(axis=1)).flatten()==0).any(): ---> 74 raise ValueError('There are observations without non-zero variables!') 76 tdata, reference = tdata.copy(), reference.copy() # dont touch the originals 78 if log_norm: ValueError: There are observations without non-zero variables!
Hi Giulia,
it seems your error is similar to this issue. Maybe this resolves your error, otherwise let us know and we will look into it more extensively.
Hope this helps!
Hi there! I am using TACCO to annotate my spatial single cell data with a pubblished datasets. In particular, I am having issues with this dataset. I would like to ask and to understand which is the problem and I can solve it.
Best regards, Giulia L.
` import tacco as tc
tc.tl.annotate(adata, reference, annotation_key='tissue_type',counts_location='X', result_key='cell_type',max_annotation=1,assume_valid_counts=True,multi_center=0)`