README.md 5.97 KB
Newer Older
Midoux Cedric's avatar
Midoux Cedric committed
1
2
# DIGESTOMIC

Midoux Cedric's avatar
Midoux Cedric committed
3
4
5
## link to DATA

```bash
Midoux Cedric's avatar
Midoux Cedric committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J177_A_02_03_16_S3_all_R1_001.fastq.gz DATA/raw/J177_A_R1.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J177_A_02_03_16_S3_all_R2_001.fastq.gz DATA/raw/J177_A_R2.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J177_B_02_03_16_S4_all_R1_001.fastq.gz DATA/raw/J177_B_R1.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J177_B_02_03_16_S4_all_R2_001.fastq.gz DATA/raw/J177_B_R2.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J218_A_120416_S5_all_R1_001.fastq.gz DATA/raw/J218_A_R1.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J218_A_120416_S5_all_R2_001.fastq.gz DATA/raw/J218_A_R2.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J218_B_120416_S6_all_R1_001.fastq.gz DATA/raw/J218_B_R1.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J218_B_120416_S6_all_R2_001.fastq.gz DATA/raw/J218_B_R2.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J281_A_140616_S1_all_R1_001.fastq.gz DATA/raw/J281_A_R1.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J281_A_140616_S1_all_R2_001.fastq.gz DATA/raw/J281_A_R2.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J281_B_140616_S2_all_R1_001.fastq.gz DATA/raw/J281_B_R1.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J281_B_140616_S2_all_R2_001.fastq.gz DATA/raw/J281_B_R2.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J462_A_121216_S3_all_R1_001.fastq.gz DATA/raw/J462_A_R1.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J462_A_121216_S3_all_R2_001.fastq.gz DATA/raw/J462_A_R2.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J462_B_121216_S4_all_R1_001.fastq.gz DATA/raw/J462_B_R1.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J462_B_121216_S4_all_R2_001.fastq.gz DATA/raw/J462_B_R2.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J80_A_26_11_15_S1_all_R1_001.fastq.gz DATA/raw/J80_A_R1.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J80_A_26_11_15_S1_all_R2_001.fastq.gz DATA/raw/J80_A_R2.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J80_B_26_11_15_S2_all_R1_001.fastq.gz DATA/raw/J80_B_R1.fastq.gz
ln -s /projet/maiage/save/cmidoux/DIGESTOMIC/DATA/DIGESTOMIC_J80_B_26_11_15_S2_all_R2_001.fastq.gz DATA/raw/J80_B_R2.fastq.gz
Midoux Cedric's avatar
Midoux Cedric committed
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
```

## ghostKOALA

### Submit analysis

```bash
awk 'NR<=2000000' work/FGS/coassembly_FGS.faa > work/FGS/coassembly_FGS-1.faa 
awk 'NR>=2000001&&NR<=4000000' work/FGS/coassembly_FGS.faa > work/FGS/coassembly_FGS-2.faa 
awk 'NR>=4000001&&NR<=6000000' work/FGS/coassembly_FGS.faa > work/FGS/coassembly_FGS-3.faa 
awk 'NR>=6000001&&NR<=8000000' work/FGS/coassembly_FGS.faa > work/FGS/coassembly_FGS-4.faa 
awk 'NR>=8000001&&NR<=10000000' work/FGS/coassembly_FGS.faa > work/FGS/coassembly_FGS-5.faa 
awk 'NR>=10000001' work/FGS/coassembly_FGS.faa  > work/FGS/coassembly_FGS-6.faa 
```

