Skip to content

Commit

Permalink
comment global.yaml, add nodefaults and replace snakemake@source
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichl committed Dec 20, 2024
1 parent ba976d0 commit 5390a26
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion workflow/Snakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

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

##### libraries #####
import os
Expand Down
2 changes: 1 addition & 1 deletion workflow/envs/inspectdf.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
channels:
- conda-forge
- defaults
- nodefaults
dependencies:
- r-inspectdf=0.0.12
- r-data.table=1.14.10
2 changes: 1 addition & 1 deletion workflow/envs/seurat.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
channels:
- conda-forge
- bioconda
- defaults
- nodefaults
dependencies:
- r-seurat=4.4.0
- bioconductor-glmgampoi=1.14.0
Expand Down
2 changes: 2 additions & 0 deletions workflow/rules/normalize_correct_score.smk
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ rule normalize:
confounders = [],
module_gene_lists = config["module_gene_lists"],
cell_cycle = config["cell_cycle"],
utils_path = workflow.source_path("../scripts/utils.R"),
script:
"../scripts/sctransform_cellScore.R"

Expand Down Expand Up @@ -65,5 +66,6 @@ rule correct:
confounders = config["variables_to_regress"],
module_gene_lists = config["module_gene_lists"],
cell_cycle = config["cell_cycle"],
utils_path = workflow.source_path("../scripts/utils.R"),
script:
"../scripts/sctransform_cellScore.R"
10 changes: 9 additions & 1 deletion workflow/rules/process.smk
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# load & generate Seurat object per sample including metadata
rule prepare:
input:
Expand All @@ -24,6 +25,7 @@ rule prepare:
os.path.join("logs","rules","PREP_{sample}.log"),
params:
metadata = lambda w: "" if pd.isna(annot.loc["{}".format(w.sample),'metadata']) else annot.loc["{}".format(w.sample),'metadata'],
utils_path = workflow.source_path("../scripts/utils.R"),
script:
"../scripts/prepare.R"

Expand Down Expand Up @@ -53,7 +55,8 @@ rule merge:
log:
os.path.join("logs","rules","merge.log"),
params:
extra_metadata = config["extra_metadata"]
extra_metadata = config["extra_metadata"],
utils_path = workflow.source_path("../scripts/utils.R"),
script:
"../scripts/merge.R"

Expand All @@ -74,6 +77,8 @@ rule split:
"list": "Metadata",
"feature": "",
}),
params:
utils_path = workflow.source_path("../scripts/utils.R"),
resources:
mem_mb=config.get("mem", "16000"),
threads: config.get("threads", 1)
Expand Down Expand Up @@ -114,6 +119,7 @@ rule filter_cells:
ab_flag = config["modality_flags"]['Antibody_Capture'],
crispr_flag = config["modality_flags"]['CRISPR_Guide_Capture'],
custom_flag = config["modality_flags"]['Custom'],
utils_path = workflow.source_path("../scripts/utils.R"),
script:
"../scripts/filter.R"

Expand Down Expand Up @@ -145,6 +151,8 @@ rule pseudobulk:
"list": "Cell count",
"feature": "",
}),
params:
utils_path = workflow.source_path("../scripts/utils.R"),
resources:
mem_mb=config.get("mem", "16000"),
threads: config.get("threads", 1)
Expand Down
5 changes: 5 additions & 0 deletions workflow/rules/visualize.smk
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# visualize metadata
rule metadata_plots:
input:
Expand All @@ -16,6 +17,8 @@ rule metadata_plots:
"feature": "",
}),
metadata_stats = directory(os.path.join(result_path,'{split}','{step}','stats')),
params:
utils_path = workflow.source_path("../scripts/utils.R"),
resources:
mem_mb=config.get("mem", "16000"),
threads: config.get("threads", 1)
Expand Down Expand Up @@ -44,6 +47,8 @@ rule seurat_plots:
"list": "{feature_list}",
"feature": "{feature}",
}),
params:
utils_path = workflow.source_path("../scripts/utils.R"),
resources:
mem_mb=config.get("mem", "16000"),
threads: config.get("threads", 1)
Expand Down
3 changes: 2 additions & 1 deletion workflow/scripts/filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ library("Seurat")

# source utility functions
# source("workflow/scripts/utils.R")
snakemake@source("./utils.R")
# snakemake@source("./utils.R") # does not work when loaded as module (https://github.com/snakemake/snakemake/issues/2205)
source(snakemake@params[["utils_path"]])

# inputs
raw_object_path <- snakemake@input[["raw_object"]]
Expand Down
3 changes: 2 additions & 1 deletion workflow/scripts/merge.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ library("Seurat")

# source utility functions
# source("workflow/scripts/utils.R")
snakemake@source("./utils.R")
# snakemake@source("./utils.R") # does not work when loaded as module (https://github.com/snakemake/snakemake/issues/2205)
source(snakemake@params[["utils_path"]])

#### configs

Expand Down
3 changes: 2 additions & 1 deletion workflow/scripts/metadata_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ library("ggplot2")

# source utility functions
# source("workflow/scripts/utils.R")
snakemake@source("./utils.R")
# snakemake@source("./utils.R") # does not work when loaded as module (https://github.com/snakemake/snakemake/issues/2205)
source(snakemake@params[["utils_path"]])

# inputs
metadata_path <- snakemake@input[["metadata"]]
Expand Down
3 changes: 2 additions & 1 deletion workflow/scripts/prepare.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ library("Seurat")

# source utility functions
# source("workflow/scripts/utils.R")
snakemake@source("./utils.R")
# snakemake@source("./utils.R") # does not work when loaded as module (https://github.com/snakemake/snakemake/issues/2205)
source(snakemake@params[["utils_path"]])

# helper function to assign each cell's gRNA and KO calls
assign_grna_KO <- function(col) {
Expand Down
3 changes: 2 additions & 1 deletion workflow/scripts/pseudobulk.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ library("dplyr")

# source utility functions
# source("workflow/scripts/utils.R")
snakemake@source("./utils.R")
# snakemake@source("./utils.R") # does not work when loaded as module (https://github.com/snakemake/snakemake/issues/2205)
source(snakemake@params[["utils_path"]])

# helper function to check if all values in a group are the same
all_equal <- function(x) {
Expand Down
3 changes: 2 additions & 1 deletion workflow/scripts/sctransform_cellScore.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ library("sctransform")

# source utility functions
# source("workflow/scripts/utils.R")
snakemake@source("./utils.R")
# snakemake@source("./utils.R") # does not work when loaded as module (https://github.com/snakemake/snakemake/issues/2205)
source(snakemake@params[["utils_path"]])

# inputs
filtered_object_path <- snakemake@input[["filtered_object"]]
Expand Down
3 changes: 2 additions & 1 deletion workflow/scripts/seurat_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ library("ggplot2")

# source utility functions
# source("workflow/scripts/utils.R")
snakemake@source("./utils.R")
# snakemake@source("./utils.R") # does not work when loaded as module (https://github.com/snakemake/snakemake/issues/2205)
source(snakemake@params[["utils_path"]])

# inputs
object_path <- snakemake@input[["norm_object"]]
Expand Down
3 changes: 2 additions & 1 deletion workflow/scripts/split.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ library("Seurat")

# source utility functions
# source("workflow/scripts/utils.R")
snakemake@source("./utils.R")
# snakemake@source("./utils.R") # does not work when loaded as module (https://github.com/snakemake/snakemake/issues/2205)
source(snakemake@params[["utils_path"]])

# inputs
merged_object_path <- snakemake@input[["merged_object"]]
Expand Down

0 comments on commit 5390a26

Please sign in to comment.