Skip to content

ahryhorzhevska/mpip_cc_smk_tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

0640d54 · Apr 12, 2022

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Club: Gentle Introduction to Snakemake

Exercises

Exercise ex1:

Write a Snakemake rule generate_data using Python language to generate two vectors of random numbers of size 100 and save each vector to a separate text file: x.txt and y.txt.

Hint 1. Import numpy library

import numpy as np

Hint 2. Define the names of the output files before the rules

file_ids = ['x', 'y']

Hint 3. Use special Snakemake function to create a list of output filenames from a pattern (for example, in the rule all)

expand("data/{file}.txt", file = file_ids)

Exercise ex2:

Write a snakemake rule subset_data using shell to create two subsets from the generated files, so that each new file will contain the value less or equal to 0.5. Save each new generated vector to a separate text file: x_subset.txt and y_subset.txt.

Hint 1. Use the awk shell command to subset the data and > to redirect the output:

awk ‘$1 <= 0.5’ {input} > {output}

Exercise ex3:

Write a snakemake rule using the custom R script (scripts/plot.R) to plot two vectors generated in the ex2.


Exercise ex4:

Combine all rules into one pipeline, delete all before generated files and run the whole pipeline again specifying the final output.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published