Skip to content

Commit

Permalink
PD-2759 Add positioning task to Slide-tags WDL (#1402)
Browse files Browse the repository at this point in the history
  • Loading branch information
aawdeh authored Nov 5, 2024
1 parent 70d3e1d commit f81cee2
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 12 deletions.
18 changes: 11 additions & 7 deletions beta-pipelines/skylab/slidetags/SlideTags.wdl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version 1.0

import "scripts/spatial-count.wdl" as SpatialCount
import "scripts/positioning.wdl" as Positioning

workflow SlideTags {

Expand All @@ -10,25 +11,28 @@ workflow SlideTags {
String id
Array[String] fastq_paths
Array[String] pucks
Int mem_GiB = 64
Int disk_GiB = 128
String docker = "us.gcr.io/broad-gotc-prod/slide-tags:1.0.0"
Array[String] rna_paths
String sb_path
String docker = "us.gcr.io/broad-gotc-prod/slide-tags:1.1.0"
}

parameter_meta {
fastq_paths: "Array of paths to spatial fastq files"
pucks: "Array of paths to puck files"
mem_GiB: "Memory in GiB to allocate to the task"
disk_GiB: "Disk in GiB to allocate to the task"
docker: "Docker image to use"
}

call SpatialCount.count as spatial_count {
input:
fastq_paths = fastq_paths,
pucks = pucks,
mem_GiB = mem_GiB,
disk_GiB = disk_GiB,
docker = docker
}

call Positioning.generate_positioning as positioning {
input:
rna_paths = rna_paths,
sb_path = spatial_count.sb_counts,
docker = docker
}

Expand Down
4 changes: 4 additions & 0 deletions beta-pipelines/skylab/slidetags/scripts/CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ This project uses code from the following sources:
URL: [https://github.com/MacoskoLab/Macosko-Pipelines/blob/main/spatial-count/spatial-count.wdl](https://github.com/MacoskoLab/Macosko-Pipelines/blob/main/spatial-count/spatial-count.wdl)
This code was adapted and modified from the Macosko Lab's pipeline repository.

- **Positioning Workflow**
URL: [https://github.com/MacoskoLab/Macosko-Pipelines/blob/main/positioning/positioning.wdl](https://github.com/MacoskoLab/Macosko-Pipelines/blob/main/positioning/positioning.wdl)
This code was adapted and modified from the Macosko Lab's pipeline repository.

Additional modifications include output handling and script download changes.

Please refer to the original source for the full context of the workflow.
90 changes: 90 additions & 0 deletions beta-pipelines/skylab/slidetags/scripts/positioning.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
version 1.0

task generate_positioning {
input {
Array[String] rna_paths
String sb_path
Int mem_GiB = 128
Int disk_GiB = 128
Int nthreads = 16
String docker
}
command <<<
set -euo pipefail
set -x
echo "<< starting spatial-count >>"

gcloud config set storage/process_count 16 # is this set by user?
gcloud config set storage/thread_count 2 # is this set by user?

# Download the scripts -- these need to be changed -- also need to add to docker
wget https://raw.githubusercontent.com/MacoskoLab/Macosko-Pipelines/ee005109446f58764509ee47ff51c212ce8dabe3/positioning/positioning.R
wget https://raw.githubusercontent.com/MacoskoLab/Macosko-Pipelines/6a78716aa08a9f2506c06844f7e3fd491b03aa8b/positioning/load_matrix.R
wget https://raw.githubusercontent.com/MacoskoLab/Macosko-Pipelines/a7fc86abbdd3d46461c500e7d024315d88a97e9a/positioning/run-positioning.R

echo "RNA: ~{sep=' ' rna_paths}"
echo "SB: ~{sb_path}"

# Assert that the RNA files exist
rnas=(~{sep=' ' rna_paths})
for rna in "${rnas[@]}" ; do
if ! gsutil stat "$rna" &> /dev/null ; then
echo "ERROR: gsutil stat command failed on file $rna"
exit 1
fi
done

# Download the RNA
echo "Downloading RNA:"
mkdir RNA
gcloud storage cp ~{sep=' ' rna_paths} RNA

# Assert that the SB file exists
if ! gsutil stat "~{sb_path}" &> /dev/null ; then
echo "ERROR: gsutil stat command failed on file ~{sb_path}"
exit 1
fi

# Download the SB
echo "Downloading SB:"
mkdir SB
gcloud storage cp ~{sb_path} SB

# Run the script
echo ; echo "Running run-positioning.R"
Rscript run-positioning.R RNA SB output

# Upload the results
ls output/*

if [[ -f output/seurat.qs ]] ; then
echo "true" > DONE
else
echo ; echo "ERROR: CANNOT FIND: seurat.qs"
fi

echo; echo "Writing logs:"
echo; echo "RNA size:"; du -sh RNA
echo; echo "SB size:"; du -sh SB
echo; echo "output size:"; du -sh output
echo; echo "FREE SPACE:"; df -h

echo "tar files/logs"
cat stdout stderr > positioning.log
tar -zcvf output.tar.gz output
echo "<< completed positioning >>"
>>>

output {
File output_file = "output.tar.gz"
File positioning_log = "positioning.log"
}

runtime {
docker: docker
memory: "~{mem_GiB} GB"
disks: "local-disk ~{disk_GiB} SSD"
cpu: nthreads
}

}
9 changes: 4 additions & 5 deletions beta-pipelines/skylab/slidetags/scripts/spatial-count.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ task count {
input {
Array[String] fastq_paths
Array[String] pucks
Int mem_GiB
Int disk_GiB
Int mem_GiB = 64
Int disk_GiB = 128
Int nthreads = 1
String docker
}
command <<<
Expand Down Expand Up @@ -74,7 +75,6 @@ task count {
>>>

output {
Boolean DONE = read_boolean("DONE")
File sb_counts = "SBcounts.h5"
File spatial_log = "spatial-count.log"

Expand All @@ -83,8 +83,7 @@ task count {
docker: docker
memory: "~{mem_GiB} GB"
disks: "local-disk ~{disk_GiB} SSD"
cpu: 1
preemptible: 0
cpu: nthreads
}
}

0 comments on commit f81cee2

Please sign in to comment.