Skip to content

Commit

Permalink
GEX - edit count rule to decrease the chance of accidental overwrite …
Browse files Browse the repository at this point in the history
…or deletion of existing runs, unset R lib user path when loading module
  • Loading branch information
chenv3 committed May 2, 2024
1 parent 8633516 commit a29c7c7
Showing 1 changed file with 37 additions and 12 deletions.
49 changes: 37 additions & 12 deletions workflow/rules/gex.smk
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,29 @@ rule count:
"""
# Remove output directory
# prior to running cellranger
# perform additional checks to prevent accidental clean-up of existing run
if [ -d '{params.id}' ]; then
if ! [ -f '{output.html}' ]; then
rm -rf '{params.id}/'
fi
if ! [ -f '{output.html}' ]; then
rm -rf '{params.id}/'
cellranger count \\
--id {params.id} \\
--sample {params.sample} \\
--transcriptome {params.transcriptome} \\
--fastqs {params.fastqs} \\
{params.excludeintrons} \\
{params.createbam} \\
2>{log.err} 1>{log.log}
fi
else
cellranger count \\
--id {params.id} \\
--sample {params.sample} \\
--transcriptome {params.transcriptome} \\
--fastqs {params.fastqs} \\
{params.excludeintrons} \\
{params.createbam} \\
2>{log.err} 1>{log.log}
fi
cellranger count \\
--id {params.id} \\
--sample {params.sample} \\
--transcriptome {params.transcriptome} \\
--fastqs {params.fastqs} \\
{params.excludeintrons} \\
{params.createbam} \\
2>{log.err} 1>{log.log}
"""

rule summaryFiles:
Expand Down Expand Up @@ -252,6 +261,10 @@ rule seuratQC:
shell:
"""
module load R/4.3.0
unset __RLIBSUSER
unset R_LIBS_USER
Rscript {params.seurat} \\
--workdir {params.outdir} \\
--datapath {params.data} \\
Expand All @@ -277,6 +290,10 @@ rule seuratQCReport:
shell:
"""
module load R/4.3.0
unset __RLIBSUSER
unset R_LIBS_USER
cd {params.tmpdir}
cp {params.script} ./{params.sample}.Rmd
R -e "rmarkdown::render('{params.sample}.Rmd', params=list(seuratdir='{params.seuratdir}', sample='{params.sample}', defaultfilter={params.filter}), output_file='{output.report}')"
Expand Down Expand Up @@ -307,6 +324,10 @@ rule cellFilterSummary:
shell:
"""
module load R/4.3.0
unset __RLIBSUSER
unset R_LIBS_USER
Rscript {params.script} --datapath {params.seuratdir} --filename {params.filename} --output {output.cell_filter_summary}
"""

Expand All @@ -324,6 +345,10 @@ rule seuratQCSummaryReport:
shell:
"""
module load R/4.3.0
unset __RLIBSUSER
unset R_LIBS_USER
R -e "rmarkdown::render('{params.script}', params=list(seuratdir='{params.seuratdir}', samples={params.samples}, cellfilter='{input.cell_filter}'), output_file='{output.report}')"
"""

Expand Down

0 comments on commit a29c7c7

Please sign in to comment.