-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvenn_comparison.R
205 lines (135 loc) · 7.12 KB
/
venn_comparison.R
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
library(devtools)
install_github("mustafapir/geneName")
library(gdata)
library(geneName)
library(UpSetR)
library(data.table)
library(dplyr)
library(readxl)
source("./functions/venn_function.R")
source("./functions/commonUnique.R")
#read csv file
humangenes<-fread("./data/Reyfman_Table1.csv", header=TRUE)
#Venn for human data
venn(humangenes, 14)
# Genes only in ciliated cells
humanciliary<-commonUnique(humangenes, "Ciliated Cells")
colnames(humanciliary)[1]<-"human"
# Convert (if) any gene synonyms to gene names
humanciliary<-gnameConverter(humanciliary, "human")
# Read mouse data
mouseciliarygenes<-read.csv("./data/Du_et_2017_Mouse_scRNA_seq.csv", sep = ";", stringsAsFactors = FALSE)
mouseciliarygenes<-mouseciliarygenes[,seq(1,17,2)]
# Venn for mouse data
venn(mouseciliarygenes, 9)
# Genes only in ciliated cells
mouseciliary<-commonUnique(mouseciliarygenes, "ď..Ciliated_cells")
# Convert (if) any mouse gene synonyms to mouse gene names
mouseciliaryhuman<-mousesynonymConverter(mouseciliary, "ď..Ciliated_cells")
# Convert mouse gene names to human gene names
mouseciliaryhuman<-mousegnameConverter(mouseciliaryhuman, "ď..Ciliated_cells")
# Get only the genes having human homolog
mouseciliaryhuman$human<-mouse_homology$Gene_name[match(mouseciliaryhuman$ď..Ciliated_cells, mouse_homology$Gene_name)]
mouseciliary1<-data.frame(mouse = na.omit(mouseciliaryhuman$human), stringsAsFactors = FALSE)
# Read C. elegans data
celegansciliary<-fread("./data/C_elegans_single_cell_1329_.csv", header = FALSE)
# Read C. elegans homology data
celeghum<-fread("./data/C_elegans_Human_Homologs_20.01.2019 - UPDATED.csv")
# Convert from C. elegans to human gene name
celeghum1<-celeghum[,4:6]
#celeghum1[which(celeghum1$Human_Symbol == "-"),]<-""
#celeghum1<-gnameConverter(celeghum1, "Human_Symbol")
colnames(celegansciliary)<-"Celegans_Symbol"
celeghum2<-celeghum1[which(celeghum1$Celegans_Symbol %in% celegansciliary$Celegans_Symbol),c(1,3)]
colnames(celegansciliary)<-"Celegans_Tag"
celeghum3<-celeghum1[which(celeghum1$Celegans_Tag %in% celegansciliary$Celegans_Tag),c(2,3)]
colnames(celeghum3)[1]<-"Celegans_Symbol"
celeghum4<-rbind(celeghum2, celeghum3)
celegansciliary<-celeghum4[,2]
colnames(celegansciliary)[1]<-"celegans"
# Convert (if) any gene synonyms to gene names
celegansciliary<-gnameConverter(celegansciliary, "celegans")
# Combine all 3 data
allciliary<-cbindX(humanciliary, mouseciliary1, celegansciliary)
# Convert any NA to space
allciliary$mouse<-replace(allciliary$mouse, is.na(allciliary$mouse), "")
allciliary$celegans<-replace(allciliary$celegans, is.na(allciliary$celegans), "")
# Find genes found only in "......"
human_mouse_celegans<-commonUnique(allciliary)
human_mouse_celegans<-replace(human_mouse_celegans, is.na(human_mouse_celegans), "")
write.table(human_mouse_celegans, "./data/human_mouse_celegans.csv", sep = ",", row.names = FALSE, quote = FALSE)
# Venn
venn(allciliary, 3)
# C elegans single cell, only human homologs
celeghum11<-celeghum[,6]
celeghum11[which(celeghum11$Human_Symbol == "-"),]<-""
celeghum11<-gnameConverter(celeghum11, "Human_Symbol")
# Mouse single cell, only human homologs
mouhum<-geneName::mouse_homology
mouhum<-gnameConverter(mouhum, "Gene_name")
# CiliaCarta
ciliacarta<-fread("./data/CiliaCarta_genes.csv", select = "Associated Gene Name")
colnames(ciliacarta)[1]<-"cilia_carta"
ciliacarta<-gnameConverter(ciliacarta, "cilia_carta")
celeghum11<-celeghum[,6]
celeghum11[which(celeghum11$Human_Symbol == "-"),]<-""
celeghum11<-gnameConverter(celeghum11, "Human_Symbol")
ciliacarta_celegans<-ciliacarta[which(ciliacarta$cilia_carta %in% celeghum11$Human_Symbol),]
ciliacarta_mouse<-ciliacarta[which(ciliacarta$cilia_carta %in% mouhum$Gene_name),]
# Gold standard
goldstandard<-fread("./data/Gold_standard_cilia_scgs.v1.tsv", select = "V2")
goldstandard<-goldstandard[-1]
colnames(goldstandard)<-"gold_standard"
goldstandard<-gnameConverter(goldstandard, "gold_standard")
goldstandard_celegans<-goldstandard[which(goldstandard$gold_standard %in% celeghum11$Human_Symbol),]
goldstandard_mouse<-goldstandard[which(goldstandard$gold_standard %in% mouhum$Gene_name),]
# Negative cilia genes
negativecilia<-read_xls("./data/Nevers_2017_NegativeGenesInsightsCiiaryGenes_SuppTable3 .xls") %>%
dplyr::select("Gene Name")
negativecilia<-data.table(negativecilia)
colnames(negativecilia)<-"negative_ciliary"
negativecilia<-gnameConverter(negativecilia, "negative_ciliary")
negativecilia_celegans<-negativecilia[which(negativecilia$negative_ciliary %in% celeghum11$Human_Symbol),]
negativecilia_mouse<-negativecilia[which(negativecilia$negative_ciliary %in% mouhum$Gene_name),]
# Venn for human single cell + cilia carta + gold standard + negative cilia
all1<-cbindX(humanciliary, ciliacarta, goldstandard, negativecilia)
all1$cilia_carta<-replace(all1$cilia_carta, is.na(all1$cilia_carta), "")
all1$gold_standard<-replace(all1$gold_standard, is.na(all1$gold_standard), "")
all1$negative_ciliary<-replace(all1$negative_ciliary, is.na(all1$negative_ciliary), "")
venn(all1, 4)
# Venn for mouse single cell + cilia carta + gold standard + negative cilia
all2<-cbindX(mouseciliary1, ciliacarta_mouse, goldstandard_mouse, negativecilia_mouse)
all2$mouse<-replace(all2$mouse, is.na(all2$mouse), "")
all2$cilia_carta<-replace(all2$cilia_carta, is.na(all2$cilia_carta), "")
all2$gold_standard<-replace(all2$gold_standard, is.na(all2$gold_standard), "")
all2$negative_ciliary<-replace(all2$negative_ciliary, is.na(all2$negative_ciliary), "")
venn(all2, 4)
# Venn for c elegans single cell + cilia carta + gold standard + negative cilia
all3<-cbindX(celegansciliary, ciliacarta_celegans, goldstandard_celegans, negativecilia_celegans)
all3$celegans<-replace(all3$celegans, is.na(all3$celegans), "")
all3$cilia_carta<-replace(all3$cilia_carta, is.na(all3$cilia_carta), "")
all3$gold_standard<-replace(all3$gold_standard, is.na(all3$gold_standard), "")
all3$negative_ciliary<-replace(all3$negative_ciliary, is.na(all3$negative_ciliary), "")
venn(all3, 4)
# Venn for all single cell + cilia carta + gold standard + negative cilia
all4<-cbindX(humanciliary, mouseciliary1, celegansciliary, ciliacarta, goldstandard, negativecilia)
all4$celegans<-replace(all4$celegans, is.na(all4$celegans), "")
all4$cilia_carta<-replace(all4$cilia_carta, is.na(all4$cilia_carta), "")
all4$gold_standard<-replace(all4$gold_standard, is.na(all4$gold_standard), "")
all4$negative_ciliary<-replace(all4$negative_ciliary, is.na(all4$negative_ciliary), "")
all4$mouse<-replace(all4$mouse, is.na(all4$mouse), "")
all4$human<-replace(all4$human, is.na(all4$human), "")
venn(all4, 6)
# Gene lists
human<-commonUnique(all1)
human<-replace(human, is.na(human), "")
write.table(human, "./data/human.csv", sep = ",", row.names = FALSE, quote = FALSE)
mouse<-commonUnique(all2)
mouse<-replace(mouse, is.na(mouse), "")
write.table(mouse, "./data/mouse.csv", sep = ",", row.names = FALSE, quote = FALSE)
celegans<-commonUnique(all3)
celegans<-replace(celegans, is.na(celegans), "")
write.table(celegans, "./data/celegans.csv", sep = ",", row.names = FALSE, quote = FALSE)
all<-commonUnique(all4)
all<-replace(all, is.na(all), "")
write.table(all, "./data/all.csv", sep = ",", row.names = FALSE, quote = FALSE)