-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSnakefile
More file actions
152 lines (127 loc) · 4.75 KB
/
Copy pathSnakefile
File metadata and controls
152 lines (127 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
chromosomes = ["1", "2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","MT"]
accessions_numbers = ["SRR628582", "SRR628583", "SRR628584", "SRR628585", "SRR628586", "SRR628587", "SRR628588", "SRR628589"]
# Règle all :
rule all:
input:
"analysis_R/Analysis.Rdata"
# Télécharger les données SRA depuis le site internet NCBI
rule get_sra :
output :
"SRA_files/{sample}.sra"
threads : 8
shell :
" wget -O {output} https://sra-downloadb.be-md.ncbi.nlm.nih.gov/sos1/sra-pub-run-5/{wildcards.sample}/{wildcards.sample}.1"
# Convertir chaque fichier SRA en 2 fichiers fastq
rule conversion_sample_fastq:
input:
"SRA_files/{sample}.sra"
output:
"fastq_files/{sample}_1.fastq",
"fastq_files/{sample}_2.fastq"
singularity:
"docker://evolbioinfo/sratoolkit:v2.5.7"
threads:4
shell:
" fastq-dump --split-files ./{input} -O fastq_files"
# Télécharger les chromosomes du génome humain.
# on choisit de télecharger le génome de référence de réference GRCh38-release-101 (et non pas le release-104)
rule download_chromosome_sequence:
output:
"chr_files/{chr}.fa.gz"
threads: 8
shell:
"""
wget -O {output} ftp://ftp.ensembl.org/pub/release-101/fasta/homo_sapiens/dna/Homo_sapiens.GRCh38.dna.chromosome.{wildcards.chr}.fa.gz
"""
# Unziper les fichiers pour chaque chromosome de référence téléchargé et les concaténer en un seul fichier pour obtenir le génome humaine de réference : le fichier ref.fa
rule create_reference_file:
input:
expand("chr_files/{chr}.fa.gz", chr= chromosomes)
output:
"ref.fa"
shell:
"gunzip -c {input} > {output}"
# Indexer le génome humain de réference. On obtient en sortie un dossier ref_index avec l'ensemble des informations nécessaires
rule create_genome_index:
input:
"ref.fa"
output :
"ref_index/SA",
"ref_index/SAindex",
threads : 4
singularity :
"docker://evolbioinfo/star:v2.7.6a"
shell :
"""
STAR --runThreadN {threads} --runMode genomeGenerate --genomeDir ref_index/ --genomeSAindexNbases 6 --genomeFastaFiles {input}
"""
# Télécharger le génome annoté
rule get_annotations:
output:
genome_annot_zip = "annotations/human_genome_annotation.chr.gtf.gz",
genome_annot = "annotations/human_genome_annotation.chr.gtf"
shell:
"""
wget -O {output.genome_annot_zip} ftp://ftp.ensembl.org/pub/release-101/gtf/homo_sapiens/Homo_sapiens.GRCh38.101.chr.gtf.gz
gunzip -c {output.genome_annot_zip} > {output.genome_annot}
"""
# Mapper le génôme pour obtenir un fichier .bam
# Mettre les fichiers SA et SAindex en input pour forcer le Snakefile à aller jusqu'au bout et pas lancer le mapping avant que l'indexation soit terminée
rule star_mapping:
input:
fastq1 = "fastq_files/{sample}_1.fastq",
fastq2 = "fastq_files/{sample}_2.fastq",
genome_SA = "ref_index/SA",
genome_SAindex = "ref_index/SAindex"
output:
"mapping/{sample}.bam"
threads: 16
singularity:
"docker://evolbioinfo/star:v2.7.6a"
shell:
"""
STAR --outSAMstrandField intronMotif \
--outFilterMismatchNmax 4 \
--outFilterMultimapNmax 10 \
--genomeDir ref_index/ \
--readFilesIn {input.fastq1} {input.fastq2} \
--runThreadN {threads} \
--outSAMunmapped None \
--outSAMtype BAM SortedByCoordinate \
--outStd BAM_SortedByCoordinate \
--genomeLoad NoSharedMemory \
--limitBAMsortRAM 50000000000 \
> {output}
"""
# Convertir le fichier .bam en un fichier .bam.bai
rule samtool_index_mapping:
input:
"mapping/{sample}.bam"
output:
"mapping/{sample}.bam.bai"
singularity:
"docker://evolbioinfo/samtools:v1.11"
shell:
"samtools index mapping/{wildcards.sample}.bam"
# Comptage
rule feature_count:
input:
sample_mapping = "mapping/{sample}.bam",
genome_annotation = "annotations/human_genome_annotation.chr.gtf",
index = "mapping/{sample}.bam.bai"
output:
"result/{sample}.counts"
threads : 4
singularity:
"docker://evolbioinfo/subread:v2.0.1"
shell:
"featureCounts -T {threads} -t gene -g gene_id -s 0 -a {input.genome_annotation} -o {output} {input.sample_mapping}"
# Analyse statistique sur R et renvoyer une markdown de l'analyse
rule analyse_stat_R:
input:
expand("result/{sample}.counts", sample=accessions_numbers)
output:
"analysis_R/Analysis.Rdata"
singularity:"docker://evolbioinfo/deseq2:v1.28.1"
script:
"DESeq2.R"