diff --git a/example/example.smk b/example/example.smk index 467b285..e05fa5d 100644 --- a/example/example.smk +++ b/example/example.smk @@ -105,5 +105,8 @@ rule all: 'results/figure_combined.pdf', 'results/figure_combined.png', 'results/figure_combined.tiff', + 'results/supplemental_figure_combined.pdf', + 'results/supplemental_figure_combined.png', + 'results/supplemental_figure_combined.tiff', # Sample information 'results/sample_stats.tsv' diff --git a/example/results/supplemental_figure_combined.pdf b/example/results/supplemental_figure_combined.pdf new file mode 100644 index 0000000..d84dee5 Binary files /dev/null and b/example/results/supplemental_figure_combined.pdf differ diff --git a/example/results/supplemental_figure_combined.png b/example/results/supplemental_figure_combined.png new file mode 100644 index 0000000..955acb6 Binary files /dev/null and b/example/results/supplemental_figure_combined.png differ diff --git a/example/results/supplemental_figure_combined.tiff b/example/results/supplemental_figure_combined.tiff new file mode 100644 index 0000000..6c52631 Binary files /dev/null and b/example/results/supplemental_figure_combined.tiff differ diff --git a/example/rules/deeptools.smk b/example/rules/deeptools.smk index 1be743d..5531d4c 100644 --- a/example/rules/deeptools.smk +++ b/example/rules/deeptools.smk @@ -95,6 +95,7 @@ rule computeMatrix_chip: shell:''' computeMatrix {params.mattype} -p {threads} \ -S {params.bws} \ + 'results/supplemental_figure_combined.pdf', -o {output.mat} \ -bs {params.binsize} \ --missingDataAsZero \ @@ -156,13 +157,98 @@ rule plotHeatmap_atac: runtime = 1440 shell:''' plotHeatmap -m {input.mat} -out {output.png} \ - --startLabel "\\-5kb" --endLabel "\\+5kb" --colorMap Reds \ + --startLabel "\\-5kb" \ + --endLabel "\\+5kb" \ + --colorMap Reds \ --xAxisLabel "" \ --interpolationMethod bilinear \ --regionsLabel up down non-de \ --whatToShow "heatmap and colorbar" ''' +rule multiBigwigSummary_ATAC: + input: + bw = expand('results/atac/{atacsample}.bw', atacsample=ATACSAMPLES) + output: + npz = 'results/atac_summ.npz' + threads: 10 + params: + labels = lambda wildcards, input: ' '.join( [i.split('_')[2] + '-' + i.split('_')[4] for i in input.bw] ) + resources: + mem_mb = 8000, + runtime = 1440 + shell:''' + multiBigwigSummary bins \ + -p {threads} \ + -o {output.npz} \ + -b {input.bw} \ + --labels {params.labels} + ''' + +rule plotPCA_ATAC: + input: + mat = 'results/atac_summ.npz' + output: + png = 'results/atac_pca.png' + resources: + mem_mb = 4000, + runtime = 1440 + shell:''' + plotPCA \ + -in {input.mat} \ + -o {output.png} \ + --colors blue blue red red \ + --plotWidth 6 \ + --plotHeight 12 \ + --addLabels + ''' + +rule plotCorrelation_ATAC: + input: + mat = 'results/atac_summ.npz' + output: + png = 'results/atac_correlation.png' + resources: + mem_mb = 4000, + runtime = 1440 + shell:''' + plotCorrelation \ + -in {input.mat} \ + -o {output.png} \ + --corMethod pearson \ + --whatToPlot heatmap \ + --colorMap RdYlBu \ + --plotNumbers \ + --skipZeros \ + --plotWidth 6 \ + --plotHeight 6 + ''' + +rule plotEnrichment_ATAC: + input: + bams = expand('deeptools_input/{atacsample}.bam', atacsample=ATACSAMPLES), + bed = 'deeptools_input/upreg_ATAC.bed' + output: + png = 'results/atac_enrichment.png' + params: + labels = lambda wildcards, input: ' '.join( [i.split('_')[2] + '-' + i.split('_')[4] for i in input.bams] ) + threads: 10 + resources: + mem_mb = 4000, + runtime = 1440 + shell:''' + plotEnrichment \ + -p {threads} \ + -b {input.bams} \ + -o {output.png} \ + --BED {input.bed} \ + --labels {params.labels} \ + --colors blue blue red red \ + --plotWidth 6 \ + --plotHeight 6 \ + --variableScales + ''' + rule computeMatrix_meth: input: bw = expand('deeptools_input/{bssample}_CpG.bw', bssample=BSSAMPLES), @@ -225,3 +311,18 @@ rule combine_figure: runtime = 60 script: 'scripts/combined_figure.py' + +rule combine_supplemental_figure: + input: + atac_pca = 'results/atac_pca.png', + atac_corr = 'results/atac_correlation.png', + atac_enrich = 'results/atac_enrichment.png' + output: + pdf = 'results/supplemental_figure_combined.pdf', + png = 'results/supplemental_figure_combined.png', + tiff = 'results/supplemental_figure_combined.tiff' + resources: + mem_mb = 4000, + runtime = 60 + script: + 'scripts/combined_supplemental_figure.py' \ No newline at end of file diff --git a/example/rules/scripts/combined_supplemental_figure.py b/example/rules/scripts/combined_supplemental_figure.py new file mode 100644 index 0000000..c60c16d --- /dev/null +++ b/example/rules/scripts/combined_supplemental_figure.py @@ -0,0 +1,37 @@ +# Script to combine the 3 ATAC supplemental figures into a single figure + +import matplotlib.pyplot as plt +import matplotlib.image as mpimg + +# Section 1: Read the images +fig1 = mpimg.imread('results/atac_pca.png') +fig2 = mpimg.imread('results/atac_correlation.png') +fig3 = mpimg.imread('results/atac_enrichment.png') + + +# Section 2: Create a new figure and add subplots +# Plot 1 +ax1 = plt.subplot2grid((2, 2), (0, 0), rowspan=2) +ax1.imshow(fig1) + +# Plot 2 +ax2 = plt.subplot2grid((2, 2), (0, 1), colspan=1) +ax2.imshow(fig2) + +# Plot 3 +ax3 = plt.subplot2grid((2, 2), (1, 1), colspan=1) +ax3.imshow(fig3) + +# Add titles to each subplot +ax1.set_title('A', loc='left') +ax2.set_title('B', loc='left') +ax3.set_title('C', loc='left') + +# remove axes for all subplots +for ax in [ax1, ax2, ax3]: + ax.axis('off') + +# save the combined figure +plt.savefig('results/supplemental_figure_combined.png', dpi=300, bbox_inches='tight') +plt.savefig('results/supplemental_figure_combined.pdf', dpi=300, bbox_inches='tight') +plt.savefig('results/supplemental_figure_combined.tiff', dpi=300, bbox_inches='tight') \ No newline at end of file diff --git a/figures/collate_figures.sh b/figures/collate_figures.sh index d780425..28c2994 100644 --- a/figures/collate_figures.sh +++ b/figures/collate_figures.sh @@ -17,3 +17,7 @@ cp "$SCRIPT_DIR/../benchmark/results/performance.pdf" "$SCRIPT_DIR/figure2.pdf" ## Figure 4 - example (generated before, results committed to repo)cp cp "$SCRIPT_DIR/../example/results/figure_combined.png" "$SCRIPT_DIR/figure4.png" cp "$SCRIPT_DIR/../example/results/figure_combined.pdf" "$SCRIPT_DIR/figure4.pdf" + +## Supp. Figure - supplemental figure (generated before, results committed to repo) +cp "$SCRIPT_DIR/../example/results/supplemental_figure_combined.png" "$SCRIPT_DIR/supp_figure1.png" +cp "$SCRIPT_DIR/../example/results/supplemental_figure_combined.pdf" "$SCRIPT_DIR/supp_figure1.pdf"