Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify output structure #45

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
a79ec94
Initial DSL2
adamjtaylor Mar 23, 2022
14d7d64
Add example dataset
adamjtaylor Mar 23, 2022
9572967
Start to build workflows
adamjtaylor Mar 23, 2022
0888d13
Merge pull request #30 from adamjtaylor/main
adamjtaylor Mar 29, 2022
27d458f
Merge pull request #31 from adamjtaylor/main
adamjtaylor Mar 29, 2022
c1fa592
Merge pull request #32 from adamjtaylor/main
adamjtaylor Mar 29, 2022
5ea1220
Write roughly working dsl2 pipeline
adamjtaylor Mar 31, 2022
8ee7247
Add action to build docker image
adamjtaylor Mar 31, 2022
d3ee683
Update ci.yml
adamjtaylor Mar 31, 2022
9d621ec
Update ci.yml
adamjtaylor Mar 31, 2022
db1cc59
Add small example data
adamjtaylor Mar 31, 2022
7dbc680
Merge branch 'dsl2' of https://www.github.com/adamjtaylor/htan-artist…
adamjtaylor Mar 31, 2022
51558b8
Add imagemagick
adamjtaylor Mar 31, 2022
969a66e
Add tiffslide and libvips
adamjtaylor Mar 31, 2022
5b5df0d
Make conversion optional and add he thumbnail approach
adamjtaylor Mar 31, 2022
bb50ae3
Choose outputs in samplesheet
adamjtaylor Apr 1, 2022
5ba910a
Start building new workflow
adamjtaylor Jan 10, 2023
2b66229
Add minerva
adamjtaylor Jan 11, 2023
0fa026c
Update config
adamjtaylor Jan 11, 2023
49661d1
Add sage.config
adamjtaylor Jan 11, 2023
3756c65
Add sage profile
adamjtaylor Jan 11, 2023
522af45
Create action to deploy to quay.io
adamjtaylor Jan 12, 2023
2ccd894
Update buildah version
adamjtaylor Jan 12, 2023
6dd67cf
Update ci.yml
adamjtaylor Jan 12, 2023
51ab7b8
Revert to bioformats2raw=0.4.0
adamjtaylor Jan 20, 2023
1758735
Revert numpy=1.23.0
adamjtaylor Jan 20, 2023
d869d1d
Delete quay.yml
adamjtaylor Jan 20, 2023
9cd3ac8
Use autominerva branch that works for all-blank channels
adamjtaylor Jan 24, 2023
6d5cb5c
Update Dockerfile to use v2 branch of miniature
adamjtaylor Jul 1, 2023
b0e0e35
Update Dockerfile
adamjtaylor Jul 1, 2023
e701e17
Update main.nf to use UCIE colormap
adamjtaylor Jul 1, 2023
5f5c351
Update main.nf
adamjtaylor Jul 1, 2023
e08e855
Update Dockerfile
adamjtaylor Jul 1, 2023
d455d19
Update main.nf
adamjtaylor Jul 1, 2023
d144b9f
Update Dockerfile to use minerva1point5 branch of auto-minerva
adamjtaylor Jul 1, 2023
755a464
Update environment.yml to add estimagic
adamjtaylor Jul 1, 2023
eede82f
Comment out remove_bg parameter
adamjtaylor Jul 1, 2023
f242299
Update expected location of miniature.png
adamjtaylor Jul 1, 2023
80f11df
Update main.nf
adamjtaylor Jul 1, 2023
78a9392
Update ci.yml
adamjtaylor Jul 1, 2023
1bb4eea
Add more miniature params
adamjtaylor Jul 1, 2023
f20aff5
Update Dockerfile
adamjtaylor Jul 1, 2023
fae1422
Update Dockerfile
adamjtaylor Jul 1, 2023
8b84c16
Update ci.yml
adamjtaylor Jul 1, 2023
780b7ca
Update Dockerfile
adamjtaylor Jul 1, 2023
f31cd22
Update Dockerfile
adamjtaylor Jul 1, 2023
af39470
Revert minerva author to v1.11.2
adamjtaylor Jul 3, 2023
aeac01c
Remove autominerva error strategy
adamjtaylor Jul 3, 2023
922b99a
Revert comment out of autominerva in dockerfile
adamjtaylor Jul 3, 2023
a54760f
Pip install ome-types
adamjtaylor Jul 3, 2023
26d418b
Move pip requirements into conda env
adamjtaylor Jul 3, 2023
8191ade
Fix opencv-python-headless typo
adamjtaylor Jul 3, 2023
ea76b54
Revert to pip install in Dockerfile
adamjtaylor Jul 3, 2023
8c8d130
Don't echo miniature
adamjtaylor Jul 3, 2023
193c9a9
Output jpg
adamjtaylor Jul 3, 2023
840f0bf
Merge pull request #1 from adamjtaylor/dsl2
thomasyu888 Jul 14, 2023
1d97040
add nextflow_schema json
Jul 14, 2023
5c0ab94
add specs about input filepath
Jul 14, 2023
cc4bc6d
correct colormap type
Jul 14, 2023
5030d47
Only publish story.json during autominerva
adamjtaylor Jul 15, 2023
61cbb64
creates new modules
BWMac Jul 25, 2023
ef38de6
creates new subworkflows
BWMac Jul 25, 2023
4f99da5
creates workflows/artist.nf
BWMac Jul 25, 2023
55b8c50
Merge pull request #3 from adamjtaylor/dsl2
BWMac Jul 26, 2023
ea31916
Merge branch 'dsl2' into bwmac/orca-242/modularize_artist
BWMac Jul 26, 2023
c1d3b12
Fix merge conflict
thomasyu888 Jul 28, 2023
34a23bf
Merge pull request #6 from Sage-Bionetworks-Workflows/dsl2
thomasyu888 Jul 28, 2023
5331bf1
Merge pull request #4 from Sage-Bionetworks-Workflows/bwmac/orca-242/…
BWMac Jul 28, 2023
cfbbbd1
[ORCA-249] Push docker image to ghcr and use trivy docker scan tool (#5)
rxu17 Aug 1, 2023
2fc6b2c
remove workfowRunname under id in output str
adamjtaylor Aug 17, 2023
ad3a013
Remove top-level runName in output
adamjtaylor Aug 17, 2023
d77f61b
Use id column from samplesheet if specified
adamjtaylor Aug 17, 2023
280cbd5
Remove unused code
adamjtaylor Aug 17, 2023
c462d28
Lint with prettier
adamjtaylor Aug 17, 2023
a945d29
Use improved H&E store compatible with Minerva 1.5
adamjtaylor Aug 17, 2023
f103f6b
Remove custom index.html as is generated by save_exhibit_pyramid
adamjtaylor Aug 17, 2023
30c5678
Remove unused items from Dockerfile
adamjtaylor Aug 17, 2023
7952055
Update readme
adamjtaylor Aug 17, 2023
b80c7bf
Lint he_story
adamjtaylor Aug 17, 2023
f7d57ab
Update schema
adamjtaylor Aug 17, 2023
1cd7beb
Merge pull request #10 from Sage-Bionetworks-Workflows/simplify_output
adamjtaylor Aug 17, 2023
0c126ba
Merge pull request #11 from Sage-Bionetworks-Workflows/custom_id_in_s…
adamjtaylor Aug 17, 2023
3d05bcb
Resolved merge conflict by removing modules/minerva.nf
adamjtaylor Aug 17, 2023
e096616
Merge pull request #8 from Sage-Bionetworks-Workflows/custom_id_in_sa…
adamjtaylor Aug 17, 2023
f4af592
Revert "Resolved merge conflict by removing modules/minerva.nf"
adamjtaylor Aug 18, 2023
4a35442
Add TODO.md
adamjtaylor Aug 18, 2023
cad3920
Update schema
adamjtaylor Aug 18, 2023
494ff04
Update schema
adamjtaylor Aug 18, 2023
ab171da
Refine remove_bg description
adamjtaylor Aug 18, 2023
de17f0b
Add output structure to readme
adamjtaylor Aug 18, 2023
c48f12d
Update options section of readme
adamjtaylor Aug 18, 2023
ff7c37c
Add id to samplesheet readme
adamjtaylor Aug 18, 2023
d7493b8
Add labels to all processes
adamjtaylor Aug 19, 2023
2febdd6
Tag each process with meta.id
adamjtaylor Aug 21, 2023
cd1f576
Update logic for H&E minerva stories
adamjtaylor Aug 22, 2023
871c7fb
Update test datasets
adamjtaylor Aug 22, 2023
b9d05f7
Update .gitignore
adamjtaylor Aug 22, 2023
476215a
Move to minerva-author v1.14.0
adamjtaylor Aug 22, 2023
338bf4b
Update TODO.md
adamjtaylor Aug 22, 2023
b9d5c21
Merge pull request #9 from Sage-Bionetworks-Workflows/cleanup
adamjtaylor Aug 24, 2023
86f2028
Fix example command in readme
adamjtaylor Aug 24, 2023
c1ecbfc
Use `id` from samplesheet if present
adamjtaylor Aug 24, 2023
c6db835
Convert H&E thumbnail to RGB if RGB or P mode
adamjtaylor Aug 24, 2023
2d67c0c
Merge pull request #16 from Sage-Bionetworks-Workflows/fix-readme-exa…
adamjtaylor Aug 24, 2023
edde6a5
Merge pull request #14 from Sage-Bionetworks-Workflows/orca-249-add-n…
adamjtaylor Aug 24, 2023
7b83f4e
Merge pull request #17 from Sage-Bionetworks-Workflows/use-id-from-sa…
thomasyu888 Sep 5, 2023
8b738da
Merge pull request #20 from Sage-Bionetworks-Workflows/fix-he-thumbna…
thomasyu888 Sep 5, 2023
5955c92
Simplify output structure
adamjtaylor Sep 15, 2023
35e1f26
Fix test samplesheet path for exemplar-001
adamjtaylor Sep 15, 2023
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
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: ci

on:
push:
branches:
- "main"
paths:
- "docker/**"
- ".github/workflows/ci.yml"

env:
REGISTRY: ghcr.io

jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

defaults:
run:
working-directory: "./docker"

steps:
- name: Checkout GitHub Action
uses: actions/checkout@v3

- name: Login to GitHub Container Registry (GHCR)
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=sha
latest

- name: Build and push to GHCR
uses: docker/build-push-action@v4
with:
context: ./docker
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
72 changes: 72 additions & 0 deletions .github/workflows/scan-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Scan image

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
schedule:
- cron: "32 12 * * 2" # every tuesday at 12:32 UTC time

env:
REGISTRY: ghcr.io
IMAGE_TAG: latest # scan just latest image

jobs:
trivy:
name: Run Trivy vulnerability scanner
permissions:
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
runs-on: ubuntu-latest

steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: ${{ env.IMAGE_TAG }}

- name: Pull the image
run: |
docker pull ${{ steps.metadata.outputs.tags }}

- name: Run Trivy vulnerability scanner for any major issues
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ steps.metadata.outputs.tags }}
ignore-unfixed: true
severity: "CRITICAL,HIGH"
limit-severities-for-sarif: true
format: sarif
output: trivy-results.sarif
timeout: 20m # trivy default timeout is 5m, we need longer for our image

