simonwm / tacco

TACCO: Transfer of Annotations to Cells and their COmbinations
BSD 3-Clause "New" or "Revised" License
44 stars 1 forks source link

"Exception: type_prior contains negative values!" when running tc.tl.annotate() #5

Closed ZeroLi-Bio closed 1 year ago

ZeroLi-Bio commented 1 year ago

Hello, I tried to run tc.tl.annotate() and encountered this error: `

tc.tl.annotate(puck,reference,'subtype',result_key='subtype',) Starting preprocessing Annotation profiles were not found in reference.varm["subtype"]. Constructing reference profiles with tacco.preprocessing.construct_reference_profiles and default arguments... Finished preprocessing in 118.54 seconds. Starting annotation of data with shape (173055, 2841) and a reference of shape (56131, 2841) using the following wrapped method: +- platform normalization: platform_iterations=0, gene_keys=subtype, normalize_to=adata +- multi center: multi_center=None multi_center_amplitudes=True +- bisection boost: bisections=4, bisection_divisor=3 +- core: method=OT annotation_prior=None mean,std( rescaling(gene) ) 29.675947315286834 623.3959057199611 bisection run on 1 /USER/lizeyu/00.software/Miniconda3/envs/TACCO_env/lib/python3.10/site-packages/tacco/utils/_dist.py:393: RuntimeWarning: invalid value encountered in sqrt A = np.sqrt(A) Traceback (most recent call last): File "", line 1, in File "/USER/lizeyu/00.software/Miniconda3/envs/TACCO_env/lib/python3.10/site-packages/tacco/tools/_annotate.py", line 802, in annotate cell_type = _method(tdata, reference, annotation_key, annotation_prior, verbose) File "/USER/lizeyu/00.software/Miniconda3/envs/TACCO_env/lib/python3.10/site-packages/tacco/tools/_annotate.py", line 328, in _method cell_type = annotation_method(adata, reference, annotation_key, annotation_prior, verbose) File "/USER/lizeyu/00.software/Miniconda3/envs/TACCO_env/lib/python3.10/site-packages/tacco/tools/_annotate.py", line 381, in _method cell_type = annotation_method(adata, reference, annotation_key, annotation_prior, verbose) File "/USER/lizeyu/00.software/Miniconda3/envs/TACCO_env/lib/python3.10/site-packages/tacco/tools/_annotate.py", line 208, in _method cell_type = annotation_method(adata, reference, annotation_key, annotation_prior, verbose) File "/USER/lizeyu/00.software/Miniconda3/envs/TACCO_env/lib/python3.10/site-packages/tacco/tools/_annotate.py", line 115, in _method cell_type = annotate(adata, reference, annotation_key, annotation_prior=_annotation_prior, verbose_arg, kw_args) File "/USER/lizeyu/00.software/Miniconda3/envs/TACCO_env/lib/python3.10/site-packages/tacco/tools/_OT.py", line 75, in _annotate_OT cell_type = _run_OT(type_cell_dist, annotation_prior, cell_prior=cell_prior, epsilon=epsilon, lamb=lamb) File "/USER/lizeyu/00.software/Miniconda3/envs/TACCO_env/lib/python3.10/site-packages/tacco/utils/_utils.py", line 247, in _run_OT raise Exception('type_prior contains negative values!') Exception: type_prior contains negative values! ` Since i couldn't find an example data format. Could you give me a hint about was that because of and where my data format is wrong?

The puck and reference i used were like: image

simonwm commented 1 year ago

Hello,

by default tc.tl.annotate assumes to find counts (i.e. non-negative integer values) in .X of both reference and adata.

So my guess would be that the .X at least in reference contains negative values due to some preprocessing.

If the bare counts are still somewhere in reference (and adata) but not in .X, you can use the counts_location parameter of tc.tl.annotate to specify where to find them. https://simonwm.github.io/tacco/_autosummary/tacco.tools.annotate.html#tacco.tools.annotate

Hope this helps!

ZeroLi-Bio commented 1 year ago

Great, thank you!