fmi-basel/ggiorget_ms2analysis
None
Overview
Topics:
Latest release: None, Last update: 2024-11-14
Linting: linting: failed, Formatting:formatting: failed
Deployment
Step 1: Install Snakemake and Snakedeploy
Snakemake and Snakedeploy are best installed via the Mamba package manager (a drop-in replacement for conda). If you have neither Conda nor Mamba, it is recommended to install Miniforge. More details regarding Mamba can be found here.
When using Mamba, run
mamba create -c conda-forge -c bioconda --name snakemake snakemake snakedeploy
to install both Snakemake and Snakedeploy in an isolated environment. For all following commands ensure that this environment is activated via
conda activate snakemake
Step 2: Deploy workflow
With Snakemake and Snakedeploy installed, the workflow can be deployed as follows. First, create an appropriate project working directory on your system and enter it:
mkdir -p path/to/project-workdir
cd path/to/project-workdir
In all following steps, we will assume that you are inside of that directory. Then run
snakedeploy deploy-workflow https://github.com/fmi-basel/ggiorget_ms2analysis . --tag None
Snakedeploy will create two folders, workflow
and config
. The former contains the deployment of the chosen workflow as a Snakemake module, the latter contains configuration files which will be modified in the next step in order to configure the workflow to your needs.
Step 3: Configure workflow
To configure the workflow, adapt config/config.yml
to your needs following the instructions below.
Step 4: Run workflow
The deployment method is controlled using the --software-deployment-method
(short --sdm
) argument.
To run the workflow with automatic deployment of all required software via conda
/mamba
, use
snakemake --cores all --sdm conda
Snakemake will automatically detect the main Snakefile
in the workflow
subfolder and execute the workflow module that has been defined by the deployment in step 2.
For further options such as cluster and cloud execution, see the docs.
Step 5: Generate report
After finalizing your data analysis, you can automatically generate an interactive visual HTML report for inspection of results together with parameters and code inside of the browser using
snakemake --report report.zip
Configuration
The following section is imported from the workflow’s config/README.md
.
This project runs on Snakemake version 8.4.12. To install Snakemake, you can use Mambaforge. First create an environment and activate it:
mamba create -n snakemake
mamba activate snakemake
Then install Snakemake:
mamba install -c conda-forge -c bioconda snakemake=8.4.12
All other package dependencies are handles directly by Snakemake.
The snakemake workflow processes max- and mean-projections (xyt) from time-resolved 3D-stacks (xyzt). Before running the snakemake workflow, these projection files can be generated with scripts provided in the folder scripts.
MS2 data in form from *.nd files are processed as max-projections with the script max-proj_nd-as-tiff.py. One file corresponds to z-stack movies of several stage positions (direct output from the microscope).
python max-proj_nd-as-tiff.py path/to/images.nd path/to/outputfolder
GFP data in form of *.nd files are processed as mean-projections with the script mean-proj_nd-as-tiff.py. One file corresponds to single z-stacks of movie-corresponding stage positions.
python mean-proj_nd-as-tiff.py path/to/images.nd path/to/outputfolder
Output folder strcture should be as follows: data/processed/{date_of_aquisition}/proj/
To run the workflow, you need to provide a configuration file and a text file listing the samples to be processed (list of max-projections).
The text file should contain the sample names (one per line), end with the extension '_dataset_list.txt', and be located in the data folder. An example is given.
The configuration file should contain the following entries:
- movies_list: fill name of the text file containing the list of samples to be processed
- min_tracklength_segmentation: minimum length in frames a cell is visible
- min_cellsize_segmentation: minimum size in pixels a cell has to have
- spotdiameter: diameter of the spots in pixels for spot detection
- spotdetection_threshold: threshold for spot detection
- spotfilter_size_min: minimum size of the spot for filtering after spot detection
- spotfilter_size_max: maximum size of the spot for filtering after spot detection
- spotfilter_mass: maximum mass of the spot for filtering after spot detection
- min_burstlength: filter on the minimum length of a transcriptional on time
An example is provided in the config folder (example_config.yaml). If you rename the configuration file, make sure to adjust the name in the Snakefile.
To dry-run the workflow (-np), navigate to the root of this project and run the following command in the activated snakemake environment:
snakemake --use-conda --cores 1 -np
To run the pipeline, remove the -np flag:
snakemake --use-conda --cores 1
Linting and formatting
Linting results
Lints for rule aggregate_tracks (line 132, /tmp/tmp2psfwktg/workflow/Snakefile):
* Do not access input and output files individually by index in shell commands:
When individual access to input or output files is needed (i.e., just
writing '{input}' is impossible), use names ('{input.somename}') instead
of index based access.
Also see:
https://snakemake.readthedocs.io/en/latest/snakefiles/rules.html#rules
* No log directive defined:
Without a log directive, all output will be printed to the terminal. In
distributed environments, this means that errors are harder to discover.
In local environments, output of concurrent jobs will be mixed and become
unreadable.
Also see:
https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#log-files
* Specify a conda environment or container for each rule.:
This way, the used software for each specific step is documented, and the
workflow can be executed on any machine without prerequisites.
Also see:
https://snakemake.readthedocs.io/en/latest/snakefiles/deployment.html#integrated-package-management
https://snakemake.readthedocs.io/en/latest/snakefiles/deployment.html#running-jobs-in-containers
... (truncated)
Formatting results
[DEBUG]
[DEBUG] In file "/tmp/tmp2psfwktg/workflow/Snakefile": Formatted content is different from original
[INFO] 1 file(s) would be changed 😬
snakefmt version: 0.10.2