Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,39 @@ on:
jobs:
CI:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version}}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
- name: Install Rye
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
curl -sSf https://rye.astral.sh/get | RYE_INSTALL_OPTION="--yes" bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH

- name: Install Dependencies
run: poetry install -n
- name: Setup Python ${{matrix.python-version}} & Dependencies
run: |
rye pin ${{ matrix.python-version }}
rye sync --update-all --all-features

- name: Run ruff lint check
run: poetry run ruff check --diff
run: rye run ruff check --diff

- name: Run ruff format check
run: poetry run ruff format --check --diff
run: rye run ruff format --check --diff

- name: Run pytest
run: poetry run pytest
run: rye run pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=src | tee pytest-coverage.txt

- name: Pytest Coverage Comment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: pytest-coverage.txt
junitxml-path: pytest.xml
if: ${{ matrix.os=='ubuntu-latest' && matrix.python-version=='3.12' }}
16 changes: 6 additions & 10 deletions .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Publish to PyPI
on:
release:
types: [released]
workflow_dispatch:

jobs:
publish_to_pypi:
Expand All @@ -14,18 +15,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install Poetry
- name: Install Rye
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
curl -sSf https://rye.astral.sh/get | RYE_INSTALL_OPTION="--yes" bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH

- name: Build
run: poetry build
run: rye build

- name: Publish
run: poetry publish -u $PYPI_USERNAME -p $PYPI_PASSWORD
run: rye publish -u $PYPI_USERNAME --token $PYPI_PASSWORD -y
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
output/
example/
.vscode/
notebooks/
**.fna.gz

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down Expand Up @@ -60,7 +62,7 @@ coverage.xml
*.pot

# Django stuff:
*.log
# *.log
local_settings.py
db.sqlite3
db.sqlite3-journal
Expand Down
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.6
hooks:
- id: ruff
name: ruff lint check
types_or: [python, pyi]
args: [--fix]
- id: ruff-format
name: ruff format check
types_or: [python, pyi]
65 changes: 34 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Fig2. ANI clustermap between all-vs-all 18 genomes. If no similarity detected by

## Installation

