Skip to content

Commit

Permalink
incorporating pre-commit checks (#48)
Browse files Browse the repository at this point in the history
* formatted everything with ruff
* incorporating pre-commit checks
  • Loading branch information
anushka255 authored Sep 20, 2024
1 parent 249c0eb commit deaada0
Show file tree
Hide file tree
Showing 31 changed files with 1,421 additions and 3,360 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- uses: actions/checkout@v2

- name: Install Package
run: |
pip install .
run: |
pip install .
- name: Install Pandoc
run: sudo apt-get install -y pandoc
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test_pinned_deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
- name: Install package
run: pip install .

- name: Pre-commit checks
run: pre-commit run --all-files

- name: Check Versions of Dependencies
run: pip freeze

Expand All @@ -47,5 +50,3 @@ jobs:
run: coveralls
env:
GITHUB_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}


1 change: 0 additions & 1 deletion .github/workflows/test_unpinned_deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ jobs:

- name: Pytest
run: pytest

22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
exclude: 'tests/test_data/.*'

- id: end-of-file-fixer
exclude: 'tests/test_data/.*'

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.6
hooks:
- id: ruff
args: [ --fix ]
exclude: 'tests/test_data/.*'

- id: ruff-format
exclude: 'tests/test_data/.*'
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Coverage Status](https://coveralls.io/repos/github/raphael-group/paste3/badge.svg?branch=main)](https://coveralls.io/github/raphael-group/paste3?branch=main)
[![Docs](https://github.com/raphael-group/paste3/actions/workflows/docs.yml/badge.svg)](https://raphael-group.github.io/paste3/)

(Note: This repository integrates Paste and Paste 2, and is a work in progress)
(Note: This repository integrates Paste and Paste 2, and is a work in progress)
# PASTE

![PASTE Overview](https://github.com/raphael-group/paste/blob/main/docs/source/_static/images/paste_overview.png)
Expand All @@ -27,9 +27,9 @@ Additional examples and the code to reproduce the paper's analyses can be found

### Installation

The easiest way is to install PASTE on pypi: https://pypi.org/project/paste-bio/.
The easiest way is to install PASTE on pypi: https://pypi.org/project/paste-bio/.

`pip install paste-bio`
`pip install paste-bio`

Or you can install PASTE on bioconda: https://anaconda.org/bioconda/paste-bio.

Expand All @@ -38,14 +38,14 @@ Or you can install PASTE on bioconda: https://anaconda.org/bioconda/paste-bio.
Check out Tutorial.ipynb for an example of how to use PASTE.

Alternatively, you can clone the respository and try the following example in a
notebook or the command line.
notebook or the command line.

### Quick Start

To use PASTE we require at least two slices of spatial-omics data (both
expression and coordinates) that are in
anndata format (i.e. read in by scanpy/squidpy). We have included a breast
cancer dataset from [1] in the [sample_data folder](tests/data/input/) of this repo
cancer dataset from [1] in the [sample_data folder](tests/data/input/) of this repo
that we will use as an example below to show how to use PASTE.

```python
Expand Down Expand Up @@ -79,7 +79,7 @@ slice1, slice2 = slices
# Pairwise align the slices
pi12 = pst.pairwise_align(slice1, slice2)

# To visualize the alignment you can stack the slices
# To visualize the alignment you can stack the slices
# according to the alignment pi
slices, pis = [slice1, slice2], [pi12]
new_slices = pst.stack_slices_pairwise(slices, pis)
Expand All @@ -106,11 +106,11 @@ initial_slice = slice1.copy()
slices = [slice1, slice2]
lmbda = len(slices) * [1 / len(slices)] # set hyperparameter to be uniform

## Possible to pass in an initial pi (as keyword argument pis_init)
## Possible to pass in an initial pi (as keyword argument pis_init)
## to improve performance, see Tutorial.ipynb notebook for more details.
center_slice, pis = pst.center_align(initial_slice, slices, lmbda)

## The low dimensional representation of our center slice is held
## The low dimensional representation of our center slice is held
## in the matrices W and H, which can be used for downstream analyses
W = center_slice.uns['paste_W']
H = center_slice.uns['paste_H']
Expand All @@ -121,13 +121,13 @@ PASTE now is compatible with gpu via Pytorch. All we need to do is add the follo
```
pi12 = pst.pairwise_align(slice1, slice2, backend = ot.backend.TorchBackend(), use_gpu = True)
center_slice, pis = pst.center_align(initial_slice, slices, lmbda, backend = ot.backend.TorchBackend(), use_gpu = True)
center_slice, pis = pst.center_align(initial_slice, slices, lmbda, backend = ot.backend.TorchBackend(), use_gpu = True)
```
For more details, see the GPU section of the [Tutorial notebook](docs/source/notebooks/getting-started.ipynb).

### Command Line

We provide the option of running PASTE from the command line.
We provide the option of running PASTE from the command line.

First, clone the repository:

Expand Down Expand Up @@ -162,7 +162,7 @@ Note: `pairwise` will return pairwise alignment between each consecutive pair of

Added sample spatial transcriptomics dataset consisting of four breast cancer slice courtesy of:

[1] Ståhl, Patrik & Salmén, Fredrik & Vickovic, Sanja & Lundmark, Anna & Fernandez Navarro, Jose & Magnusson, Jens & Giacomello, Stefania & Asp, Michaela & Westholm, Jakub & Huss, Mikael & Mollbrink, Annelie & Linnarsson, Sten & Codeluppi, Simone & Borg, Åke & Pontén, Fredrik & Costea, Paul & Sahlén, Pelin Akan & Mulder, Jan & Bergmann, Olaf & Frisén, Jonas. (2016). Visualization and analysis of gene expression in tissue sections by spatial transcriptomics. Science. 353. 78-82. 10.1126/science.aaf2403.
[1] Ståhl, Patrik & Salmén, Fredrik & Vickovic, Sanja & Lundmark, Anna & Fernandez Navarro, Jose & Magnusson, Jens & Giacomello, Stefania & Asp, Michaela & Westholm, Jakub & Huss, Mikael & Mollbrink, Annelie & Linnarsson, Sten & Codeluppi, Simone & Borg, Åke & Pontén, Fredrik & Costea, Paul & Sahlén, Pelin Akan & Mulder, Jan & Bergmann, Olaf & Frisén, Jonas. (2016). Visualization and analysis of gene expression in tissue sections by spatial transcriptomics. Science. 353. 78-82. 10.1126/science.aaf2403.

Note: Original data is (.tsv), but we converted it to (.csv).

Expand Down
16 changes: 8 additions & 8 deletions docs/paste3/installation.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# Setting up the environment
# Setting up the environment

1. Clone the repository and enter it:
1. Clone the repository and enter it:
```shell
git clone [email protected]:raphael-group/paste3.git
cd paste3
```
2. Create and activate a conda environment using the provided `environment.yml` file:
2. Create and activate a conda environment using the provided `environment.yml` file:
```shell
conda env create --file environment.yml
conda activate paste
```
The command prompt will change to indicate the new conda environment by prepending `(paste)`.
3. When you are done using the package, deactivate the `paste` environment and return to `(base)` by entering the following command:
The command prompt will change to indicate the new conda environment by prepending `(paste)`.
3. When you are done using the package, deactivate the `paste` environment and return to `(base)` by entering the following command:
```shell
conda deactivate
```

# Installation
# Installation

1. Enter the `paste3` repository cloned before setting up the environment
```shell
cd paste3
```
2. Install the package:
```shell
pip install .
```
pip install .
```
1 change: 0 additions & 1 deletion docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,3 @@ Miscellaneous

helper.filter_for_common_genes
helper.match_spots_using_spatial_heuristic

21 changes: 11 additions & 10 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pathlib import Path
import sys
import os

HERE = Path(__file__).parent
sys.path.insert(0, os.path.abspath(HERE.parent.parent))

Expand All @@ -12,34 +13,34 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'paste3'
copyright = '2022, Raphael Lab'
author = 'Ron Zeira, Max Land, Alexander Strzalkowski, Benjamin J. Raphael'
project = "paste3"
copyright = "2022, Raphael Lab"
author = "Ron Zeira, Max Land, Alexander Strzalkowski, Benjamin J. Raphael"

# The full version, including alpha/beta/rc tags
release = '1.2.0'
release = "1.2.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"myst_parser",
'sphinx.ext.autosummary',
"sphinx.ext.autosummary",
"sphinx.ext.autodoc",
'sphinx.ext.napoleon',
"sphinx.ext.napoleon",
"sphinx_autodoc_typehints",
"nbsphinx",
"sphinx_gallery.load_style",
"sphinx.ext.viewcode"
"sphinx.ext.viewcode",
]

templates_path = ['_templates']
templates_path = ["_templates"]
exclude_patterns = []

language = 'python'
language = "python"

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"
html_static_path = ['_static']
html_static_path = ["_static"]
2 changes: 0 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,3 @@ You can view PASTE `preprint <https://www.biorxiv.org/content/10.1101/2021.03.16
paste3/installation.md
api
tutorial


Loading

0 comments on commit deaada0

Please sign in to comment.