Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions example/example.smk
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Binary file added example/results/supplemental_figure_combined.pdf
Binary file not shown.
Binary file added example/results/supplemental_figure_combined.png

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to have consistent label sizes, axes sizes, whitespace and margins across the subpanels, in line with fig4. PCA could also be A+B as they are 2 panels. cmap on B could also be improved.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/results/supplemental_figure_combined.tiff
Binary file not shown.
103 changes: 102 additions & 1 deletion example/rules/deeptools.smk
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ rule computeMatrix_chip:
shell:'''
computeMatrix {params.mattype} -p {threads} \
-S {params.bws} \
'results/supplemental_figure_combined.pdf',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

-o {output.mat} \
-bs {params.binsize} \
--missingDataAsZero \
Expand Down Expand Up @@ -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:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this'd encompass the full example, or at least the ChIPs instead of ATAC alone.

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),
Expand Down Expand Up @@ -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'
37 changes: 37 additions & 0 deletions example/rules/scripts/combined_supplemental_figure.py
Original file line number Diff line number Diff line change
@@ -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')
4 changes: 4 additions & 0 deletions figures/collate_figures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading