-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from haniffalab/dev
Preparation for WebAtlas manuscript
- Loading branch information
Showing
73 changed files
with
3,797 additions
and
2,797 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,60 @@ | ||
[![python-tests](https://github.com/haniffalab/vitessce-pipeline/actions/workflows/tests-python.yml/badge.svg)](https://github.com/haniffalab/vitessce-pipeline/actions/workflows/tests-python.yml) | ||
[![codecov](https://codecov.io/gh/haniffalab/vitessce-pipeline/branch/main/graph/badge.svg?token=7HQVFH08WJ)](https://codecov.io/gh/haniffalab/vitessce-pipeline/branch/main) | ||
[![python-tests](https://github.com/haniffalab/webatlas-pipeline/actions/workflows/tests-python.yml/badge.svg)](https://github.com/haniffalab/webatlas-pipeline/actions/workflows/tests-python.yml) | ||
[![codecov](https://codecov.io/gh/haniffalab/webatlas-pipeline/branch/main/graph/badge.svg?token=7HQVFH08WJ)](https://codecov.io/gh/haniffalab/webatlas-pipeline/branch/main) | ||
|
||
# Vitessce Pipeline | ||
# WebAtlas Pipeline | ||
|
||
[![docs](https://img.shields.io/badge/Documentation-online-blue)](https://haniffalab.github.io/vitessce-pipeline) | ||
[![demo](https://img.shields.io/badge/Demos-view-blue)](https://haniffalab.github.io/vitessce-pipeline/demos.html) | ||
[![docs](https://img.shields.io/badge/Documentation-online-blue)](https://haniffalab.github.io/webatlas-pipeline) | ||
[![demo](https://img.shields.io/badge/Demos-view-blue)](https://haniffalab.github.io/webatlas-pipeline/demos.html) | ||
[![doi](https://zenodo.org/badge/DOI/10.5281/zenodo.7405818.svg)](https://doi.org/10.5281/zenodo.7405818) | ||
|
||
This Nextflow pipeline processes spatial and single-cell experiment data for visualisation in [vitessce-app](https://github.com/haniffalab/vitessce-app). The pipeline generates data files for [supported data types](http://vitessce.io/docs/data-types-file-types/), and builds a [view config](http://vitessce.io/docs/view-config-json/). | ||
This Nextflow pipeline processes spatial and single-cell experiment data for visualisation in [webatlas-app](https://github.com/haniffalab/webatlas-app). The pipeline generates data files for [supported data types](http://vitessce.io/docs/data-types-file-types/), and builds a [view config](http://vitessce.io/docs/view-config-json/). | ||
|
||
|
||
## Usage | ||
|
||
The pipeline can handle data from `h5ad` files, image `tif` files, SpaceRanger output, Xenium output and MERSCOPE output. It can also generate image files from data files. | ||
|
||
Running the pipeline requires a parameters file that defines configuration options and the data to be processed. | ||
Full instructions and parameters definitions for this files are available in the [documentation](https://haniffalab.com/webatlas-pipeline/setup.html) | ||
|
||
A parameters file looks like | ||
|
||
```yaml | ||
outdir: "/path/to/output/" | ||
|
||
args: | ||
h5ad: | ||
compute_embeddings: "True" | ||
|
||
projects: | ||
- project: project_1 | ||
datasets: | ||
- dataset: dataset_1 | ||
data: | ||
- | ||
data_type: h5ad | ||
data_path: /path/to/project_1/dataset_1/anndata.h5ad | ||
- | ||
data_type: raw_image | ||
data_path: /path/to/project_1/dataset_1/raw_image.tif | ||
- | ||
data_type: label_image | ||
data_path: /path/to/project_1/dataset_1/label_image.tif | ||
|
||
vitessce_options: | ||
spatial: | ||
xy: "obsm/spatial" | ||
mappings: | ||
obsm/X_umap: [0,1] | ||
layout: "simple" | ||
``` | ||
The pipeline can then be run like | ||
```sh | ||
nextflow run main.nf -params-file /path/to/run-params.yaml -entry Full_pipeline | ||
``` | ||
|
||
|
||
Parameters file templates are available in the `templates` directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
generate_image.py | ||
==================================== | ||
Generates raw/label images from spatial data | ||
""" | ||
|
||
from __future__ import annotations | ||
import fire | ||
import typing as T | ||
import tifffile as tf | ||
from process_spaceranger import visium_label | ||
from process_xenium import xenium_label | ||
from process_merscope import merscope_label, merscope_raw | ||
|
||
|
||
def create_img( | ||
stem: str, | ||
img_type: str, | ||
file_type: str, | ||
file_path: str, | ||
ref_img: str = None, | ||
args: dict[str, T.Any] = {}, | ||
) -> None: | ||
"""This function calls the corresponding function | ||
to write a label image given the metadata provided. | ||
It also obtains the image shape of a reference image if specified. | ||
Args: | ||
stem (str): Prefix for the output image filename. | ||
file_type (str): Type of file containing the metadata from which to | ||
generate the label image. | ||
file_path (str): Path to the metadata file. | ||
ref_img (str, optional): Path to reference image from which to get the | ||
shape for the label image. Defaults to None. | ||
args (dict[str,T.Any], optional): Args to be passed to the appropriate processing function. | ||
Defaults to {}. | ||
""" | ||
|
||
if ref_img: | ||
tif_img = tf.TiffFile(ref_img) | ||
args["shape"] = tif_img.pages[0].shape[:2] | ||
|
||
if img_type == "label": | ||
if file_type == "visium": | ||
visium_label(stem, file_path, **args) | ||
elif file_type == "merscope": | ||
merscope_label(stem, file_path, **args) | ||
elif file_type == "xenium": | ||
xenium_label(stem, file_path, **args) | ||
elif img_type == "raw": | ||
if file_type == "merscope": | ||
merscope_raw(stem, file_path, **args) | ||
|
||
|
||
if __name__ == "__main__": | ||
fire.Fire(create_img) |
Oops, something went wrong.