# Show all detected issues.
- name: Run Trivy vulnerability scanner for local output
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ steps.metadata.outputs.tags }}
format: table
timeout: 20m # trivy default timeout is 5m, we need longer for our image

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: trivy-results.sarif
category: ${{ steps.metadata.outputs.tags }} image
wait-for-processing: true

- name: Detain results for debug if needed
uses: actions/upload-artifact@v3
with:
name: trivy-results.sarif
path: trivy-results.sarif
if-no-files-found: error
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.nextflow/
work/
.nextflow.log*
test-outputs/
test-outputs/
flowchart*
outputs/*
.DS_Store
80 changes: 49 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,70 @@
# HTAN Artist

A NextFlow piepline to run image rendering process to generate resources for the [HTAN Portal](https://github.com/ncihtan/htan-portal).
A NextFlow pipeline to run image rendering process to generate resources for the [HTAN Portal](https://github.com/ncihtan/htan-portal).

- Converts bioformats files into OME-TIFF
- Generates a `story.json` file using [Auto-Minerva](https://github.com/jmuhlich/auto-minerva)
- Sets thresholds for each channel and pepares 4-channel overlay groups using [Auto-Minerva](https://github.com/jmuhlich/auto-minerva)
- Renders a Minerva story using [Minerva Author](https://github.com/labsyspharm/minerva-author)
- If the `--all` parameter is set, renders a thumbnail, an autominerva story and gets the metadata
- If the `--miniature` parameter is set, renders a thumbnail image using [Miniature](https://github.com/adamjtaylor/miniature)
- `--he` assumes the channel is a brighfield microscopy image of H&E stained tissue and uses a fixed, unscaled `story.json` and a custom color legend
- `--input` can be the path to an image (with `*` wildcards) or a csv manifest of cloud storage uris (one per line).
- Renders a thumbnail image using [Miniature](https://github.com/adamjtaylor/miniature)

A Docker container ([adamjtaylor/htan-artist](https://hub.docker.com/repository/docker/adamjtaylor/htan-artist)) is used to ensure reproducibility.
A Docker container ([ghcr.io/sage-bionetworks-workflows/nf-artist](https://github.com/sage-bionetworks-workflows/nf-artist/pkgs/container/nf-artist)) is used to ensure reproducibility.

## Example usage

```
nextflow run adamjtaylor/htan-artist --input_path <path-to-image> --outdir <output-directory> --all
nextflow run Sage-Bionetworks-Workflows/nf-artist --input <path-to-samplesheet> --outdir <output-directory>
```


## Output

`nf-artist` outputs the following directory structure into the specified output directory (`outdir`):

```
├── outdir
│ ├── <simpleName or id for first row of samplesheet>
│ │ ├── thumbnail.jpeg
│ │ ├── minerva
│ │ │ ├── index.html
│ │ │ ├── exhibit.json
│ │ │ ├── story.json
│ │ │ ├── Group-1
│ │ │ │ ├── tile1.jpeg
│ │ │ │ ├── ...
│ │ │ ├── Group-<n>
│ │ │ │ ├── tile1.jpeg
│ │ │ │ ├── ...
│ ├── < simpleName or id for n'th row of samplesheet>
```

## Options

`--outdir` - output directory. Default: `.`
`--minerva`: Renders an [Auto-Minerva](https://github.com/jmuhlich/auto-minerva) story
`--miniature` - Renders a thumbnail image using [Miniature](https://github.com/adamjtaylor/miniature)
`--metadata` - Extract headers from the image and save as a json
`--all` - set `--minerva` `--miniature` and `--metadata`
`--he` - Use an unscaled scene for Minerva story and thumbnail generation. Suitable for H&E images
`--input_csv` - Path to a csv with a file path, uid, or synapseID per row
`--input_synid` - A synapse ID
`--input_path` - The path to a file. Can take wildcards
`--watch_path` - A path to watch for files that are created or modified
`--watch_csv` - A path to a csv to watch for if it is modified
`--echo` - Echo outputs
`--keepBg` - Keep the background in thumbnails
`--level` - the pyramid level used in thumbnauls, Default: `-1` (highest)
`--bioformats2ometiff` - Convert images to ome-tiff. Default: `true`
`--synapseconfig` - Path to a synapseConfig file. Required for Synapse authentication
#### Input/Output Options:

* **input**: Path to a CSV sample sheet. This parameter is required. (Type: String)

* **outdir**: Specifies the directory where the output data should be saved. Default is "outputs". (Type: String)

#### Miniature Options:

* **remove_bg**: Setting this to true will remove the non-tissue background. Default is true. (Type: Boolean)

* **level**: Specifies the pyramid level used in thumbnails. Default is -1 (smallest). (Type: Integer)

## Example flow diagram:
* **dimred**: The dimensionality reduction method used. Default is "umap". Options include "umap", "tsne", and "pca". (Type: String)

![image](https://user-images.githubusercontent.com/14945787/133272620-18223615-ce22-41c3-807b-3f3007b8f080.png)
* **colormap**: Specifies the colormap used. Ensure the colormap is compatible with the number of `n_components` selected. Default is "UCIE". 3D colormap options: "UCIE", "LAB", "RGB". 2D colormap options: "BREMM", "SCHUMANN", "STEIGER", "TEULING2", "ZIEGLER", "CUBEDIAGONAL". (Type: String)

## Docker pointers
* **n_components**: Specifies the number of components. Default is 3. Options are 2 and 3. (Type: Integer)

### Test docker container
#### Samplesheet requirements

`docker run -ti adamjtaylor/htan-artist`
The samplesheet specified in the `input` parameter should be a CSV file with the following columns

## Build docker container
- `image`: [string] Path or URI to image to be processed
- `convert`: [boolean] Should the image be converted to a OME-TIFF
- `he`: [boolean] Is the image a H&E image
- `minerva`: [boolean] Should a Minerva story be generated
- `miniatuee`: [boolean] Should a Miniature thumbnail be generated
- `id`: *optional* [string] A custom identifier to replace image simpleName in output directory structure

`docker build -t adamjtaylor/htan-artist docker/`
14 changes: 14 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# nf-artist
nf-artist is a Nextflow pipeline to generate interactive multiplexed image explorations and thumbnails.

- Add CI testing in Github action using included test data in `data/` and samplesheet `data/test_samplesheet.csv`
- Move logic on if minerva story or miniature thumbnail are run out of samplesheet and into `params`

## Minerva
- ✅ ~~Ensure H&E images are rendered with a fixed legend~~
- Allow for custom descriptions to be provided in the samplesheet and added into the Minerva story
- Update to new version of Minerva with channel selection

## Miniature

- Split `make_miniature` into two processes, one to run the miniature script for multiplexed images and one (that can have lower resource requirements) that makes the brightfield thumbnail for H&E images with TiffSlide
21 changes: 21 additions & 0 deletions assets/he_story.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"sample_info": {
"name": "",
"rotation": 0,
"text": "",
"pixels_per_micron": null
},
"defaults": [],
"groups": [
{
"label": "H&E",
"channels": [
{ "color": "ffffff", "id": 0, "label": "H&E", "min": 0, "max": 1 }
],
"render": [
{ "color": "ffffff", "id": 0, "label": "H&E", "min": 0, "max": 1 }
]
}
],
"waypoints": []
}
Binary file added data/CMU-1-Small-Region.svs
Binary file not shown.
Binary file added data/exemplar-001_small.tif
Binary file not shown.
3 changes: 3 additions & 0 deletions data/test_samplesheet.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
image,convert,he,minerva,miniature,id
data/exemplar-001_small.tif,true,false,true,true,cycif
data/CMU-1-Small-Region.svs,true,true,true,true,h_and_e
15 changes: 7 additions & 8 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
FROM continuumio/miniconda3 AS build

# File Author / Maintainer
MAINTAINER Adam Taylor <[email protected]>
LABEL maintainer="Adam Taylor <[email protected]>"

# Install the package as normal:
COPY environment.yml .
Expand All @@ -24,7 +24,6 @@ RUN conda-pack -n artist -o /tmp/env.tar && \
# so now fix up paths:
RUN /venv/bin/conda-unpack


# The runtime-stage image; we can use Debian as the
# base image since the Conda env also includes Python
# for us.
Expand All @@ -48,15 +47,15 @@ RUN apt-get update && apt-get install --yes --no-install-recommends \
libblosc1

RUN source /venv/bin/activate && \
git clone https://github.com/adamjtaylor/miniature.git && \
git clone https://github.com/jmuhlich/auto-minerva.git && \
git clone https://github.com/labsyspharm/minerva-author.git && \
git clone https://github.com/ncihtan/image-header-validation && \
wget https://gist.githubusercontent.com/adamjtaylor/964e206bf1e6f302f6e512082e953193/raw/0acdea0736a027a260a0bb598f619552ff106758/index.html && \
git clone https://github.com/adamjtaylor/miniature.git -b v2 && \
git clone https://github.com/adamjtaylor/auto-minerva.git -b minerva1point5 && \
git clone https://github.com/labsyspharm/minerva-author.git -b v1.14.0 && \
pip install git+https://github.com/labsyspharm/minerva-lib-python@master#egg=minerva-lib && \
pip install openslide-python && \
pip install opencv-python-headless \
pip install synapseclient
pip install synapseclient \
pip install mantel \
pip install ome_types

ENV VIRTUAL_ENV=/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
7 changes: 5 additions & 2 deletions docker/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ channels:
- fastai
- bioconda
dependencies:
- numpy
- numpy=1.23.0
- Pillow
- flask
- waitress
Expand All @@ -27,5 +27,8 @@ dependencies:
- h5py
- bioformats2raw=0.4.0
- raw2ometiff
- ome-types
- pip
- imagemagick
- tiffslide=2.1.2
- libvips
- estimagic
Loading
Loading