`Python 3.8 or later` is required for installation.
`Python 3.9 or later` is required for installation.
[fastANI](https://github.com/ParBLiSS/FastANI) or [skani](https://github.com/bluenote-1577/skani) is required to calculate ANI.

**Install bioconda package:**
Expand All @@ -38,7 +38,7 @@ Description of ANIclustermap's automated workflow.
1. Calculate ANI between all-vs-all microbial genomes by fastANI (or skani).
If no similarity detected by fastANI, NA is output. In that case, NA is replaced by 0.0.
If previous result available at the time of re-run, reuse previous result.
2. Clustering ANI matrix by scipy's UPGMA method.
2. Clustering ANI matrix by scipy UPGMA method.
3. Using clustered matrix, draw ANI clustermap by seaborn.

## Usage
Expand All @@ -50,37 +50,40 @@ Description of ANIclustermap's automated workflow.
### Options

$ ANIclustermap --help
usage: ANIclustermap -i [Genome fasta directory] -o [output directory]

Draw ANI(Average Nucleotide Identity) clustermap

optional arguments:
-i I, --indir I Input genome fasta directory (*.fa|*.fna[.gz]|*.fasta)
-o O, --outdir O Output directory
-m , --mode ANI calculation mode ('fastani'[default]|'skani')
-t , --thread_num Thread number parameter (Default: MaxThread - 1)
--overwrite Overwrite previous ANI calculation result (Default: OFF)
--fig_width Figure width (Default: 10)
--fig_height Figure height (Default: 10)
--dendrogram_ratio Dendrogram ratio to figsize (Default: 0.15)
--cmap_colors cmap interpolation colors parameter (Default: 'lime,yellow,red')
--cmap_gamma cmap gamma parameter (Default: 1.0)
--cmap_ranges Range values (e.g. 80,90,95,100) for discrete cmap (Default: None)
--cbar_pos Colorbar position (Default: (0.02, 0.8, 0.05, 0.18))
--annotation Show ANI value annotation (Default: OFF)
--annotation_fmt Annotation value format (Default: '.3g')
-v, --version Print version information
-h, --help Show this help message and exit

Usage: ANIclustermap [OPTIONS]

Draw ANI(Average Nucleotide Identity) clustermap

╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────╮
│ * --indir -i Input genome fasta directory (*.fa|*.fna[.gz]|*.fasta) [required] │
│ * --outdir -o Output directory [required] │
│ --mode ANI calculation tool (fastani|skani) [default: fastani] │
│ --thread_num -t Thread number parameter [default: MaxThread - 1] │
│ --overwrite Overwrite previous ANI calculation result │
│ --fig_width Figure width [default: 10] │
│ --fig_height Figure height [default: 10] │
│ --dendrogram_ratio Dendrogram ratio to figsize [default: 0.15] │
│ --cmap_colors cmap interpolation colors parameter [default: lime,yellow,red] │
│ --cmap_gamma cmap gamma parameter [default: 1.0] │
│ --cmap_ranges Range values (e.g. 80,90,95,100) for discrete cmap │
│ --cbar_pos Colorbar position [default: 0.02, 0.85, 0.04, 0.15] │
│ --annotation Show ANI value annotation │
│ --annotation_fmt Annotation value format [default: .3g] │
│ --quiet No print log on screen │
│ --version -v Print version information │
│ --help -h Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯

### Example Command

7 genomes minimal dataset. Click [here](https://github.com/moshi4/ANIclustermap/wiki/dataset/minimal_dataset.zip) to download dataset (Size=3.6MB).
7 genomes minimal dataset. Click [here](https://github.com/moshi4/ANIclustermap/raw/main/example/input/minimal_dataset.zip) to download dataset.

ANIclustermap -i ./minimal_dataset/ -o ./ANIclustermap_result

## Output Contents

ANIclustermap outputs 3 types of files.
ANIclustermap outputs 3 types of result files.

- **`ANIclustermap.[png|svg]`** ([example1](https://github.com/moshi4/ANIclustermap/blob/main/example/output/05_normal_dataset/ANIclustermap.png), [example2](https://github.com/moshi4/ANIclustermap/blob/main/example/output/06_normal_dataset_annotation/ANIclustermap.png))
ANI clustermap result figure.
Expand All @@ -94,32 +97,32 @@ ANIclustermap outputs 3 types of files.
## Gallery

Example gallery of 33 genomes normal dataset.
If you want to try it for yourself, click [here](https://github.com/moshi4/ANIclustermap/wiki/dataset/normal_dataset.zip) to donwload dataset (Size=63.5MB).
If you want to try it for yourself, click [here](https://github.com/moshi4/ANIclustermap/raw/main/example/input/normal_dataset.zip) to donwload dataset.

**Normal parameter:**

ANIclustermap -i ./normal_dataset -o ./ANIclustermap_result \
ANIclustermap -i ./normal_dataset -o ./ANIclustermap_result01 \
--fig_width 15

![ANIclustermap.png](https://raw.githubusercontent.com/moshi4/ANIclustermap/main/images/gallery/01_ANIclustermap.png)

**Change cmap_gamma parameter:**

ANIclustermap -i ./normal_dataset -o ./ANIclustermap_result \
ANIclustermap -i ./normal_dataset -o ./ANIclustermap_result02 \
--fig_width 15 --cmap_gamma 0.5

![ANIclustermap.png](https://raw.githubusercontent.com/moshi4/ANIclustermap/main/images/gallery/02_ANIclustermap.png)

**Change cmap_colors(=white,orange,red) paramter:**

ANIclustermap -i ./normal_dataset -o ./ANIclustermap_result \
ANIclustermap -i ./normal_dataset -o ./ANIclustermap_result03 \
--fig_width 15 --cmap_colors white,orange,red

![ANIclustermap.png](https://raw.githubusercontent.com/moshi4/ANIclustermap/main/images/gallery/03_ANIclustermap.png)

**Change cmap_ranges paramter:**

ANIclustermap -i ./normal_dataset -o ./ANIclustermap_result \
ANIclustermap -i ./normal_dataset -o ./ANIclustermap_result04 \
--fig_width 15 --cmap_ranges 80,85,90,92.5,95,97.5,100

> See [this issue](https://github.com/moshi4/ANIclustermap/issues/1) for more details.
Expand All @@ -128,7 +131,7 @@ If you want to try it for yourself, click [here](https://github.com/moshi4/ANIcl

**Add ANI value annotation parameter:**

ANIclustermap -i ./normal_dataset -o ./ANIclustermap_result \
ANIclustermap -i ./normal_dataset -o ./ANIclustermap_result05 \
--fig_width 20 --fig_height 15 --annotation

![ANIclustermap.png](https://raw.githubusercontent.com/moshi4/ANIclustermap/main/images/gallery/05_ANIclustermap.png)
32 changes: 26 additions & 6 deletions example/example_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,39 @@ OUTDIR=output
mkdir -p $OUTDIR

ANIclustermap -i ./input/minimal_dataset -o ${OUTDIR}/01_minimal_dataset \
--fig_width 8 --fig_height 5
--fig_width 8 --fig_height 5

ANIclustermap -i ./input/minimal_dataset -o ${OUTDIR}/02_minimal_dataset_annotation \
--fig_width 8 --fig_height 5 --annotation
--fig_width 8 --fig_height 5 --annotation

ANIclustermap -i ./input/small_dataset -o ${OUTDIR}/03_small_dataset \
--fig_width 15
--fig_width 15

ANIclustermap -i ./input/small_dataset -o ${OUTDIR}/04_small_dataset_annotation \
--fig_width 15 --annotation
--fig_width 15 --annotation

ANIclustermap -i ./input/normal_dataset -o ${OUTDIR}/05_normal_dataset \
--fig_width 15
--fig_width 15

ANIclustermap -i ./input/normal_dataset -o ${OUTDIR}/06_normal_dataset_annotation \
--fig_width 20 --annotation
--fig_width 20 --annotation

# Normal parameter
ANIclustermap -i ./input/normal_dataset -o ${OUTDIR}/ANIclustermap_result01 \
--fig_width 15

# Change cmap_gamma parameter
ANIclustermap -i ./input/normal_dataset -o ${OUTDIR}/ANIclustermap_result02 \
--fig_width 15 --cmap_gamma 0.5

# Change cmap_colors parameter
ANIclustermap -i ./input/normal_dataset -o ${OUTDIR}/ANIclustermap_result03 \
--fig_width 15 --cmap_colors white,orange,red

# Change cmap_ranges parameter
ANIclustermap -i ./input/normal_dataset -o ${OUTDIR}/ANIclustermap_result04 \
--fig_width 15 --cmap_ranges 80,85,90,92.5,95,97.5,100

# Add ANI value annotation parameter
ANIclustermap -i ./input/normal_dataset -o ${OUTDIR}/ANIclustermap_result05 \
--fig_width 20 --fig_height 15 --annotation
Binary file added example/input/minimal_dataset.zip
Binary file not shown.
Binary file added example/input/normal_dataset.zip
Binary file not shown.
Binary file added example/input/small_dataset.zip
Binary file not shown.
Binary file modified example/output/01_minimal_dataset/ANIclustermap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading