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

Midoux Cedric's avatar
Midoux Cedric committed
3
4
5
6
7
8
9
10
11
12
13
## link to DATA

```bash
ln -s ~/DIGESTOMIC/DATA/DIGESTOMIC_J177_A_02_03_16_S3_all_R1_001.fastq.gz DATA/raw/J177_A_R1.fastq.gz
ln -s ~/DIGESTOMIC/DATA/DIGESTOMIC_J177_A_02_03_16_S3_all_R2_001.fastq.gz DATA/raw/J177_A_R2.fastq.gz
ln -s ~/DIGESTOMIC/DATA/DIGESTOMIC_J177_B_02_03_16_S4_all_R1_001.fastq.gz DATA/raw/J177_B_R1.fastq.gz
ln -s ~/DIGESTOMIC/DATA/DIGESTOMIC_J177_B_02_03_16_S4_all_R2_001.fastq.gz DATA/raw/J177_B_R2.fastq.gz
ln -s ~/DIGESTOMIC/DATA/DIGESTOMIC_J80_A_26_11_15_S1_all_R1_001.fastq.gz DATA/raw/J80_A_R1.fastq.gz
ln -s ~/DIGESTOMIC/DATA/DIGESTOMIC_J80_A_26_11_15_S1_all_R2_001.fastq.gz DATA/raw/J80_A_R2.fastq.gz
ln -s ~/DIGESTOMIC/DATA/DIGESTOMIC_J80_B_26_11_15_S2_all_R1_001.fastq.gz DATA/raw/J80_B_R1.fastq.gz
ln -s ~/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
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
```

## 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
55
56

cut -f4 KO_Orthology_ko00001.txt | sort -n | uniq | sed 's/  /\t/' > KO_name.txt
Midoux Cedric's avatar
Midoux Cedric committed
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
### 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
86
87
88
89
90
91

## 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 | \
join -t $'\t' -  report/count-genes_FGS-J177_B-coassembly.tsv | \
Midoux Cedric's avatar
Midoux Cedric committed
92
sed 's/__/0_/' | \
Midoux Cedric's avatar
Midoux Cedric committed
93
94
95
96
97
98
99
100
101
102
103
104
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
105
 echo -e "gene\tJ80_A\tJ80_B\tJ177_A\tJ177_B\ttaxID_kaijuNR\ttaxID_name\tKO_ghostKOALA\tKO_name"> Table/digestomics.tsv
Midoux Cedric's avatar
Midoux Cedric committed
106
107
108
109
110

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
```