This repository has been archived by the owner on Dec 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
172 lines (172 loc) · 7.56 KB
/
.Rhistory
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
165
166
167
168
169
170
171
172
#EXPLORING VIRUS DATA
#see proportion of cytoplasm replication segmented
virus_data |>
group_by(vCytoReplicTF) |> #DNA/RNA, SS/DS
summarize(sum = sum(vSegmentedTF == TRUE), n = n())
library(tidyverse)
set.seed(313)
mv_associations <- read.csv("MammalViruses_Associations.csv")
#samples only 1000 so we can test it, and then run on all data
mv_sample <- mv_associations %>% sample_n(1000)
#selects columns
mv_sample_select <- select(mv_sample, HostOrder, Virus)
#changes virus names to match virus data
mv_sample_select$Virus <- sub(" ", "_", mv_sample_select$Virus)
#changes to lower case
mv_sample_select$Virus <- tolower(mv_sample_select$Virus)
#CLEANING UP VIRUS DATA
virus_data <- read.csv("HP3_viruses.csv")
#selects needed columns
virus_select <- select(virus_data, vVirusNameCorrected, vSegmentedTF, vCytoReplicTF, vDNAoRNA)
#changes to lower case (to match mv data)
virus_select$vVirusNameCorrected <- tolower(virus_select$vVirusNameCorrected)
#EXPLORING VIRUS DATA
#see proportion of cytoplasm replication segmented
virus_data |>
group_by(vCytoReplicTF) |> #DNA/RNA, SS/DS
summarize(sum = sum(vSegmentedTF == TRUE), n = n())
virus_data |>
group_by(vDNAoRNA) |> #DNA/RNA, SS/DS
summarize(sum = sum(vSegmentedTF == TRUE), n = n())
ication segmented
virus_data |>
group_by(vCytoReplicTF) |> #DNA/RNA, SS/DS
summarize(sum = sum(vSegmentedTF == TRUE), n = n())
#kept it, cause
irus_data |>
group_by(vSSods) |> #DNA/RNA, SS/DS
summarize(sum = sum(vSegmentedTF == TRUE), n = n())
virus_data |>
group_by(vSSods) |> #DNA/RNA, SS/DS
summarize(sum = sum(vSegmentedTF == TRUE), n = n())
#see proportion of SS or DS viruses segmented
virus_data |>
group_by(vSSoDS) |> #DNA/RNA, SS/DS
summarize(sum = sum(vSegmentedTF == TRUE), n = n())
#EXPLORING VIRUS DATA
#see proportion of DNA/RNA viruses segmented
virus_data |>
group_by(vDNAoRNA) |> #DNA/RNA, SS/DS
summarize(sum = sum(vSegmentedTF == TRUE), n = n())
#Since there are not segmented DNA viruses in the dataset, decided to remove all DNA viruses
#see proportion of DNA/RNA viruses segmented
virus_data |>
group_by(vDNAoRNA) |> #DNA/RNA, SS/DS
summarize(sum = sum(vSegmentedTF == TRUE), n = n())
#Since there are not segmented DNA viruses in the dataset, decided to remove all DNA viruses
View(virus_data)
virus_select <- virus_data |>
filter(vDNAoRNA, RNA) |>
select(vVirusNameCorrected, vSegmentedTF, vCytoReplicTF, vFamily, vGenomeAveLength, vEnvelope, vSSoDS, IsZoonotic)
virus_select <- virus_data |>
filter(vDNAoRNA == RNA) |>
select(vVirusNameCorrected, vSegmentedTF, vCytoReplicTF, vFamily, vGenomeAveLength, vEnvelope, vSSoDS, IsZoonotic)
virus_select <- virus_data |>
filter(vDNAoRNA == 'RNA') |>
select(vVirusNameCorrected, vSegmentedTF, vCytoReplicTF, vFamily, vGenomeAveLength, vEnvelope, vSSoDS, IsZoonotic)
View(virus_select)
#attempt to merge df by virus names
# keeps all Y and all X, even the NA ones
df_merge <- merge(mv_sample_select, virus_select, by.x = "Virus", by.y = 'vVirusNameCorrected',
all.x = TRUE, all.y = TRUE)
#removing NA
df_noNA <- na.omit(df_merge)
View(df_noNA)
View(df_merge)
mv_associations <- read.csv("MammalViruses_Associations.csv")
#samples only 1000 so we can test it, and then run on all data
#mv_sample <- mv_associations %>% sample_n(1000)
mv_sample <- mv_associations
#selects columns
mv_sample_select <- select(mv_sample, HostOrder, Virus)
#changes virus names to match virus data
mv_sample_select$Virus <- sub(" ", "_", mv_sample_select$Virus)
#changes to lower case
mv_sample_select$Virus <- tolower(mv_sample_select$Virus)
#attempt to merge df by virus names
# keeps all Y and all X, even the NA ones
df_merge <- merge(mv_sample_select, virus_select, by.x = "Virus", by.y = 'vVirusNameCorrected',
all.x = TRUE, all.y = TRUE)
#removing NA
df_noNA <- na.omit(df_merge)
#CLEANING UP VIRUS DATA
virus_data <- read.csv("HP3_viruses.csv")
#see proportion of DNA/RNA viruses segmented
virus_data |>
group_by(vDNAoRNA) |> #DNA/RNA, SS/DS
summarize(sum = sum(vSegmentedTF == TRUE), n = n())
#Since there are not segmented DNA viruses in the dataset, decided to remove all DNA viruses
#selects needed columns and only DNA viruses
virus_select <- virus_data |>
filter(vDNAoRNA == 'RNA') |>
select(vVirusNameCorrected, vSegmentedTF, vCytoReplicTF, vFamily, vGenomeAveLength, vEnvelope, vSSoDS, IsZoonotic)
#changes to lower case (to match mv data)
virus_select$vVirusNameCorrected <- tolower(virus_select$vVirusNameCorrected)
#attempt to merge df by virus names
# keeps all Y and all X, even the NA ones
df_merge <- merge(mv_sample_select, virus_select, by.x = "Virus", by.y = 'vVirusNameCorrected',
all.x = TRUE, all.y = TRUE)
#removing NA
df_noNA <- na.omit(df_merge)
virus_select$vVirusNameCorrected <- tolower(virus_select$vVirusNameCorrected)
virus_select$vVirusNameCorrected <- sub(" ", "_", virus_select$vVirusNameCorrected)
#attempt to merge df by virus names
# keeps all Y and all X, even the NA ones
df_merge <- merge(mv_sample_select, virus_select, by.x = "Virus", by.y = 'vVirusNameCorrected',
all.x = TRUE, all.y = TRUE)
#removing NA
df_noNA <- na.omit(df_merge)
mv_associations <- read.csv("MammalViruses_Associations.csv")
#samples only 1000 so we can test it, and then run on all data
#mv_sample <- mv_associations %>% sample_n(1000)
mv_sample <- mv_associations
#selects columns
mv_sample_select <- select(mv_sample, HostOrder, Virus)
#changes virus names to match virus data
mv_sample_select$Virus <- gsub(" ", "_", mv_sample_select$Virus)
#changes to lower case
mv_sample_select$Virus <- tolower(mv_sample_select$Virus)
#CLEANING UP VIRUS DATA
virus_data <- read.csv("HP3_viruses.csv")
#see proportion of DNA/RNA viruses segmented
virus_data |>
group_by(vDNAoRNA) |> #DNA/RNA, SS/DS
summarize(sum = sum(vSegmentedTF == TRUE), n = n())
#Since there are not segmented DNA viruses in the dataset, decided to remove all DNA viruses
#selects needed columns and only DNA viruses
virus_select <- virus_data |>
filter(vDNAoRNA == 'RNA') |>
select(vVirusNameCorrected, vSegmentedTF, vCytoReplicTF, vFamily, vGenomeAveLength, vEnvelope, vSSoDS, IsZoonotic)
#changes to lower case (to match mv data)
virus_select$vVirusNameCorrected <- tolower(virus_select$vVirusNameCorrected)
virus_select$vVirusNameCorrected <- gsub(" ", "_", virus_select$vVirusNameCorrected)
#attempt to merge df by virus names
# keeps all Y and all X, even the NA ones
df_merge <- merge(mv_sample_select, virus_select, by.x = "Virus", by.y = 'vVirusNameCorrected',
all.x = TRUE, all.y = TRUE)
#removing NA
df_noNA <- na.omit(df_merge)
#attempt to merge df by virus names
# keeps all Y and all X, even the NA ones
df_merge <- merge(mv_sample_select, virus_select, by.x = "Virus", by.y = 'vVirusNameCorrected',
all.x = TRUE, all.y = TRUE)
#removing NA
df_noNA <- na.omit(df_merge)
df_sum <- df_noNA |>
group_by(HostOrder) |>
summarize(sum = sum(vSegmentedTF == TRUE), n = n())
df_sum <- as.data.frame(df_sum)
df_sum
df_noNA |>
group_by(HostOrder) |>
summarize(sum = sum(vSegmentedTF == TRUE), n = n())
model = glm(vSegmentedTF ~ vDNAoRNA + vFamily + vGenomeAveLength + vEnvelope + vSSoDS + IsZoonotic, family = 'binomial', data = df_noNA)
model = glm(vSegmentedTF ~ vFamily + vGenomeAveLength + vEnvelope + vSSoDS + IsZoonotic, family = 'binomial', data = df_noNA)
summary(model)
model2 = glm(vSegmentedTF ~ HostOrder + vFamily + vGenomeAveLength + vEnvelope + vSSoDS + IsZoonotic, family = 'binomial', data = df_noNA)
summary(model2)
summary(model)
model = glm(vSegmentedTF ~ vFamily + vGenomeAveLength + vEnvelope + vSSoDS + IsZoonotic + vCytoReplicTF, family = 'binomial', data = df_noNA)
summary(model)
model2 = glm(vSegmentedTF ~ HostOrder + vFamily + vGenomeAveLength + vEnvelope + vSSoDS + IsZoonotic + vCytoReplicTF, family = 'binomial', data = df_noNA)
summary(model2)