Skip to content

Commit

Permalink
adapt to Snakemake 8; move env, config, annot export into the result …
Browse files Browse the repository at this point in the history
…folder to be self-contained
  • Loading branch information
sreichl committed Sep 13, 2024
1 parent f242120 commit 2d56c10
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![DOI](https://zenodo.org/badge/481635018.svg)](https://zenodo.org/badge/latestdoi/481635018)

# scCRISPR-seq Perturbation Analysis Snakemake Workflow using Seurat's Mixscape
A [Snakemake](https://snakemake.readthedocs.io/en/stable/) workflow for performing perturbation analyses of pooled (multimodal) CRISPR screens with scRNA-seq read-out (scCRISPR-seq, CROP-seq, Perturb-seq) powered by the R package [Seurat's](https://satijalab.org/seurat/index.html) method [Mixscape](https://satijalab.org/seurat/articles/mixscape_vignette.html).
A [Snakemake 8](https://snakemake.readthedocs.io/en/stable/) workflow for performing perturbation analyses of pooled (multimodal) CRISPR screens with scRNA-seq read-out (scCRISPR-seq, CROP-seq, Perturb-seq) powered by the R package [Seurat's](https://satijalab.org/seurat/index.html) method [Mixscape](https://satijalab.org/seurat/articles/mixscape_vignette.html).

This workflow adheres to the module specifications of [MR.PARETO](https://github.com/epigen/mr.pareto), an effort to augment research by modularizing (biomedical) data science. For more details, instructions and modules check out the project's repository. Please consider starring and sharing modules that are useful to you, this helps me in prioritizing my efforts!

Expand Down
6 changes: 4 additions & 2 deletions config/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Configuration

You need one configuration file and one annotation file to run the complete workflow. You can use the provided example as starting point. If in doubt read the comments in the config and/or try the default values.
You need one configuration file and one annotation file to run the complete workflow. If in doubt read the comments in the config and/or try the default values.

- project configuration (config/config.yaml): different for every project/dataset and configures the analyses to be performed.
- project configuration (`config/config.yaml`): different for every project/dataset and configures the analyses to be performed.
- sample annotation (sample_annotation): CSV file consisting of two columns
- name: name of the dataset (tip: keep it short).
- data: absolute path to the Seurat object as .rds.

Set workflow-specific `resources` or command line arguments (CLI) in the workflow profile `workflow/profiles/default.config.yaml`, which supersedes global Snakemake profiles.
1 change: 0 additions & 1 deletion config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
##### RESOURCES #####
mem: '32000'
threads: 1
partition: 'shortq'

##### GENERAL #####
annotation: /path/to/mixscape_seurat_annotation.csv
Expand Down
17 changes: 10 additions & 7 deletions workflow/Snakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@

##### global workflow dependencies #####
conda: "envs/global.yaml"

##### libraries #####
import os
import sys
import pandas as pd
import yaml
from snakemake.utils import min_version

min_version("7.15.2")
##### set minimum snakemake version #####
min_version("8.20.1")

##### module name #####
module_name = "mixscape_seurat"
Expand All @@ -27,18 +32,16 @@ rule all:
sample=samples),
prtb_score_plots = expand(os.path.join(result_path,'{sample}','plots','PerturbScore'),
sample=samples),
envs = expand(os.path.join(config["result_path"],'envs',module_name,'{env}.yaml'),env=['seurat_mixscape','seurat_lda']),
configs = os.path.join(config["result_path"],'configs',module_name,'{}_config.yaml'.format(config["project_name"])),
annotations = os.path.join(config["result_path"],'configs',module_name,'{}_annot.csv'.format(config["project_name"])),
envs = expand(os.path.join(result_path,'envs','{env}.yaml'),env=['seurat_mixscape','seurat_lda']),
configs = os.path.join(result_path,'configs','{}_config.yaml'.format(config["project_name"])),
annotations = os.path.join(result_path,'configs','{}_annot.csv'.format(config["project_name"])),
resources:
mem_mb=config.get("mem", "8000"),
threads: config.get("threads", 1)
log:
os.path.join("logs","rules","all.log"),
params:
partition=config.get("partition"),


##### load rules #####
include: os.path.join("rules", "common.smk")
include: os.path.join("rules", "mixscape.smk")
Expand Down
7 changes: 7 additions & 0 deletions workflow/envs/global.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
channels:
- conda-forge
- bioconda
- nodefaults
dependencies:
- numpy=2.0.1
- pandas=2.2.2
3 changes: 3 additions & 0 deletions workflow/profiles/default/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
default-resources:
slurm_partition: shortq
slurm_extra: "'--qos=shortq'"
24 changes: 9 additions & 15 deletions workflow/rules/envs_export.smk
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
# one rule per used conda environment to document the exact versions and builds of the used software
rule env_export:
output:
report(os.path.join(config["result_path"],'envs','mixscape_seurat','{env}.yaml'),
report(os.path.join(result_path,'envs','{env}.yaml'),
caption="../report/software.rst",
category="Software",
subcategory="{}_mixscape_seurat".format(config["project_name"])
subcategory="{}_{}".format(config["project_name"],module_name)
),
conda:
"../envs/{env}.yaml"
resources:
mem_mb=1000, #config.get("mem", "16000"),
mem_mb=1000,
threads: config.get("threads", 1)
log:
os.path.join("logs","rules","env_{env}.log"),
params:
partition=config.get("partition"),
shell:
"""
conda env export > {output}
Expand All @@ -23,18 +21,16 @@ rule env_export:
# add configuration files to report
rule config_export:
output:
configs = report(os.path.join(config["result_path"],'configs','mixscape_seurat','{}_config.yaml'.format(config["project_name"])),
configs = report(os.path.join(result_path,'configs','{}_config.yaml'.format(config["project_name"])),
caption="../report/configs.rst",
category="Configuration",
subcategory="{}_mixscape_seurat".format(config["project_name"])
subcategory="{}_{}".format(config["project_name"],module_name)
)
resources:
mem_mb=1000, #config.get("mem", "16000"),
mem_mb=1000,
threads: config.get("threads", 1)
log:
os.path.join("logs","rules","config_export.log"),
params:
partition=config.get("partition"),
run:
with open(output["configs"], 'w') as outfile:
yaml.dump(config, outfile)
Expand All @@ -44,18 +40,16 @@ rule annot_export:
input:
config["annotation"],
output:
annot = report(os.path.join(config["result_path"],'configs','mixscape_seurat','{}_annot.csv'.format(config["project_name"])),
annot = report(os.path.join(result_path,'configs','{}_annot.csv'.format(config["project_name"])),
caption="../report/configs.rst",
category="Configuration",
subcategory="{}_mixscape_seurat".format(config["project_name"])
subcategory="{}_{}".format(config["project_name"],module_name)
)
resources:
mem_mb=1000, #config.get("mem_small", "16000"),
mem_mb=1000,
threads: config.get("threads", 1)
log:
os.path.join("logs","rules","annot_export.log"),
params:
partition=config.get("partition"),
shell:
"""
cp {input} {output}
Expand Down
4 changes: 0 additions & 4 deletions workflow/rules/mixscape.smk
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ rule mixscape:
"../envs/seurat_mixscape.yaml"
log:
os.path.join("logs","rules","mixscape_{sample}.log"),
params:
partition=config.get("partition"),
script:
"../scripts/mixscape.R"

Expand Down Expand Up @@ -56,7 +54,5 @@ rule lda:
"../envs/seurat_lda.yaml"
log:
os.path.join("logs","rules","lda_{sample}.log"),
params:
partition=config.get("partition"),
script:
"../scripts/lda.R"
2 changes: 0 additions & 2 deletions workflow/rules/visualize.smk
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,5 @@ rule visualize:
"../envs/seurat_mixscape.yaml"
log:
os.path.join("logs","rules","visualize_{sample}.log"),
params:
partition=config.get("partition"),
script:
"../scripts/visualize.R"

0 comments on commit 2d56c10

Please sign in to comment.