Skip to content

Commit

Permalink
Merge pull request #175 from bigomics/add-mouse-chr-map
Browse files Browse the repository at this point in the history
Retrieve chr map for mouse genes
  • Loading branch information
ESCRI11 authored Oct 25, 2024
2 parents 10c8bfc + 2a135f8 commit 58c788b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions R/pgx-annot.R
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ getGeneAnnotation.ANNOTHUB <- function(
cols <- c("SYMBOL", "GENENAME", "GENETYPE", "MAP")
cols <- intersect(cols, AnnotationDbi::keytypes(orgdb))

if (organism %in% c("Mus musculus", "Rattus norvegicus")) {
cols <- unique(c(cols, "ENTREZID"))
}

cat("get gene annotation columns:", cols, "\n")
message("retrieving annotation for ", length(probes), " ", probe_type, " features...")

Expand All @@ -245,6 +249,27 @@ getGeneAnnotation.ANNOTHUB <- function(
)
))

## Attempt to retrieve chr map via org.Mm.egCHRLOC / org.Rn.egCHRLOC.
if (organism %in% c("Mus musculus", "Rattus norvegicus")) {
if (organism == "Mus musculus") {
library(org.Mm.eg.db)
chrloc <- org.Mm.egCHRLOC
}
if (organism == "Rattus norvegicus") {
library(org.Rn.eg.db)
chrloc <- org.Rn.egCHRLOC
}
mapped_genes <- as.list(chrloc[mappedkeys(chrloc)])
cm <- intersect(as.character(annot$ENTREZID), names(mapped_genes))
mapped_genes <- mapped_genes[cm]
locs <- unlist(lapply(mapped_genes, function(x) names(x[1])))
jj <- match(names(locs), annot$ENTREZID)
annot$MAP <- NA
annot$MAP[jj] <- unname(locs)
cls <- setdiff(colnames(annot), "ENTREZID")
annot <- annot[, cls, drop = FALSE]
}

# some organisms do not provide symbol but rather gene name (e.g. yeast)
if (!"SYMBOL" %in% colnames(annot)) {
annot$SYMBOL <- annot$GENENAME
Expand Down

0 comments on commit 58c788b

Please sign in to comment.