-
Notifications
You must be signed in to change notification settings - Fork 0
/
geneStrainResults.Rmd
164 lines (124 loc) · 5.03 KB
/
geneStrainResults.Rmd
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
153
154
155
156
157
158
159
160
161
162
163
164
---
title: "gene strain table"
output: html_document
---
```{r}
library(reshape2)
maxHitScoreDF_cysteine_wide <- dcast(maxHitScoreDF_cysteine, strain~gene)
View(maxHitScoreDF_cysteine_wide)
# ok... custom profiles give basically the same result as the profile HMMs from Wolf.
# next step: check scores and lengths.... just in case the profile HMMs are returning low scores or short sequences.
```
#first, let's take a look at the hit scores for each of the profiles
```{r}
library(ggplot2)
# hit scores
ggplot(maxHitScoreDF_cysteine, aes(x = hit_score, fill = gene)) +
geom_histogram(position="identity", color = "black") +
facet_wrap(~gene) +
ggtitle("Distribution of Hit Scores for HMMER Results, by profile HMM ") +
theme(legend.position="none")
ggplot(maxHSPScoreDF, aes(x = hsp_score, fill = gene)) +
geom_histogram(position="identity", color = "black") +
facet_wrap(~gene) +
ggtitle("Distribution of HSP Scores for HMMER Results, by profile HMM ") +
theme(legend.position="none")
ggplot(maxHSPLen, aes(x = hsp_len, fill = gene)) +
geom_histogram(position="identity", color = "black") +
facet_wrap(~gene) +
ggtitle("Distribution of HSP Lengths for HMMER Results, by profile HMM ") +
theme(legend.position="none")
# PROFILE LENGTHS (all custom)
"
lcd = 523
metC = 479
malY = 493
cysK = 462
cysM = 366
tnaA = 839
"
```
# let's look at boxplot version of the distribution
```{r}
library(ggplot2)
# hit scores
ggplot(maxHitScoreDF_cysteine, aes(x = hit_score, fill = gene)) +
geom_boxplot(position="identity", color = "black") +
facet_wrap(~gene) +
ggtitle("Distribution of Hit Scores for HMMER Results, by profile HMM ") +
theme(legend.position="none")
ggplot(maxHSPScoreDF, aes(x = hsp_score, fill = gene)) +
geom_boxplot(position="identity", color = "black") +
facet_wrap(~gene) +
ggtitle("Distribution of HSP Scores for HMMER Results, by profile HMM ") +
theme(legend.position="none")
ggplot(maxHSPLen, aes(x = hsp_len, fill = gene)) +
geom_boxplot(position="identity", color = "black") +
facet_wrap(~gene) +
ggtitle("Distribution of HSP Lengths for HMMER Results, by profile HMM ") +
theme(legend.position="none")
```
# score filter based on lowest scoring model cysteine-degrader
```{r}
library(dplyr)
model_metc <- c("Escherichia_coli")
model_cysk <- c("Escherichia_coli")
model_cysm <- c("Escherichia_coli")
model_tnaa <- c("Escherichia_coli")
model_cdb_df <- (subset(maxHitScoreDF_cysteine,
grepl(model_cdb[1], strain) |
grepl(model_cdb[2], strain) |
grepl(model_cdb[3], strain) |
grepl(model_cdb[4], strain)
== TRUE))
slice(subset(model_cdb_df, model_cdb_df$gene == "cysKcustom"), which.min(hit_score))
slice(subset(model_cdb_df, model_cdb_df$gene == "cysMcustom"), which.min(hit_score))
slice(subset(model_cdb_df, model_cdb_df$gene == "lcdcustom"), which.min(hit_score))
slice(subset(model_cdb_df, model_cdb_df$gene == "malYcustom"), which.min(hit_score))
slice(subset(model_cdb_df, model_cdb_df$gene == "metCcustom"), which.min(hit_score))
slice(subset(model_cdb_df, model_cdb_df$gene == "tnaA"), which.min(hit_score))
cysK_min_score = 515.6
cysM_min_score = 546
lcd_min_score = 116.8
malY_min_score = 531.1
metC_min_score = 563.3
tnaA_min_score = 933.6
```
# filtering by max hit
```{r}
cysK_min_score = max(maxHitScoreDF_cysteine_wide$cysKcustom, na.rm = TRUE)
cysM_min_score = max(maxHitScoreDF_cysteine_wide$cysMcustom, na.rm = TRUE)
lcd_min_score = max(maxHitScoreDF_cysteine_wide$lcdcustom, na.rm = TRUE)
malY_min_score = max(maxHitScoreDF_cysteine_wide$malYcustom, na.rm = TRUE)
metC_min_score = max(maxHitScoreDF_cysteine_wide$metCcustom, na.rm = TRUE)
tnaA_min_score = max(maxHitScoreDF_cysteine_wide$tnaA, na.rm = TRUE)
```
# subset df for score filter
```{r}
filter_factor = 0.75
cysteine_score_filtered_df <- as.data.frame(maxHitScoreDF_cysteine) %>%
filter((gene == "cysKcustom" & hit_score >= cysK_min_score * filter_factor) |
(gene == "cysMcustom" & hit_score >= cysM_min_score * filter_factor) |
(gene == "lcdcustom" & hit_score >= lcd_min_score * filter_factor) |
(gene == "metCcustom" & hit_score >= metC_min_score * filter_factor) |
(gene == "malYcustom" & hit_score >= malY_min_score * filter_factor) |
(gene == "tnaA" & hit_score >= tnaA_min_score * filter_factor))
# reshape filtered_df from long to wide by gene (gene)
cysteine_score_filtered_wide <- reshape(cysteine_score_filtered_df, timevar = "gene", direction = "wide", idvar = "strain")
```
# find model organisms for each gene
```{r}
gene_dict <- Dict$new("metC" = "K01760",
"malY" = "K14155",
"cysK" = "K01738",
"cysM" = "K12339",
"lcd" = "K22207")
gene <- "malY"
KO_ID <- gene_dict$get(gene)
geneList <- keggFind("genes", KO_ID)
organisms <- c()
for (geneID in names(geneList)) {
organisms <- append(organisms, as.character(keggGet(geneID)[[1]]$ORGANISM))
}
View(organisms)
```