From 934aaf69104b0b9a6f2735ca5bad19785f6dc07b Mon Sep 17 00:00:00 2001 From: Ivo Kwee Date: Fri, 22 Dec 2023 14:32:33 +0100 Subject: [PATCH 1/2] update --- NAMESPACE | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 759a08b8..2941927d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -141,9 +141,11 @@ export(ngs.fitContrastsWithAllMethods) export(ngs.fitContrastsWithEDGER) export(ngs.fitContrastsWithLIMMA) export(ngs.fitContrastsWithTTEST) +export(ngs.getGeneAnnot) export(ngs.getGeneAnnotation) export(ngs.getGeneAnnotation_DEPRECATED) export(ngs.save) +export(ngs.tximportSalmon) export(nmfImpute) export(normalizeCounts) export(normalizeRLE) From cab576e6bea91325db9b7e1d8e63c8d90f34df78 Mon Sep 17 00:00:00 2001 From: Ivo Kwee Date: Fri, 22 Dec 2023 15:42:08 +0100 Subject: [PATCH 2/2] fix: not parsing ensemble with dot-version (critical) --- R/pgx-compute.R | 1 - R/pgx-ensembl.R | 31 ++++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/R/pgx-compute.R b/R/pgx-compute.R index 0b479d1d..493bb53d 100644 --- a/R/pgx-compute.R +++ b/R/pgx-compute.R @@ -171,7 +171,6 @@ pgx.createPGX <- function(counts, message("[createPGX] input: dim(samples) = ", paste(dim(samples), collapse = "x")) message("[createPGX] input: dim(contrasts) = ", paste(dim(contrasts), collapse = "x")) - ## convert old-style contrast matrix to sample-wise labeled contrasts contrasts <- playbase::contrasts.convertToLabelMatrix(contrasts, samples) diff --git a/R/pgx-ensembl.R b/R/pgx-ensembl.R index 90c0e215..6b4f9035 100644 --- a/R/pgx-ensembl.R +++ b/R/pgx-ensembl.R @@ -446,22 +446,27 @@ pgx.gene_table <- function(pgx, organism) { #' @export detect_probe_DEPRECATED <- function(probes, organism) { # Get org database - if (organism == "Human") { + if (tolower(organism) == "human") { org_db <- org.Hs.eg.db::org.Hs.eg.db - } else if (organism == "Mouse") { + } else if (tolower(organism) == "mouse") { org_db <- org.Mm.eg.db::org.Mm.eg.db - } else if (organism == "Rat") { + } else if (tolower(organism) == "rat") { org_db <- org.Rn.eg.db::org.Rn.eg.db } # Probe types keytypes <- c( - "ENSEMBL", "ENSEMBLTRANS", "SYMBOL", - "REFSEQ", "UNIPROT", "ACCNUM" + "ENSEMBL", "ENSEMBLTRANS", "SYMBOL", "REFSEQ", "UNIPROT", "ACCNUM" ) - key_matches <- vector("character", length(keytypes)) + ## key_matches <- vector("character", length(keytypes)) + key_matches <- rep( 0L, length(keytypes)) names(key_matches) <- keytypes + ## discard version numbers if ENSEMBL + if(mean(grepl("^ENS",probes)) > 0.8) { + probes <- sub("[.][0-9]+", "", probes) + } + # Subset probes if too many if (length(probes) > 100) { probes <- probes[as.integer(seq(1, length(probes), 100))] @@ -516,7 +521,8 @@ detect_probe_DEPRECATED <- function(probes, organism) { #' } #' @export ngs.getGeneAnnotation_DEPRECATED <- function(probes, probe_type, organism) { - # Get org database and columns request + + # Get org database and columns request if (organism == "Human") { org_db <- org.Hs.eg.db::org.Hs.eg.db cols_req <- c("SYMBOL", "GENENAME", "CHR", "CHRLOC", "MAP", "GENETYPE") @@ -528,6 +534,12 @@ ngs.getGeneAnnotation_DEPRECATED <- function(probes, probe_type, organism) { cols_req <- c("SYMBOL", "GENENAME", "CHR", "CHRLOC", "GENETYPE") } + ## discard version numbers if ENSEMBL + orig.probes <- probes + if(mean(grepl("^ENS",probes)) > 0.8) { + probes <- sub("[.][0-9]+", "", probes) + } + # Call for annotation table suppressWarnings(d <- AnnotationDbi::select(org_db, keys = probes, @@ -544,6 +556,11 @@ ngs.getGeneAnnotation_DEPRECATED <- function(probes, probe_type, organism) { d$MAP <- d$CHR } + ## if ENSEMBL get original probe names with version + if(probe_type == "ENSEMBL") { + d$ENSEMBL <- orig.probes[match(d$ENSEMBL, probes)] + } + # Rename cols, add extra cols, reorder cols and rows if (probe_type == "SYMBOL") { d[, feature := SYMBOL]