-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompileGOList.FromQuickGOAnnotations.R
More file actions
38 lines (34 loc) · 2.04 KB
/
CompileGOList.FromQuickGOAnnotations.R
File metadata and controls
38 lines (34 loc) · 2.04 KB
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
CompileGOList.FromQuickGOAnnotations <- function(ExportedTSVFilePath,
ExistingGOList = list(),
UniProtKBACColumnName = "GENE.PRODUCT.ID",
To = "Ensembl",
GOColumnName = "GO.TERM",
IgnoreUnreliableGOAnnotationPipelines = FALSE,
ReferenceColumnName = "REFERENCE",
IgnoredReferenceCodes = c("GO_REF:0000002", "GO_REF:0000041", "GO_REF:0000090", "GO_REF:0000108", "GO_REF:0000117", "GO_REF:0000118")) {
QuickGOAnnotationsTable <- read.table(ExportedTSVFilePath, header = TRUE, sep = "\t", na.strings = "", quote = "")
if (nrow(QuickGOAnnotationsTable) == 0) {
return(ExistingGOList)
}
if (IgnoreUnreliableGOAnnotationPipelines) {
QuickGOAnnotationsTable <- QuickGOAnnotationsTable[!(QuickGOAnnotationsTable[, ReferenceColumnName] %in% IgnoredReferenceCodes),]
}
MappingTable <- UniProtKBAC2EnsemblID(paste0(unique(QuickGOAnnotationsTable[, UniProtKBACColumnName]), collapse = ","), To = To)
QuickGOAnnotationsTable[, "EnsemblID"] <- rep(NA, nrow(QuickGOAnnotationsTable))
for (i in 1 : nrow(QuickGOAnnotationsTable)) {
UniProtKBAC <- QuickGOAnnotationsTable[i, UniProtKBACColumnName]
EnsemblMapping <- unique(MappingTable[(MappingTable[, "uniprotsptrembl"] == UniProtKBAC), "ensembl_gene_id"])
QuickGOAnnotationsTable[i, "EnsemblID"] <- paste0(EnsemblMapping, collapse = ";")
}
for (i in 1 : nrow(QuickGOAnnotationsTable)) {
for (j in unlist(strsplit(QuickGOAnnotationsTable[i, "EnsemblID"], split = ";"))) {
if (j %in% names(ExistingGOList)) {
ExistingGOList[[j]] <- unique(c(ExistingGOList[[j]], QuickGOAnnotationsTable[i, GOColumnName]))
}
else {
ExistingGOList[[j]] <- QuickGOAnnotationsTable[i, GOColumnName]
}
}
}
return(ExistingGOList)
}