kaizhang / SnapATAC2

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

trouble with pbmc notebook #277

Open vjcitn opened 6 months ago

vjcitn commented 6 months ago

this is being run within the recommended container

for snap.pl.umap(data, color='leiden', interactive=False, height=500)


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[17], line 1
----> 1 snap.pl.umap(data, color='leiden', interactive=False, height=500)

File [/usr/local/lib/python3.11/site-packages/snapatac2/plotting/__init__.py:265](http://127.0.0.1:8888/usr/local/lib/python3.11/site-packages/snapatac2/plotting/__init__.py#line=264), in umap(adata, color, use_rep, marker_size, marker_opacity, sample_size, **kwargs)
    234 """Plot the UMAP embedding.
    235 
    236 Parameters
   (...)
    261     returned, which can then be further customized using the plotly API.
    262 """
    263 from natsort import index_natsorted
--> 265 embedding = adata.obsm[use_rep] 
    267 if isinstance(color, str):
    268     groups = adata.obs[color].to_numpy()

File [/usr/local/lib/python3.11/site-packages/anndata/_core/aligned_mapping.py:196](http://127.0.0.1:8888/usr/local/lib/python3.11/site-packages/anndata/_core/aligned_mapping.py#line=195), in AlignedActualMixin.__getitem__(self, key)
    195 def __getitem__(self, key: str) -> V:
--> 196     return self._data[key]

KeyError: 'X_umap'```
vjcitn commented 6 months ago

Also looks like git is needed in container for sc.external.pp.magic(gene_matrix, solver="approximate")

    141     from magic import MAGIC, __version__
    142 except ImportError:
--> 143     raise ImportError(
    144         "Please install magic package via `pip install --user "
    145         "git+git://github.com/KrishnaswamyLab/MAGIC.git#subdirectory=python`"
    146     )
njmei commented 6 months ago

I will take a look at these errors this weekend. Thanks for your patience!

vjcitn commented 6 months ago

Thanks for rapid response! Do you intend to put the container in a registry like dockerhub? I saw a size of 7.1GB on the image I made, so it seems reasonable to do this once the compatibility issues are sorted.

njmei commented 6 months ago

@vjcitn I've submitted a PR to address the issues you've encountered. After it is merged, you would need to wait until the latest version of SnapAtac2 is published to PyPi (see: https://pypi.org/project/snapatac2/#history) and then re-run the docker image build step while changing the --build-arg SNAP_ATAC_VERSION=v2.6.*.

I'm only a volunteer helping out with some Docker related things so I don't know about plans for publishing containers to Dockerhub. I will say it's probably best to either build them yourself or wait for official images to be published. The possibility of supply chain attacks makes it hard for me to recommend pulling from random docker repositories that happen to have snapatac2 images.

EDIT: As a short-term workaround in the top of any Jupyter notebooks in a new cell you can run !pip install scanpy[scanorama, skmisc, magic, harmony], restart your python kernel, and then proceed to run the rest of the notebook's cells. Note that because this install step is not persisted, you would need to re-run it every time you start a new docker container.