snakemake

Snakemake expand on a dictionary, keeping wildcards

Snakemake expand on a dictionary, keeping wildcards Question: I have a dictionary like the following: data = { "group1": ["a", "b", "c"], "group2": ["x", "y", "z"] } I want to use expand to get all combinations between the keys and their values separately in "rule all", s.t. the expected output files are e.g. "group1/a.txt", "group1/b.txt", …

Total answers: 4

Running snakefile from directory that doesn't contain snakefile

Running snakefile from directory that doesn't contain snakefile Question: I’m writing a pipeline that creates a snakefile in child directory. The general structure looks like this. > snakemake_pipeline.py > runs/ > run1/ > Snakefile > … (all other necessary files for snakemake to run) So, each time I run snakemake_pipeline.py a new directory is created …

Total answers: 1

Generic input functions for Snakemake

Generic input functions for Snakemake Question: I am using input functions in my Snakemake rules. Most of these rules simply look up a sample sheet (pandas data frame) derived from the PEP specifications. For example .. samples = pep.sample_table def get_image(wildcards): return samples.loc[wildcards.sample, "image_file"] def get_visium_fastqs(wildcards): return samples.loc[wildcards.sample, "visium_fastqs"] def get_slide(wildcards): return samples.loc[wildcards.sample, "slide"] def …

Total answers: 2

How to rename files with snakemake with a dictionary in config file?

How to rename files with snakemake with a dictionary in config file? Question: I currently have the issue of renaming some files with snakemake based on pattern matching with help of a dictionary in the config file. The input wildcard does not match the output wildcard any more afterwards. The data follow this structure: . …

Total answers: 1

Target rules may not contain wildcards. Please specify concrete files or a rule without wildcards error

Target rules may not contain wildcards. Please specify concrete files or a rule without wildcards error Question: I have a snakemake srcipt like # minimal example configfile: "../snakemake/config.yaml" import os rule generateInclude: input: archaic_inc=config[‘input’][‘archaic_include’], modern_inc=config[‘input’][‘modern_include’] output: all_include=’include_{reference_genome}.bed’ params: reference_genome='{reference_genome}’ shell: """ if [ {params.reference_genome}==’hg19′ ]; then bedtools intersect -a <(zcat {input.archaic_inc} | sed ‘s/^chr//’) -b …

Total answers: 1

How to reference input in params section of snakemake rule?

How to reference input in params section of snakemake rule? Question: I need to process my input file values, turning them into a comma-separated string (instead of white space) in order to pass them to a CLI program. To do this, I want to run the input files through a Python function. How can I …

Total answers: 1

Run short python code directly on snakemake

Run short python code directly on snakemake Question: I have a snakemake pipeline where I need to do a small step of processing the data (applying a rolling average to a dataframe). I would like to write something like this: rule average_df: input: # script = , df_raw = "{sample}_raw.csv" params: window = 83 output: …

Total answers: 2

Snakemake | Creating an aggregate without specifying a list in expand

Snakemake | Creating an aggregate without specifying a list in expand Question: My directory structure looks like this: — path — parameter_combination_1 – time_average.property1.csv – time_average.property2.csv – … — parameter_combination_2 – time_average.property1.csv – time_average.property2.csv – … — … I would like to create a rule which aggregates information of all files which carry the time_average …

Total answers: 2

Snakemake doesn't activate conda environment correctly

Snakemake doesn't activate conda environment correctly Question: I have a Python module modulename installed in a conda environment called myenvname. My snakemake file consists of one simple rule: rule checker2: output: "tata.txt" conda: "myenvname" script: "scripts/test2.py" The contents of the test2.py are the following: import modulename with open("tata.txt","w") as _f: _f.write(modulename.__version__) When I run the …

Total answers: 1