Skip to content
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Suggests:
impute,
knitr,
magrittr,
miRNAmeConverter,
org.Hs.eg.db,
RColorBrewer,
readr,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export(trimColData)
export(uniformBuilds)
import(methods)
importFrom(BiocBaseUtils,checkInstalled)
importFrom(BiocBaseUtils,isCharacter)
importFrom(BiocBaseUtils,isScalarCharacter)
importFrom(BiocBaseUtils,isScalarNumber)
importFrom(BiocBaseUtils,lifeCycle)
Expand Down
46 changes: 32 additions & 14 deletions R/simplifyTCGA.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @importFrom GenomicFeatures genes
#' @importFrom GenomeInfoDb keepStandardChromosomes seqlevelsStyle
#' seqlevelsStyle<-
#' @importFrom BiocBaseUtils isScalarCharacter
#' @importFrom BiocBaseUtils isScalarCharacter isCharacter
NULL

.checkHas <-
Expand Down Expand Up @@ -32,7 +32,12 @@ NULL
for (i in which(which)) {
lookup <- FUN(rownames(x[[i]]))
ranges <- lookup[["mapped"]]
rse <- x[[i]][names(ranges), ]
if (!is.null(mcols(ranges)[["rowIdx"]]))
rse <- `rownames<-`(
x[[i]][mcols(ranges)[["rowIdx"]], ], names(ranges)
)
Comment thread
LiNk-NY marked this conversation as resolved.
Outdated
else
rse <- x[[i]][names(ranges), ]
# rowData not merged with mcols of RHS in `rowRanges<-` method
mcols(ranges) <-
S4Vectors::DataFrame(rowData(rse), S4Vectors::mcols(ranges))
Expand Down Expand Up @@ -60,9 +65,18 @@ NULL
#' `GRanges()` object with ranges of mapped symbols
#' @keywords internal
.makeListRanges <- function(x, gn) {
res <- list(unmapped = x[!x %in% names(gn)])
x <- x[x %in% names(gn)]
gn <- gn[match(x, names(gn))]
checkInstalled("miRNAmeConverter")
nc <- miRNAmeConverter::MiRNANameConverter()
mirna_version <-
miRNAmeConverter::assessVersion(nc, names(gn))[1L, "version"]
trout <- miRNAmeConverter::translateMiRNAName(
nc, x, versions = mirna_version
)
new_x <- trout[[paste0("v", mirna_version, ".0")]]
res <- list(unmapped = setdiff(x, trout[["input"]]))
rowIdx <- match(tolower(trout[["input"]]), x)

Copilot AI Nov 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using tolower(trout[["input"]]) for matching assumes that the original input x contains lowercase miRNA identifiers. However, miRNA identifiers are typically mixed-case (e.g., "hsa-miR-21"). This mismatch will likely cause incorrect row index mapping.

Consider using case-insensitive matching or ensuring consistent case handling: rowIdx <- match(trout[["input"]], x) or rowIdx <- match(tolower(trout[["input"]]), tolower(x)).

Suggested change
rowIdx <- match(tolower(trout[["input"]]), x)
rowIdx <- match(tolower(trout[["input"]]), tolower(x))

Copilot uses AI. Check for mistakes.
gn <- gn[match(new_x, names(gn))]
mcols(gn)[["rowIdx"]] <- rowIdx
res[["mapped"]] <- gn
res
}
Comment thread
LiNk-NY marked this conversation as resolved.
Expand Down Expand Up @@ -92,9 +106,9 @@ NULL
#' @rdname hidden-helpers
#' @keywords internal
.getRangesOfMir <- function(x) {
stopifnot(isScalarCharacter(x))
stopifnot(isCharacter(x))

mirnas_gr <- .get_hsa_gff3(x)
mirnas_gr <- .get_hsa_gff3("hg19")
Comment thread
LiNk-NY marked this conversation as resolved.

miR <- mirnas_gr[
mcols(mirnas_gr)[["type"]] %in% c("miRNA", "microRNA", "tRNA")
Expand Down Expand Up @@ -209,9 +223,7 @@ NULL
#' [`RangedSummarizedExperiment`][SummarizedExperiment::RangedSummarizedExperiment-class]
#' objects
#'
#' @author L. Waldron
#'
#' @md
#' @author L. Waldron, M. Ramos
#'
#' @examples
#'
Expand Down Expand Up @@ -275,10 +287,16 @@ symbolsToRanges <- function(obj, keep.assay = FALSE, unmapped = TRUE) {
#'
#' @export
mirToRanges <- function(obj, keep.assay = FALSE, unmapped = TRUE) {
lifeCycle(
package = "TCGAutils",
cycle = "defunct",
title = "simplifyTCGA"
checkInstalled("Bioc.gff")

can.fix <- .isFixable(mae = obj, pattern = "^hsa")

.convertTo(
x = obj,
which = can.fix,
FUN = .getRangesOfMir,
keep = keep.assay,
unmap = unmapped
)
}

Expand Down
2 changes: 1 addition & 1 deletion man/simplifyTCGA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading