diff --git a/workflow/Snakefile b/workflow/Snakefile index 0b32a9e..f889a8e 100644 --- a/workflow/Snakefile +++ b/workflow/Snakefile @@ -1,6 +1,6 @@ ##### global workflow dependencies ##### -conda: "envs/global.yaml" +# conda: "envs/global.yaml" ##### libraries ##### import os diff --git a/workflow/envs/inspectdf.yaml b/workflow/envs/inspectdf.yaml index e128239..22c6204 100644 --- a/workflow/envs/inspectdf.yaml +++ b/workflow/envs/inspectdf.yaml @@ -1,6 +1,6 @@ channels: - conda-forge - - defaults + - nodefaults dependencies: - r-inspectdf=0.0.12 - r-data.table=1.14.10 diff --git a/workflow/envs/seurat.yaml b/workflow/envs/seurat.yaml index 13354d3..94c2fd2 100644 --- a/workflow/envs/seurat.yaml +++ b/workflow/envs/seurat.yaml @@ -1,7 +1,7 @@ channels: - conda-forge - bioconda - - defaults + - nodefaults dependencies: - r-seurat=4.4.0 - bioconductor-glmgampoi=1.14.0 diff --git a/workflow/rules/normalize_correct_score.smk b/workflow/rules/normalize_correct_score.smk index 543ffbd..18e03c4 100644 --- a/workflow/rules/normalize_correct_score.smk +++ b/workflow/rules/normalize_correct_score.smk @@ -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" @@ -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" \ No newline at end of file diff --git a/workflow/rules/process.smk b/workflow/rules/process.smk index a2aed77..3daed8d 100644 --- a/workflow/rules/process.smk +++ b/workflow/rules/process.smk @@ -1,3 +1,4 @@ + # load & generate Seurat object per sample including metadata rule prepare: input: @@ -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" @@ -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" @@ -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) @@ -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" @@ -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) diff --git a/workflow/rules/visualize.smk b/workflow/rules/visualize.smk index d1c9a03..6cbb9b6 100644 --- a/workflow/rules/visualize.smk +++ b/workflow/rules/visualize.smk @@ -1,3 +1,4 @@ + # visualize metadata rule metadata_plots: input: @@ -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) @@ -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) diff --git a/workflow/scripts/filter.R b/workflow/scripts/filter.R index 010f3b5..ffcd942 100644 --- a/workflow/scripts/filter.R +++ b/workflow/scripts/filter.R @@ -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"]] diff --git a/workflow/scripts/merge.R b/workflow/scripts/merge.R index 0449aac..c626006 100644 --- a/workflow/scripts/merge.R +++ b/workflow/scripts/merge.R @@ -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 diff --git a/workflow/scripts/metadata_plot.R b/workflow/scripts/metadata_plot.R index 15bc44e..6cf1755 100644 --- a/workflow/scripts/metadata_plot.R +++ b/workflow/scripts/metadata_plot.R @@ -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"]] diff --git a/workflow/scripts/prepare.R b/workflow/scripts/prepare.R index 3604331..869fb10 100644 --- a/workflow/scripts/prepare.R +++ b/workflow/scripts/prepare.R @@ -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) { diff --git a/workflow/scripts/pseudobulk.R b/workflow/scripts/pseudobulk.R index e6fdb54..8a188fd 100644 --- a/workflow/scripts/pseudobulk.R +++ b/workflow/scripts/pseudobulk.R @@ -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) { diff --git a/workflow/scripts/sctransform_cellScore.R b/workflow/scripts/sctransform_cellScore.R index ca8883a..f606a34 100644 --- a/workflow/scripts/sctransform_cellScore.R +++ b/workflow/scripts/sctransform_cellScore.R @@ -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"]] diff --git a/workflow/scripts/seurat_plots.R b/workflow/scripts/seurat_plots.R index 90a1aca..76b6d3f 100644 --- a/workflow/scripts/seurat_plots.R +++ b/workflow/scripts/seurat_plots.R @@ -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"]] diff --git a/workflow/scripts/split.R b/workflow/scripts/split.R index 5e14d37..9106a2a 100644 --- a/workflow/scripts/split.R +++ b/workflow/scripts/split.R @@ -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"]]