* Download files
* Upload on [GhostKOALA webserver](https://www.kegg.jp/ghostkoala/) with `genus_prokaryotes + family_eukaryotes + viruses ` database option
* Submit
* Download from webserver and group in order annotation files `user_ko.txt`
* Join with other tables

### KEGG orthology table

[source](http://merenlab.org/2018/01/17/importing-ghostkoala-annotations/)

```bash
cd work/ghostKOALA
wget 'https://www.genome.jp/kegg-bin/download_htext?htext=ko00001&format=htext&filedir=' -O ko00001.keg

kegfile="ko00001.keg"

while read -r prefix content
do
    case "$prefix" in A) col1="$content";; \
                      B) col2="$content" ;; \
                      C) col3="$content";; \
                      D) echo -e "$col1\t$col2\t$col3\t$content";;
    esac 
done < <(sed '/^[#!+]/d;s/<[^>]*>//g;s/^./& /' < "$kegfile") > KO_Orthology_ko00001.txt

rm ko00001.keg
Midoux Cedric's avatar
Midoux Cedric committed
67
68

cut -f4 KO_Orthology_ko00001.txt | sort -n | uniq | sed 's/  /\t/' > KO_name.txt
Midoux Cedric's avatar
Midoux Cedric committed
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
### Combine duplicates lines with comma

```python
import csv
import os

os.system("sort -k1,1 user_ko.txt > user_ko-sort.txt")

with open("user_ko-sort.txt", "r") as f:
	with open("user_ko-uniq.txt", "w") as out:
		reader=csv.reader(f, delimiter='\t')
		old_gene=""
		old_ko=""
		for row in reader:
			gene=row[0]
			try:
				ko=row[1]
			except IndexError:
				ko="NA"
			if(gene==old_gene):
				old_ko=old_ko+","+ko
			else:
				out.write("%s\t%s\n"%(old_gene, old_ko))
				old_gene=gene
				old_ko=ko
		out.write("%s\t%s\n"%(gene, ko))
```
Midoux Cedric's avatar
Midoux Cedric committed
98
99
100
101
102

## Final table
```bash
join -t $'\t' report/count-genes_FGS-J80_A-coassembly.tsv report/count-genes_FGS-J80_B-coassembly.tsv | \
join -t $'\t' - report/count-genes_FGS-J177_A-coassembly.tsv | \
Midoux Cedric's avatar
Midoux Cedric committed
103
104
105
106
107
108
109
join -t $'\t' - report/count-genes_FGS-J177_B-coassembly.tsv | \
join -t $'\t' - report/count-genes_FGS-J218_A-coassembly.tsv | \
join -t $'\t' - report/count-genes_FGS-J218_B-coassembly.tsv | \
join -t $'\t' - report/count-genes_FGS-J281_A-coassembly.tsv | \
join -t $'\t' - report/count-genes_FGS-J281_B-coassembly.tsv | \
join -t $'\t' - report/count-genes_FGS-J462_A-coassembly.tsv | \
join -t $'\t' - report/count-genes_FGS-J462_B-coassembly.tsv | \
Midoux Cedric's avatar
Midoux Cedric committed
110
sed 's/__/0_/' | \
Midoux Cedric's avatar
Midoux Cedric committed
111
112
113
114
115
116
117
118
119
120
121
122
sort -k1,1 \
 > Table/count-genes_coassembly.tsv

awk -F $'\t' -v OFS=$'\t' '{if($1=="C") print $2,$3,$4 ; else print $2,$3,"NA; NA; NA; NA; NA; NA; NA;"}' report/genes_coassembly-taxNames.tsv | \
sort -k1,1 \
 > Table/taxName_coassembly.tsv

sort -k2,2 work/ghostKOALA/user_ko-uniq.txt | \
join --check-order -t $'\t' -e NA -a1 -12 -21 -o 1.1,0,2.2 - work/ghostKOALA/KO_name.txt | \
sort -k1,1 \
 > Table/KO_coassembly.tsv

Midoux Cedric's avatar
Midoux Cedric committed
123
 echo -e "gene\tJ80_A\tJ80_B\tJ177_A\tJ177_B\tJ218_A\tJ218_B\tJ281_A\tJ281_B\tJ462_A\tJ462_B\ttaxID_kaijuNR\ttaxID_name\tKO_ghostKOALA\tKO_name"> Table/digestomics.tsv
Midoux Cedric's avatar
Midoux Cedric committed
124
125
126
127
128

join --check-order -t $'\t' -e NA -a1 Table/count-genes_coassembly.tsv Table/taxName_coassembly.tsv | \
join --check-order -t $'\t' -e NA -a1 - Table/KO_coassembly.tsv \
 >> Table/digestomics.tsv
```