Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
rnai-screen-tf/Makefile
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
128 lines (111 sloc)
4.64 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To run everything: | |
# | |
# make | |
# | |
# For help running specific parts: | |
# | |
# make help | |
# Overwritable paths to executables | |
CELLPROFILER := cellprofiler | |
PARALLEL := parallel --eta | |
PYTHON := python | |
RSCRIPT := Rscript | |
TIME := command time --format "Completed in wall clock time [H:M:S]: %E" | |
# Make rule sources, targets and helper functions | |
SOURCES_img_raw := data/April_14_2016.tar.xz | |
TARGETS_img_raw := data/April_14_2016 | |
SOURCES_img_zproj := $(TARGETS_img_raw) | |
TARGETS_img_zproj := results/z_projection | |
SOURCES_img_filelist := $(TARGETS_img_zproj) | |
TARGETS_img_filelist := results/cellprofiler/filelist | |
SOURCES_cellprofiler_filelist := $(TARGETS_img_filelist) | |
SOURCES_cellprofiler_pipe := src/image-processing-pipeline.cpproj | |
SOURCES_cellprofiler_img := $(TARGETS_zproj) | |
SOURCES_cellprofiler_common := $(SOURCES_cellprofiler_filelist) \ | |
$(SOURCES_cellprofiler_img) | |
SOURCES_cellprofiler_gui := $(SOURCES_cellprofiler_common) \ | |
$(SOURCES_cellprofiler_pipe) | |
SOURCES_cellprofiler_batch := $(SOURCES_cellprofiler_common) | |
TARGETS_cellprofiler_batch := results/cellprofiler/Batch_data.h5 | |
SOURCES_cellprofiler_commands := $(TARGETS_cellprofiler_batch) | |
TARGETS_cellprofiler_commands := results/cellprofiler/batch_commands.sh | |
SOURCES_cellprofiler_headless := $(TARGETS_cellprofiler_commands) | |
TARGETS_cellprofiler_db := results/cellprofiler/rnai-screen-tf.db | |
TARGETS_cellprofiler_prop := $(TARGETS_cellprofiler_db:.db=.properties) | |
TARGETS_cellprofiler := $(TARGETS_cellprofiler_db) $(TARGETS_cellprofiler_prop) | |
define CELLPROFILER_OPTS_COMMON | |
--file-list=$(SOURCES_cellprofiler_filelist) \ | |
--output-directory=$(dir $(TARGETS_cellprofiler_db)) | |
endef | |
define CELLPROFILER_OPTS_GUI | |
$(CELLPROFILER_OPTS_COMMON) \ | |
--pipeline=$(SOURCES_cellprofiler_pipe) | |
endef | |
define CELLPROFILER_OPTS_BATCH | |
$(CELLPROFILER_OPTS_COMMON) \ | |
--pipeline=$(SOURCES_cellprofiler_pipe) \ | |
--run-headless | |
endef | |
define CELLPROFILER_OPTS_HEADLESS | |
$(CELLPROFILER_OPTS_COMMON) \ | |
--pipeline=$(SOURCES_cellprofiler_commands) \ | |
--run-headless | |
endef | |
SOURCES_signif_wells := src/overlap-analysis.R $(TARGETS_cellprofiler_db) | |
TARGETS_signif_wells := results/tables/rnai-p_values.csv | |
SOURCES_plot_overlap := src/plots.R $(TARGETS_signif_wells) | |
TARGETS_plot_overlap := results/plots/rnai-hist-signif.png | |
SOURCES_plot_plates := src/plot-plates.R $(TARGETS_signif_wells) | |
TARGETS_plot_plates := results/plots/stddev-scatter.png | |
TARGETS_plots := $(TARGETS_plot_overlap) $(TARGETS_plot_plates) | |
# Functions | |
# | |
# Hack of single rule invocation for multiple targets by substituting | |
# file extension "." with "%" per http://stackoverflow.com/a/3077254 | |
define singleton | |
$(foreach path,$1,$(shell echo -n $(path) | sed 's#\(.*\)\.#\1%##')) | |
endef | |
.PHONY : all | |
all : z-projection cellprofiler stats plots ## (Default) Run full pipeline from image processing to plots. | |
# Self-documenting help modified from | |
# https://gist.github.com/prwhite/8168133#gistcomment-1737630 | |
.PHONY : help | |
help : ## Show this help. | |
@echo -e 'Usage: make [TARGET] ...\n\nTargets:' | |
@sed -nE 's|^(\S+)[^#]+##(.+)|\1\t\2|p' $(MAKEFILE_LIST) | column -t -s ' ' | |
# More robust would be to associate individual target TIF files | |
# contained in the tarball, but reading the archive takes a long time | |
# and adds overhead to Makefile processing. | |
$(TARGTS_img_raw) : $(SOURCES_img_raw) | |
cd data; tar -xvJpf $< | |
.PHONY : z-projection | |
z-projection : $(TARGETS_img_zproj) ## Generate maximum intensity projection images. | |
$(TARGETS_img_zproj) : $(SOURCES_img_zproj) | |
$(PYTHON) src/image_preprocessing_z_projection.py $< $@ | |
.PHONY : cellprofiler | |
cellprofiler : $(TARGETS_cellprofiler) ## Collect statistics about all images. | |
$(call singleton,$(TARGETS_cellprofiler)) : $(SOURCES_cellprofiler_headless) | |
$(TIME) $(PARALLEL) :::: $< | |
$(TARGETS_cellprofiler_commands) : $(SOURCES_cellprofiler_commands) | |
$(CELLPROFILER) $(CELLPROFILER_OPTS_HEADLESS) --get-batch-commands=$< | sed 's#^CellProfiler#$(CELLPROFILER)#' | sort -nk 8 > $@ | |
$(TARGETS_cellprofiler_batch) : $(SOURCES_cellprofiler) | |
$(CELLPROFILER) $(CELLPROFILER_OPTS_BATCH) | |
.PHONY : gui-cellprofiler | |
gui-cellprofiler : $(SOURCES_cellprofiler) ## Interactively run CellProfiler. | |
$(CELLPROFILER) $(CELLPROFILER_OPTS_GUI) | |
$(TARGETS_img_filelist) : $(abspath $(SOURCES_img_filelist)) | |
find $< -type f | sort > $@ | |
.PHONY : stats | |
stats : $(TARGETS_signif_wells) ## Find significant wells from cellprofiler measurements. | |
$(TARGETS_signif_wells) : $(SOURCES_signif_wells) | |
cd $(<D); $(RSCRIPT) $(<F) | |
.PHONY : plots | |
plots : $(TARGETS_plots) | |
$(TARGETS_plot_overlap) : $(SOURCES_plot_overlap) | |
cd $(<D); $(RSCRIPT) $(<F) | |
$(TARGETS_plot_plates) : $(SOURCES_plot_plates) | |
cd $(<D); $(RSCRIPT) $(<F) | |
.PHONY : clean-all | |
clean-all : ## Delete all output. | |
rm -rf $(TARGETS_img_raw) | |
rm -rf results/* |