diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d06bac5 --- /dev/null +++ b/Makefile @@ -0,0 +1,87 @@ +# To run everything: +# +# make +# +# For help running specific parts: +# +# make help + +# Overwritable paths to executables +CELLPROFILER := cellprofiler +PYTHON := python +RSCRIPT := Rscript + +# Make rule sources and targets +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 := $(SOURCES_cellprofiler_filelist) \ + $(SOURCES_cellprofiler_pipe) $(SOURCES_cellprofiler_img) +TARGETS_cellprofiler_db := results/cellprofiler/all-plates.db +TARGETS_cellprofiler_prop := results/cellprofiler/all-plates.properties +TARGETS_cellprofiler := $(TARGETS_cellprofiler_db) $(TARGETS_cellprofiler_prop) +define CELLPROFILER_OPTS +--pipeline=$(SOURCES_cellprofiler_pipe) \ +--file-list=$(SOURCES_cellprofiler_filelist) \ +--output-directory=$(dir $(TARGETS_cellprofiler_db)) +endef +SOURCES_signif_wells := $(TARGETS_cellprofiler_db) +TARGETS_signif_wells := results/tables/rnai-p_values.csv +SOURCES_plot_overlap := $(TARGETS_signif_wells) +TARGETS_plot_overlap := $(addsuffix results/plots/,) +SOURCES_plot_plates := $(TARGETS_signif_wells) +TARGETS_plot_plates := $(addsuffix results/plots/,) +TARGETS_plots := $(TARGETS_plot_overlap) $(TARGETS_plot_plates) + +.PHONY : all +all : z-projection cellprofiler 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. +$(TARGETS_cellprofiler) : $(SOURCES_cellprofiler) + $(CELLPROFILER) $(CELLPROFILER_OPTS) --run-headless + +.PHONY : gui-cellprofiler +gui-cellprofiler : $(SOURCES_cellprofiler) ## Interactively run CellProfiler. + $(CELLPROFILER) $(CELLPROFILER_OPTS) + +$(TARGETS_img_filelist) : $(abspath $(SOURCES_img_filelist)) + find $< -type f | sort > $@ + +.PHONY : plots +plots : $(TARGETS_plots) + +$(TARGETS_plot_overlap) : $(SOURCES_plot_overlap) + $(RSCRIPT) src/plots.R + +$(TARGETS_plot_plates) : $(SOURCES_plot_plates) + $(RSCRIPT) src/plot-plates.R + +.PHONY : clean-all +clean-all : ## Delete all output. + rm -rf $(TARGETS_img_raw) + rm -rf results/*