kaizhang / SnapATAC2

Single-cell epigenomics analysis tools
https://kzhang.org/SnapATAC2/
215 stars 23 forks source link

Label Transfer Using the SCVI-tools #326

Open aydinbol opened 3 weeks ago

aydinbol commented 3 weeks ago

Hello. Thank you for this package. I'm doing an integration analysis using more than 40 scATAC samples. However, I do not have scRNA data from the same cells. I tried doing the label transfer using the SCVI-tools as you demonstrated here: https://kzhang.org/SnapATAC2/tutorials/annotation.html

The RNA-seq data I'm using is from the same disease model, but the cells are not overlapping at all. It looks like this:

44617a14-dc42-4041-be2d-e104c1f02d45

Do you have any suggestions to improve the label transferring? Do you have any plans of adding the FindTransferAnchors function from the Seurat package or do you think it is a better approach?

Thank you.

yojetsharma commented 2 weeks ago

Hi, I am facing issue at an earlier stage of the tutorial itself: I have merged 3 atac-seq samples (from a multiome exp) and carried out the initial steps as per the standard tutorial. I use the snRNA of these samples processed using scanpy to annotate the clusters in the ATAC seq dataset. However, I am not able to understand how to proceed. Because when I do exactly as per the tutorial i get the following:

>>> vae.train(max_epochs=1000, early_stopping=True)
/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/cuda/__init__.py:619: UserWarning: Can't initialize NVML
  warnings.warn("Can't initialize NVML")
/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/cuda/__init__.py:749: UserWarning: CUDA initialization: The NVIDIA driver on your system is too old (found version 9020). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver. (Triggered internally at ../c10/cuda/CUDAFunctions.cpp:108.)
  return torch._C._cuda_getDeviceCount() if nvml_count < 0 else nvml_count
INFO: GPU available: False, used: False
2024-08-26 00:23:29 - INFO - GPU available: False, used: False
INFO: TPU available: False, using: 0 TPU cores
2024-08-26 00:23:29 - INFO - TPU available: False, using: 0 TPU cores
INFO: IPU available: False, using: 0 IPUs
2024-08-26 00:23:29 - INFO - IPU available: False, using: 0 IPUs
INFO: HPU available: False, using: 0 HPUs
2024-08-26 00:23:29 - INFO - HPU available: False, using: 0 HPUs
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/scvi/model/base/_training_mixin.py", line 143, in train
    return runner()
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/scvi/train/_trainrunner.py", line 98, in __call__
    self.trainer.fit(self.training_plan, self.data_splitter)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/scvi/train/_trainer.py", line 220, in fit
    super().fit(*args, **kwargs)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/lightning/pytorch/trainer/trainer.py", line 538, in fit
    model = _maybe_unwrap_optimized(model)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/lightning/pytorch/utilities/compile.py", line 125, in _maybe_unwrap_optimized
    from torch._dynamo import OptimizedModule
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/_dynamo/__init__.py", line 64, in <module>
    torch.manual_seed = disable(torch.manual_seed)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/_dynamo/decorators.py", line 50, in disable
    return DisableContext()(fn)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 410, in __call__
    (filename is None or trace_rules.check(fn))
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/_dynamo/trace_rules.py", line 3378, in check
    return check_verbose(obj, is_inlined_call).skipped
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/_dynamo/trace_rules.py", line 3361, in check_verbose
    rule = torch._dynamo.trace_rules.lookup_inner(
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/_dynamo/trace_rules.py", line 3442, in lookup_inner
    rule = get_torch_obj_rule_map().get(obj, None)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/_dynamo/trace_rules.py", line 2782, in get_torch_obj_rule_map
    obj = load_object(k)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/_dynamo/trace_rules.py", line 2807, in load_object
    obj = _load_obj_from_str(x[0])
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/_dynamo/trace_rules.py", line 2795, in _load_obj_from_str
    return getattr(importlib.import_module(module), obj_name)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/distributed/_tensor/__init__.py", line 6, in <module>
    import torch.distributed._tensor.ops
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/distributed/_tensor/ops/__init__.py", line 2, in <module>
    from .embedding_ops import *  # noqa: F403
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/distributed/_tensor/ops/embedding_ops.py", line 8, in <module>
    import torch.distributed._functional_collectives as funcol
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/distributed/_functional_collectives.py", line 920, in <module>
    _register_ops()
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/distributed/_functional_collectives.py", line 911, in _register_ops
    impl_abstract(f"c10d_functional::{op_name}")(meta_impl)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/_custom_ops.py", line 253, in impl_abstract
    return torch.library.impl_abstract(qualname, func, _stacklevel=2)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/library.py", line 448, in impl_abstract
    source = torch._library.utils.get_source(_stacklevel + 1)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/_library/utils.py", line 39, in get_source
    frame = inspect.getframeinfo(sys._getframe(stacklevel))
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/inspect.py", line 1629, in getframeinfo
    lines, lnum = findsource(frame)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/inspect.py", line 952, in findsource
    module = getmodule(object, file)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/inspect.py", line 875, in getmodule
    f = getabsfile(module)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/inspect.py", line 844, in getabsfile
    _filename = getsourcefile(object) or getfile(object)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/inspect.py", line 817, in getsourcefile
    filename = getfile(object)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/site-packages/torch/package/package_importer.py", line 698, in _patched_getfile
    return _orig_getfile(object)
  File "/home/praghu/yojetsharma/.conda/envs/signac/lib/python3.10/inspect.py", line 778, in getfile
    raise TypeError('{!r} is a built-in module'.format(object))
TypeError: <module '' from '/ncbs_gs/nlsas_data/usershares/praghu/yojetsharma/snapatac2test'> is a built-in module