kaizhang / SnapATAC2

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

Potentially missing snapatac internal #113

Closed havu73 closed 1 year ago

havu73 commented 1 year ago

Hi! I am trying to use SnapATAC2 for my analysis. It would be a really package for my needs so thanks for developing it!

I tried to install using pip install snapatac2 --> success as far as I understand snap.__version__ --> 2.2.0

Now, if I try to import data of scATAC-seq using the following code:

fragment_file = os.path.join(data_dir, 'atac_fragments.tsv.gz')

data = snap.pp.import_data(
    fragment_file,
    genome=snap.genome.mm10,
    file="trial_WT.h5ad",
    sorted_by_barcode=False,
)

I will get an error saying:

---------------------------------------------------------------------------
PanicException                            Traceback (most recent call last)
Cell In[6], line 3
      1 fragment_file = os.path.join(data_dir, 'atac_fragments.tsv.gz')
----> 3 data = snap.pp.import_data(
      4     fragment_file,
      5     genome=snap.genome.mm10,
      6     file="trial_WT.h5ad",
      7     sorted_by_barcode=False,
      8 )

File ~/project-ernst/anaconda/envs/sc_env/lib/python3.9/site-packages/snapatac2/preprocessing/_basic.py:162, in import_data(fragment_file, file, genome, gff_file, chrom_size, min_num_fragments, min_tsse, sorted_by_barcode, low_memory, whitelist, chunk_size, tempdir)
    160     else:
    161         whitelist = set(whitelist)
--> 162 return internal.import_fragments(
    163     file, fragment_file, gff_file, chrom_size, min_num_fragments,
    164     min_tsse, sorted_by_barcode, low_memory, whitelist, chunk_size, tempdir
    165 )

PanicException: called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }

I looked into the code of ~/project-ernst/anaconda/envs/sc_env/lib/python3.9/site-packages/snapatac2/preprocessing/_basic.py, and from what I understand, the code may not be able to locate the files of snapatac2/_snapatac2/internal.py? I am not sure!

The content of snapatac2 folder contains:

(base) [havu73@n1911 snapatac2]$ ls
datasets.py  export  genome.py  __init__.py  _io.py  plotting  preprocessing  __pycache__  _snapatac2.cpython-39-x86_64-linux-gnu.so  tools  _utils.py  _version.py

I am trying not to build SnapATAC from scratch with Rust and all of that. Do you think you can help me fix this please?

kaizhang commented 1 year ago

Sorry for the obscure error message. But this most likely means the fragment file you used as the input doesn't exist. Could you double-check if the path is correct?

havu73 commented 1 year ago

Ah! That was a stupid mistake! Thank you so much!