dge_star_template.sh 4.4 KB
Newer Older
Holger Brandl's avatar
Holger Brandl committed
1
2
# TODO  define project name
export project="TODO  define project name"
Holger Brandl's avatar
Holger Brandl committed
3
# screen -R ${project}
Holger Brandl's avatar
Holger Brandl committed
4
5
6


## madmax
Holger Brandl's avatar
Holger Brandl committed
7
if [ "$HOSTNAME"=="falcon1" ]; then
Holger Brandl's avatar
Holger Brandl committed
8
9
    export baseDir="/projects/bioinfo/holger/projects/${project}"
    export PROJECT_SCRIPTS="/projects/bioinfo/holger/scripts/${project}"
10
    export NGS_TOOLS="/projects/bioinfo/scripts/ngs_tools/dev"
Holger Brandl's avatar
Holger Brandl committed
11
12
13
14
fi

## bioinfo
if [ $(hostname) == "bioinformatics-srv1" ]; then
Holger Brandl's avatar
Holger Brandl committed
15
16
17
    export baseDir=/net/mack/lustre/projects/bioinfo/holger/projects/${project}
    export PROJECT_SCRIPTS==/net/mack/lustre/projects/bioinfo/holger/scripts/${project}
    export NGS_TOOLS=/net/mack/lustre/projects/bioinfo/scripts/ngs_tools/dev
Holger Brandl's avatar
Holger Brandl committed
18
19
20
21
22
23
24
fi


source ${NGS_TOOLS}/dge_workflow/dge_utils.sh
export PATH=${NGS_TOOLS}/dge_workflow:$PATH


Holger Brandl's avatar
Holger Brandl committed
25
## TODO define igenome to be used
Holger Brandl's avatar
Holger Brandl committed
26
## igenome=/projects/bioinfo/igenomes/Canis_familiaris/Ensembl/CanFam3.1
Holger Brandl's avatar
Holger Brandl committed
27
#igenome=<<<<TBD>>>>
Holger Brandl's avatar
Holger Brandl committed
28
29
30
31

########################################################################################################################
### Fetch the data

Holger Brandl's avatar
Holger Brandl committed
32
mcdir ${baseDir}/originals
Holger Brandl's avatar
Holger Brandl committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

wget -nc --user="USER" --password="PW"  -r --no-directories  --no-check-certificate -A "*fastq.gz" https:/projects.biotec.tu-dresden.de/ngs-filesharing/martaf/

mailme "$project: fastq download done"

### Basic QC
dge_fastqc $(ls *fastq.gz) &

## todo make sure to also copy the sample sheet in here

########################################################################################################################
### Apply renaming and merge lane replicates (but keep technical ones)

## todo adjust renaming scheme to project specifics

mcdir $baseDir/lanereps_pooled

echo '
51
devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v1.36/R/core_commons.R")
Holger Brandl's avatar
Holger Brandl committed
52
53
54

sheetFile <- "../originals/natalied-FC_SN678_338-2015-5-12.xls"

55
sampleSheet <- read_excel(sheetFile, "Fastqfiles") %>%
Holger Brandl's avatar
Holger Brandl committed
56
57
58
    select(File, SampleName) %>%
    mutate(
        bio_replicate=str_match(SampleName, "(.).*")[,2],
59
        sample = str_replace(SampleName, "[0-9]*", "") %>% str_replace_all(c("NC" = "no_culture", "NA" = "no_hormone", "ECD"="ecdysone_", "INS"="insulin_", "9"="9h", "4"="4h")),
Holger Brandl's avatar
Holger Brandl committed
60
61
62
        bio_sample=paste(sample, bio_replicate, sep="_")
    )

63
write_tsv(sampleSheet, path="renaming_scheme.txt")
Holger Brandl's avatar
Holger Brandl committed
64

65
66
require(ggplot2)
ggplot(sampleSheet, aes(bio_sample)) + geom_bar() + coord_flip()
Holger Brandl's avatar
Holger Brandl committed
67
68

sampleSheet %>% group_by(bio_sample) %>% summarise(
Holger Brandl's avatar
Holger Brandl committed
69
70
71
72
        zcat=paste("zcat", paste(paste0("../originals/", File), collapse=" "), "| gzip -c >", paste0(bio_sample[1], ".fastq.gz"))
    ) %$%
    zcat %>%
    write_lines("lane_merge.cmd")
Holger Brandl's avatar
Holger Brandl committed
73
74
75
' | R --vanilla -q

cat lane_merge.cmd | while read line; do
Holger Brandl's avatar
Holger Brandl committed
76
#    eval ${line}
77
    jl submit -j .repmerge "$line"
Holger Brandl's avatar
Holger Brandl committed
78
79
done

80
jl wait --email --report
Holger Brandl's avatar
Holger Brandl committed
81
82
83
84
85
86
87
88
89

dge_fastqc $(ls *fastq.gz) &


########################################################################################################################
### Alignment the reads

mcdir $baseDir/alignments

Holger Brandl's avatar
Holger Brandl committed
90
star_align.kts ${igenome} $(ls ${baseDir}/lanereps_pooled/*.fastq.gz)
Holger Brandl's avatar
Holger Brandl committed
91

92
#dge_bam_correlate . & # part of star_align.kts now
Holger Brandl's avatar
Holger Brandl committed
93
94
95

mailme "$project: mapping done"

Holger Brandl's avatar
Holger Brandl committed
96
97
98
99
100
101
102

########################################################################################################################
### Differential Expression Analysis


mcdir $baseDir/dge_analysis

Holger Brandl's avatar
Holger Brandl committed
103
rend.R -e ${NGS_TOOLS}/dge_workflow/featcounts_deseq.R ../alignments/star_counts_matrix.txt  2>&1  | tee featcounts_deseq.log
Holger Brandl's avatar
Holger Brandl committed
104
105
106
107
108
109
110
111


## or use just some contrasts of interest
#echo "
#sample_1, sample_2
#unpolarised,liver_polar_stage3
#" | csvformat -T  > contrasts.txt
#
112
#rend.R -e $NGS_TOOLS/dge_workflow/featcounts_deseq.R --contrasts contrasts.txt ../alignments/star_counts_matrix.txt  2>&1  | tee featcounts_deseq.log
Holger Brandl's avatar
Holger Brandl committed
113
114
115


## Term enrichment
Holger Brandl's avatar
Holger Brandl committed
116
mcdir ${baseDir}/dge_analysis/dge_enrichment_analysis
Holger Brandl's avatar
Holger Brandl committed
117
$NGS_TOOLS/common/cp_enrichment.R --overlay_expr_data ../plot_score_matrix.txt ../degs_by_contrast.txt contrast
Holger Brandl's avatar
Holger Brandl committed
118
rend.R -e ${NGS_TOOLS}/common/cp_enrichment.R --overlay_expr_data ../plot_score_matrix.txt ../degs_by_contrast.txt contrast
Holger Brandl's avatar
Holger Brandl committed
119
120
121
122
123
124
125


########################################################################################################################
### Sync back to project space

## bidirectional sync with project space
## todo define mount path on bioinfo for bidirectional synching
126
## ~/bin/unison $baseDir ssh://bioinfo///home/brandl/mnt/<<MOUNT_PATH>> -fastcheck true -times -perms 0
Holger Brandl's avatar
Holger Brandl committed
127

128
# or use a uni-directional sync
Holger Brandl's avatar
Holger Brandl committed
129
#rsync -avsn --delete  ${baseDir} brandl@fileserver:/projects//file/server/path
Holger Brandl's avatar
Holger Brandl committed
130
mailme "$project: sync done"