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)
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}
Write a snakemake rule using the custom R script (scripts/plot.R) to plot two vectors generated in the ex2.
Combine all rules into one pipeline, delete all before generated files and run the whole pipeline again specifying the final output.