Hello, thanks for the tool!
I’m trying to do the label transfer from a ref data to my query data.
I’m following this turorial: Human Endometrial Cell Atlas (HECA): a step-by-step guide to mapping query endometrial datasets to the reference atlas.
Everything goes well, but when I run sca.models.SCANVI.prepare_query_anndata(query_adata, scanvae)
, it announced:
INFO Found 96.39999999999999% reference vars in query data.
Unexpected exception formatting exception. Falling back to standard exception
Traceback (most recent call last):
File "/dssg/opt/icelake/linux-centos8-icelake/gcc-11.2.0/miniconda3-4.10.3-f5dsmdmzng2ck6a4otduqwosi22kacfl/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3398, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "/tmp/ipykernel_2491995/2532825497.py", line 2, in <cell line: 2>
sca.models.SCANVI.prepare_query_anndata(query_adata, scanvae)
File "/dssg/home/acct-aling1357/sherylshaw/.local/lib/python3.9/site-packages/scvi/model/base/_archesmixin.py", line 225, in prepare_query_anndata
adata_out = anndata.concat(
File "/dssg/home/acct-aling1357/sherylshaw/.local/lib/python3.9/site-packages/anndata/_core/merge.py", line 1367, in concat
File "/dssg/home/acct-aling1357/sherylshaw/.local/lib/python3.9/site-packages/anndata/_core/anndata.py", line 271, in __init__
Single dimensional annotations of the observation and variables are stored
File "/dssg/home/acct-aling1357/sherylshaw/.local/lib/python3.9/site-packages/anndata/_core/anndata.py", line 473, in _init_as_actual
if any((obs, var, uns, obsm, varm, obsp, varp)):
File "/dssg/home/acct-aling1357/sherylshaw/.local/lib/python3.9/site-packages/anndata/_core/aligned_mapping.py", line 288, in __init__
def __init__(
File "/dssg/opt/icelake/linux-centos8-icelake/gcc-11.2.0/miniconda3-4.10.3-f5dsmdmzng2ck6a4otduqwosi22kacfl/lib/python3.9/_collections_abc.py", line 940, in update
self[key] = other[key]
File "/dssg/home/acct-aling1357/sherylshaw/.local/lib/python3.9/site-packages/anndata/_core/aligned_mapping.py", line 199, in __setitem__
return key in self._data
File "/dssg/home/acct-aling1357/sherylshaw/.local/lib/python3.9/site-packages/anndata/_core/aligned_mapping.py", line 268, in _validate_value
return (self.parent.obs_names, self.parent.var_names)[self._axis]
File "/dssg/home/acct-aling1357/sherylshaw/.local/lib/python3.9/site-packages/anndata/_core/aligned_mapping.py", line 89, in _validate_value
val = ensure_df_homogeneous(val, f"{name} {key!r}")
ValueError: Value passed for key 'PCs' is of incorrect shape. Values of varm must match dimensions ('var',) of parent. Value had shape (58903,) while it should have had (38678,).
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/dssg/opt/icelake/linux-centos8-icelake/gcc-11.2.0/miniconda3-4.10.3-f5dsmdmzng2ck6a4otduqwosi22kacfl/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 1993, in showtraceback
stb = self.InteractiveTB.structured_traceback(
File "/dssg/opt/icelake/linux-centos8-icelake/gcc-11.2.0/miniconda3-4.10.3-f5dsmdmzng2ck6a4otduqwosi22kacfl/lib/python3.9/site-packages/IPython/core/ultratb.py", line 1118, in structured_traceback
return FormattedTB.structured_traceback(
File "/dssg/opt/icelake/linux-centos8-icelake/gcc-11.2.0/miniconda3-4.10.3-f5dsmdmzng2ck6a4otduqwosi22kacfl/lib/python3.9/site-packages/IPython/core/ultratb.py", line 1012, in structured_traceback
return VerboseTB.structured_traceback(
File "/dssg/opt/icelake/linux-centos8-icelake/gcc-11.2.0/miniconda3-4.10.3-f5dsmdmzng2ck6a4otduqwosi22kacfl/lib/python3.9/site-packages/IPython/core/ultratb.py", line 865, in structured_traceback
formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
File "/dssg/opt/icelake/linux-centos8-icelake/gcc-11.2.0/miniconda3-4.10.3-f5dsmdmzng2ck6a4otduqwosi22kacfl/lib/python3.9/site-packages/IPython/core/ultratb.py", line 818, in format_exception_as_a_whole
frames.append(self.format_record(r))
File "/dssg/opt/icelake/linux-centos8-icelake/gcc-11.2.0/miniconda3-4.10.3-f5dsmdmzng2ck6a4otduqwosi22kacfl/lib/python3.9/site-packages/IPython/core/ultratb.py", line 736, in format_record
result += ''.join(_format_traceback_lines(frame_info.lines, Colors, self.has_colors, lvals))
File "/dssg/opt/icelake/linux-centos8-icelake/gcc-11.2.0/miniconda3-4.10.3-f5dsmdmzng2ck6a4otduqwosi22kacfl/lib/python3.9/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "/dssg/opt/icelake/linux-centos8-icelake/gcc-11.2.0/miniconda3-4.10.3-f5dsmdmzng2ck6a4otduqwosi22kacfl/lib/python3.9/site-packages/stack_data/core.py", line 698, in lines
pieces = self.included_pieces
File "/dssg/opt/icelake/linux-centos8-icelake/gcc-11.2.0/miniconda3-4.10.3-f5dsmdmzng2ck6a4otduqwosi22kacfl/lib/python3.9/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "/dssg/opt/icelake/linux-centos8-icelake/gcc-11.2.0/miniconda3-4.10.3-f5dsmdmzng2ck6a4otduqwosi22kacfl/lib/python3.9/site-packages/stack_data/core.py", line 649, in included_pieces
pos = scope_pieces.index(self.executing_piece)
File "/dssg/opt/icelake/linux-centos8-icelake/gcc-11.2.0/miniconda3-4.10.3-f5dsmdmzng2ck6a4otduqwosi22kacfl/lib/python3.9/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "/dssg/opt/icelake/linux-centos8-icelake/gcc-11.2.0/miniconda3-4.10.3-f5dsmdmzng2ck6a4otduqwosi22kacfl/lib/python3.9/site-packages/stack_data/core.py", line 628, in executing_piece
return only(
File "/dssg/opt/icelake/linux-centos8-icelake/gcc-11.2.0/miniconda3-4.10.3-f5dsmdmzng2ck6a4otduqwosi22kacfl/lib/python3.9/site-packages/executing/executing.py", line 164, in only
raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0
I compared genes between ref and query adata, found query has only 1928, while the ref adata has 2000 genes.
# Get common genes
common_genes = np.intersect1d(query_adata.var_names, ref_adata.var_names)
print(f"Number of common genes: {len(common_genes)}")
Number of common genes: 1928
I tried to subset the 1928 genes and run
model = sca.models.SCANVI.load_query_data(
query_adata,
ref_path,
freeze_dropout = True,
)
there will be anoter error:
ValueError: Number of vars in `adata_target` not the same as source. Expected: 2000 Received: 1928
I’d appreciate it a lot if anyoone could give me some suggestion!!!