Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ENH: Run project with single make command (in progress)
  • Loading branch information
pan14001 committed Mar 17, 2017
1 parent 8ac6e83 commit 95df9f4
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions 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/*

0 comments on commit 95df9f4

Please sign in to comment.