GRAVI: Gene Regulatory Analysis using Variable Inputs

public public 1yr ago 0 bookmarks

This is a snakemake workflow for:

  1. Performing sample QC

  2. Calling ChIP peaks

  3. Performing Differential Binding Analysis

  4. Comparing results across ChIP targets

Code Snippets

26
27
28
29
shell:
	"""
	Rscript --vanilla {input.r} {params.annot_path} &>> {log}
	"""
59
60
61
62
63
shell:
    """
    cp {input.rmd} {output.rmd}
    R -e "rmarkdown::render_site('{output.rmd}')" &>> {log}
    """
13
14
15
16
17
18
19
20
21
22
23
24
shell:
    """
    ## Sort the file
    echo -e "Started sorting at $(date)" >> {log}
    sort \
      -k1,1 -k2,2n \
      -S {resources.mem_mb}M \
      --parallel {threads} \
      {input} | \
      egrep $'^chr[0-9XY]+\t' > {output}
    echo -e "Finished sorting at $(date)" >> {log}
    """	
41
42
43
44
45
46
shell:
    """
    echo -e "Started conversion at $(date)" >> {log}
    bedGraphToBigWig {input.bedgraph} {input.chrom_sizes} {output.bigwig}
    echo -e "Finished conversion at $(date)" >> {log}
    """
60
61
62
63
64
65
66
67
shell:
    """
    ## Create the summary tsv
    Rscript --vanilla \
        {params.script} \
        {input.bw} \
        {output} &>> {log}
    """
14
15
16
17
18
19
20
21
shell:
	"""
	Rscript --vanilla \
		{input.r} \
		{input.bam} \
		{input.seqinfo} \
		{output.bed} &>> {log}
	"""
49
50
51
52
53
54
55
56
57
58
59
60
61
62
shell:
	"""
	## Create the generic markdown header
	Rscript --vanilla \
		{input.r} \
		{wildcards.target} \
		{wildcards.ref} \
		{wildcards.treat} \
		{params.threads} \
		{output.rmd} &>> {log}

	## Add the remainder of the module as literal text
	cat {input.db_mod} >> {output.rmd}
	"""
172
173
174
175
shell:
	"""
	R -e "rmarkdown::render_site('{input.rmd}')" &>> {log}
	"""
62
63
64
65
66
67
68
69
70
71
72
73
74
75
shell:
    """
    macs2 callpeak \
        -t {input.bam}\
        -c {input.control[0]} \
        -f BAM \
        -g {params.gsize} \
        --keep-dup {params.keep_duplicates} \
        -q {params.fdr} \
        -n {params.prefix} \
        --bdg --SPMR \
        --outdir {params.outdir} 2> {log}
    cp {log} {output.log}
    """
105
106
107
108
109
110
111
112
shell:
    """
    ## Run the QC script
    Rscript --vanilla \
        {input.r} \
        {wildcards.target} \
        {threads} &>> {log}
    """
SnakeMake From line 105 of rules/macs2.smk
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
shell:
    """
    QC_PASS=$(egrep 'pass' {input.qc} | egrep {wildcards.treat} | cut -f1)
    SAMPLES=$(for f in $QC_PASS; do echo {params.bamdir}/$f.bam; done)

    ## Get the input column
    I=$(head -n1 {input.qc} | sed -r 's/\\t/\\n/g' | egrep -n '[Ii]nput' | sed -r 's/([0-9]+):[Ii]nput/\\1/g')
    INPUT_PASS=$(egrep 'pass$' {input.qc} | egrep "{wildcards.treat}\s" | cut -f$I | uniq)
    INPUT=$(for f in $INPUT_PASS; do echo {params.bamdir}/$f.bam; done)

    macs2 callpeak \
        -t $SAMPLES\
        -c $INPUT \
        -f BAM \
        -g {params.gsize} \
        --keep-dup {params.keep_duplicates} \
        -q {params.fdr} \
        -n {params.prefix} \
        --bdg --SPMR \
        --outdir {params.outdir} 2> {log}
    cp {log} {output.log}
    """
193
194
195
196
197
198
199
200
shell:
    """
    macs2 bdgcmp \
        -t {input.bdg} \
        -c {input.ctrl} \
        -m FE \
        -o {output} 2> {log}
    """		
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
	shell:
		"""
		## Create the generic markdown header
        Rscript --vanilla \
            {input.r} \
            {wildcards.t1} \
            {wildcards.ref1} \
            {wildcards.treat1} \
			{wildcards.t2} \
            {wildcards.ref2} \
            {wildcards.treat2} \
            {params.threads} \
            {output.rmd} &>> {log}

        ## Add the remainder of the module as literal text
        cat {input.module_pw} >> {output.rmd}
		"""
101
102
103
104
	shell:
		"""
        R -e "rmarkdown::render_site('{input.rmd}')" &>> {log}
		"""
 9
10
11
12
shell:
    """
    Rscript --vanilla {input} {output} {params.version} &>> {log}
    """
24
25
26
27
shell:
    """
    Rscript --vanilla {input.r} {output} &>> {log}
    """
39
40
41
42
shell:
    """
    Rscript --vanilla {input.r} {output.rmd} &>> {log}
    """
51
52
53
54
shell:
    """
    cat {input} > {output}
    """
70
71
72
73
shell:
    """
    R -e "rmarkdown::render_site('{input.rmd}')" &>> {log}
    """
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
shell:
	"""
	## Create the generic markdown
	Rscript --vanilla \
		{input.r} \
		{wildcards.target} \
		{params.threads} \
		{output.rmd} &>> {log}

	## Add the module directly as literal code
	cat {input.module} >> {output.rmd}
	"""
168
169
170
171
shell:
	"""
	R -e "rmarkdown::render_site('{input.rmd}')" &>> {log}
	"""
 8
 9
10
11
shell:
	"""
	samtools index -@ {threads} {input.bam} {output.bai}
	"""
ShowHide 19 more snippets with no or duplicated tags.

Login to post a comment if you would like to share your experience with this workflow.

Do you know this workflow well? If so, you can request seller status , and start supporting this workflow.

Free

Created: 1yr ago
Updated: 1yr ago
Maitainers: public
URL: https://smped.github.io/GRAVI_PRJNA509779/
Name: gravi_prjna509779
Version: 1
Badge:
workflow icon

Insert copied code into your website to add a link to this workflow.

Downloaded: 0
Copyright: Public Domain
License: None
  • Future updates

Related Workflows

cellranger-snakemake-gke
snakemake workflow to run cellranger on a given bucket using gke.
A Snakemake workflow for running cellranger on a given bucket using Google Kubernetes Engine. The usage of this workflow ...