From 766c5702c4d61403fd6c6217a67c19a01edff611 Mon Sep 17 00:00:00 2001 From: Kai Zhang Date: Mon, 11 Sep 2023 10:44:56 -0700 Subject: [PATCH] minor --- .github/workflows/docs.yml | 30 +++++++++++++++++-- .../snapatac2/preprocessing/_basic.py | 2 ++ .../snapatac2/preprocessing/_knn.py | 3 +- .../snapatac2/tools/_call_peaks.py | 4 +-- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0bf1b7b3c..ab43102e5 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,7 +23,7 @@ jobs: - name: Install dependency run: | - sudo apt-get install -y pandoc + sudo apt-get install -y pandoc jq sudo pip install --upgrade pip pip install --user sphinx==6.2.* pydata-sphinx-theme==0.13.* pandoc nbsphinx \ Pygments==2.14.0 sphinx-autodoc-typehints myst-parser \ @@ -66,7 +66,7 @@ jobs: clean: true target-folder: /version/dev/ - - name: Deploy (version) + - name: Deploy (version) 🚀 uses: JamesIves/github-pages-deploy-action@v4 if: ${{ env.DEPLOY_VERSION == 'true' }} with: @@ -74,4 +74,28 @@ jobs: branch: gh-pages folder: _build/html clean: true - target-folder: /version/${{ env.VERSION }}/ \ No newline at end of file + target-folder: /version/${{ env.VERSION }}/ + + - name: Fetch JSON and Get Preferred Version + run: | + JSON=$(curl -s "https://raw.githubusercontent.com/kaizhang/SnapATAC2/main/docs/_static/versions.json") + VERSION=$(echo "$JSON" | jq -r '.[] | select(.preferred == true) | .version') + echo "PREFERRED_VERSION=$VERSION" >> $GITHUB_ENV + echo "Preferred version is $VERSION" + + - name: Checkout code from gh-pages branch into folder + uses: actions/checkout@v2 + with: + ref: 'gh-pages' + path: 'gh-pages-folder' + + - name: Deploy (preferred version) + uses: JamesIves/github-pages-deploy-action@v4 + with: + single-commit: true + branch: gh-pages + folder: gh-pages-folder/version/${{ env.PREFERRED_VERSION }} + clean: true + clean-exclude: version + + diff --git a/snapatac2-python/snapatac2/preprocessing/_basic.py b/snapatac2-python/snapatac2/preprocessing/_basic.py index 2d30fa4de..325e43396 100644 --- a/snapatac2-python/snapatac2/preprocessing/_basic.py +++ b/snapatac2-python/snapatac2/preprocessing/_basic.py @@ -200,6 +200,8 @@ def import_data( chrom_size = genome.chrom_sizes if gene_anno is None: gene_anno = genome.fetch_annotations() + if len(chrom_size) == 0: + raise ValueError("chrom_size cannot be empty") if whitelist is not None: if isinstance(whitelist, str) or isinstance(whitelist, Path): diff --git a/snapatac2-python/snapatac2/preprocessing/_knn.py b/snapatac2-python/snapatac2/preprocessing/_knn.py index e4699d3cb..8057ce283 100644 --- a/snapatac2-python/snapatac2/preprocessing/_knn.py +++ b/snapatac2-python/snapatac2/preprocessing/_knn.py @@ -12,7 +12,7 @@ def knn( adata: AnnData | AnnDataSet | np.ndarray, n_neighbors: int = 50, use_dims: int | list[int] | None = None, - use_rep: str | None = None, + use_rep: str = 'X_spectral', method: Literal['hora', 'pynndescent', 'exact'] = "hora", n_jobs: int = -1, inplace: bool = True, @@ -51,7 +51,6 @@ def knn( Otherwise, return a sparse matrix. """ if is_anndata(adata): - if use_rep is None: use_rep = "X_spectral" data = adata.obsm[use_rep] else: inplace = False diff --git a/snapatac2-python/snapatac2/tools/_call_peaks.py b/snapatac2-python/snapatac2/tools/_call_peaks.py index f77620882..32a4e7f10 100644 --- a/snapatac2-python/snapatac2/tools/_call_peaks.py +++ b/snapatac2-python/snapatac2/tools/_call_peaks.py @@ -63,8 +63,8 @@ def call_peaks( if isinstance(groupby, str): groupby = list(adata.obs[groupby]) out_dir = out_dir if out_dir is None else str(out_dir) - res = _snapatac2.call_peaks(adata, groupby, selections, q_value, nolambda, - shift, extsize, blacklist, out_dir) + res = _snapatac2.call_peaks(adata, groupby, q_value, nolambda, + shift, extsize, selections, blacklist, out_dir) if inplace: if adata.isbacked: adata.uns[key_added] = res