Skip to content

Commit

Permalink
Merge pull request #429 from lilab-bcb/yiming
Browse files Browse the repository at this point in the history
Add --localcores option to cellranger and spaceranger commands
  • Loading branch information
yihming authored Feb 11, 2025
2 parents da5311a + ebd61e6 commit 48161f8
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 13 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/womtools-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Womtools

on:
pull_request:
branches:
- master

jobs:
validate:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.repository }}
fetch-depth: 0 # Fetch all history

- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '21'

- name: Fetch Womtool
run: |
curl -L -o womtool.jar https://github.com/broadinstitute/cromwell/releases/download/87/womtool-87.jar
- name: List modified files
id: diff
run: echo "files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | tr '\n' ' ')" >> $GITHUB_ENV

- name: Validate WDL files using Womtool
run: |
for file in ${{ env.files }}
do
if [[ $file == *.wdl ]]; then
echo "Validating $file"
java -jar womtool.jar validate "$file"
fi
done
3 changes: 2 additions & 1 deletion workflows/cellranger/cellranger_arc_count.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ task run_cellranger_arc_count {
check_call(call_args)
fout.write(os.path.abspath(target) + ',' + samples[i] + ',' + ('Gene Expression' if data_types[i] == 'rna' else 'Chromatin Accessibility') + '\n')
call_args = ['cellranger-arc', 'count', '--id=results', '--libraries=libraries.csv', '--reference=genome_dir', '--jobmode=local']
mem_size = re.findall(r"\d+", "~{memory}")[0]
call_args = ['cellranger-arc', 'count', '--id=results', '--libraries=libraries.csv', '--reference=genome_dir', '--jobmode=local', '--localcores=~{num_cpu}', '--localmem='+mem_size]
if '~{gex_exclude_introns}' == 'true':
call_args.append('--gex-exclude-introns')
if '~{no_bam}' == 'true':
Expand Down
3 changes: 2 additions & 1 deletion workflows/cellranger/cellranger_atac_aggr.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ task run_cellranger_atac_aggr {
counts.append(library_id)
fout.write(library_id + "," + current_dir + '/' + library_id + "/fragments.tsv.gz," + current_dir + '/' + library_id + "/singlecell.csv\n")
call_args = ['cellranger-atac', 'aggr', '--id=results', '--reference=genome_dir', '--csv=aggr.csv', '--normalize=~{normalize}', '--jobmode=local']
mem_size = re.findall(r"\d+", "~{memory}")[0]
call_args = ['cellranger-atac', 'aggr', '--id=results', '--reference=genome_dir', '--csv=aggr.csv', '--normalize=~{normalize}', '--jobmode=local', '--localcores=~{num_cpu}', '--localmem='+mem_size]
if '~{secondary}' != 'true':
call_args.append('--nosecondary')
else:
Expand Down
3 changes: 2 additions & 1 deletion workflows/cellranger/cellranger_atac_count.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ task run_cellranger_atac_count {
check_call(call_args)
fastqs.append(target)
call_args = ['cellranger-atac', 'count', '--id=results', '--reference=genome_dir', '--fastqs=' + ','.join(fastqs), '--sample=~{sample_id}', '--jobmode=local']
mem_size = re.findall(r"\d+", "~{memory}")[0]
call_args = ['cellranger-atac', 'count', '--id=results', '--reference=genome_dir', '--fastqs=' + ','.join(fastqs), '--sample=~{sample_id}', '--jobmode=local', '--localcores=~{num_cpu}', '--localmem='+mem_size]
if '~{force_cells}' != '':
call_args.append('--force-cells=~{force_cells}')
if '~{dim_reduce}' != '':
Expand Down
2 changes: 1 addition & 1 deletion workflows/cellranger/cellranger_count.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ task run_cellranger_count {
fastqs_dirs.append(target)
mem_size = re.findall(r"\d+", "~{memory}")[0]
call_args = ['cellranger', 'count', '--id=results', '--transcriptome=genome_dir', '--chemistry=~{chemistry}', '--jobmode=local', '--localmem='+mem_size]
call_args = ['cellranger', 'count', '--id=results', '--transcriptome=genome_dir', '--chemistry=~{chemistry}', '--jobmode=local', '--localcores=~{num_cpu}', '--localmem='+mem_size]
if samples is None: # not Feature Barcode
call_args.extend(['--sample=~{sample_id}', '--fastqs=' + ','.join(fastqs_dirs)])
Expand Down
6 changes: 3 additions & 3 deletions workflows/cellranger/cellranger_create_reference.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ workflow cellranger_create_reference {

# Which docker registry to use
String docker_registry = "quay.io/cumulus"
# 8.0.1, 8.0.0, 7.2.0, 7.1.0, 7.0.1, 7.0.0, 6.1.2, 6.1.1
String cellranger_version = "8.0.1"
# 9.0.0, 8.0.1, 8.0.0, 7.2.0, 7.1.0, 7.0.1, 7.0.0, 6.1.2, 6.1.1
String cellranger_version = "9.0.0"

# Disk space in GB
Int disk_space = 100
Expand Down Expand Up @@ -308,7 +308,7 @@ task run_cellranger_mkref {
else:
break
call_args.extend(['--nthreads=~{num_cpu}', '--memgb=' + mem_digit])
call_args.extend(['--nthreads=~{num_cpu}', '--memgb=' + mem_digit, '--localcores=~{num_cpu}', '--localmem=' + mem_digit])
if '~{ref_version}' != '':
call_args.append('--ref-version=~{ref_version}')
Expand Down
2 changes: 1 addition & 1 deletion workflows/cellranger/cellranger_multi.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ task run_cellranger_multi {
raise Exception("Cannot locate CMO or FRP sample file!")
mem_size = re.findall(r"\d+", "~{memory}")[0]
call_args = ['cellranger', 'multi', '--id=results', '--csv=multi.csv', '--jobmode=local', '--localmem='+mem_size]
call_args = ['cellranger', 'multi', '--id=results', '--csv=multi.csv', '--jobmode=local', '--localcores=~{num_cpu}', '--localmem='+mem_size]
print(' '.join(call_args))
check_call(call_args)
CODE
Expand Down
2 changes: 1 addition & 1 deletion workflows/cellranger/cellranger_vdj.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ task run_cellranger_vdj {
fastqs.append(target)
mem_size = re.findall(r"\d+", "~{memory}")[0]
call_args = ['cellranger', 'vdj', '--chain=~{chain}', '--id=results', '--reference=ref_dir', '--fastqs=' + ','.join(fastqs), '--sample=~{sample_id}', '--jobmode=local', '--localmem='+mem_size]
call_args = ['cellranger', 'vdj', '--chain=~{chain}', '--id=results', '--reference=ref_dir', '--fastqs=' + ','.join(fastqs), '--sample=~{sample_id}', '--jobmode=local', '--localcores=~{num_cpu}', '--localmem='+mem_size]
if '~{denovo}' != 'false':
call_args.append('--denovo')
print(' '.join(call_args))
Expand Down
8 changes: 5 additions & 3 deletions workflows/cellranger/cellranger_vdj_create_reference.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ workflow cellranger_vdj_create_reference {

# Which docker registry to use
String docker_registry = "quay.io/cumulus"
# 8.0.0, 7.2.0 7.1.0, 7.0.1, 7.0.0, 6.1.2, 6.1.1
String cellranger_version = "8.0.0"
# 9.0.0, 8.0.0, 7.2.0 7.1.0, 7.0.1, 7.0.0, 6.1.2, 6.1.1
String cellranger_version = "9.0.0"

# Disk space in GB
Int disk_space = 100
Expand Down Expand Up @@ -84,6 +84,7 @@ task run_cellranger_vdj_create_reference {

python <<CODE
import os
import re
from subprocess import check_call
# Unzip fa if needed.
Expand All @@ -104,7 +105,8 @@ task run_cellranger_vdj_create_reference {
check_call(call_args)
gtf_file = root
call_args = ['cellranger', 'mkvdjref', '--genome=~{genome}', '--fasta=' + fa_file, '--genes=' + gtf_file]
mem_size = re.findall(r"\d+", "~{memory}")[0]
call_args = ['cellranger', 'mkvdjref', '--genome=~{genome}', '--fasta=' + fa_file, '--genes=' + gtf_file, '--jobmode=local', '--localcores=1', '--localmem='+mem_size]
if '~{ref_version}' != '':
call_args.append('--ref-version=~{ref_version}')
Expand Down
3 changes: 2 additions & 1 deletion workflows/spaceranger/spaceranger_count.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ task run_spaceranger_count {
check_call(call_args)
fastqs.append('~{sample_id}_' + str(i))
call_args = ['spaceranger', 'count', '--id=results', '--transcriptome=genome_dir', '--fastqs=' + ','.join(fastqs), '--sample=~{sample_id}', '--jobmode=local']
mem_size = re.findall(r"\d+", "~{memory}")[0]
call_args = ['spaceranger', 'count', '--id=results', '--transcriptome=genome_dir', '--fastqs=' + ','.join(fastqs), '--sample=~{sample_id}', '--jobmode=local', '--localcores=~{num_cpu}', '--localmem='+mem_size]
localmem = "".join(filter(str.isdigit, "~{memory}"))
call_args.append("--localmem=" + localmem)
Expand Down

0 comments on commit 48161f8

Please sign in to comment.