Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move R code away from snakemake files #6

Open
eudesbarbosa opened this issue Jun 4, 2021 · 0 comments
Open

Move R code away from snakemake files #6

eudesbarbosa opened this issue Jun 4, 2021 · 0 comments
Assignees

Comments

@eudesbarbosa
Copy link
Member

Issue
R code is kept in the Snakemake files and directly take variables from it. For example, rule filter in DE_pipeline. Snakemake:

rule filter:
	""" filter experiment & genes before normalisation, based on counts and/or GTF property"""
	input:
		...
	run:
		config_file = pph.file_path(step="pipeline_report", extension="yaml", contrast="all")
		script = textwrap.dedent(r"""
		#----- import packages
		library(DESeq2)
		library(AnnotationDbi)

		{R_SESSION_INFO}

		conf.f   <- "{config_file}"

		#----- load config
		config <- yaml::yaml.load_file(conf.f)

		#----- read counts in dds format
		dds <- readRDS("{input.rds}")
		sample_df <- as.data.frame(SummarizedExperiment::colData(dds))
		rownames(sample_df) <- as.character(sample_df$label)
		...

Possible solution
Isolate all R code on specific files, the location can be accessed via config, for instance. Structure the code in a way that is possible to pass the Snakemake variables as arguments (silly example). Once the code is isolated it should be easier to stablish unit tests for all of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants