Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

177 improve annotation mapping through readgmt #207

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ importFrom(SingleCellExperiment,SingleCellExperiment)
importFrom(SpatialExperiment,SpatialExperiment)
importFrom(SummarizedExperiment,SummarizedExperiment)
importFrom(SummarizedExperiment,assay)
importFrom(cli,cli_abort)
importFrom(cli,cli_alert_info)
importFrom(cli,cli_alert_success)
importFrom(cli,cli_alert_warning)
Expand Down
1 change: 1 addition & 0 deletions R/GSVA-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@
#' currentBlockId read_block gridReduce write_block close t colSums
#' @importFrom HDF5Array HDF5RealizationSink writeHDF5Array
#' @importFrom BiocSingular runRandomSVD
#' @importFrom cli cli_abort cli_alert_info cli_alert_warning cli_alert_success
NULL
31 changes: 28 additions & 3 deletions R/gsvaNewAPI.R
Original file line number Diff line number Diff line change
Expand Up @@ -863,9 +863,8 @@ geneIdsToGeneSetCollection <- function(geneIdsList,
#' @description Imports a list of gene sets from a GMT (Gene Matrix Transposed)
#' format file, offering a choice of ways to handle duplicated gene set names.
#'
#' @param con A connection object or character string containing e.g.
#' the file name or URL of a GTM file. This is directly passed to [`readLines`]
#' and hence may contain anything that `readLines()` can handle.
#' @param con A connection object or a non-empty character string of length 1
#' containing e.g. the filename or URL of a (possibly compressed) GMT file.
#'
#' @param sep The character string separating members of each gene set in the
#' GMT file.
Expand Down Expand Up @@ -919,6 +918,28 @@ geneIdsToGeneSetCollection <- function(geneIdsList,
#'
#' @seealso [`readLines`], [`GeneSetCollection`], [`getGmt`]
#'
#' @examples
#' library(GSVA)
#' library(GSVAdata)
#'
#' fname <- system.file("extdata", "c7.immunesigdb.v2024.1.Hs.symbols.gmt.gz",
#' package="GSVAdata")
#'
#' ## by default, guess geneIdType from content and return a GeneSetCollection
#' genesets <- readGMT(fname)
#' genesets
#'
#' ## how to manually override the geneIdType
#' genesets <- readGMT(fname, geneIdType=NullIdentifier())
#' genesets
#'
#' ## return a simple list instead of a GeneSetCollection
#' genesets <- readGMT(fname, valueType="list")
#' head(genesets, 2)
#'
#' ## the list has a geneIdType, too
#' gsvaAnnotation(genesets)
#'
#' @aliases readGMT
#' @name readGMT
#' @rdname readGMT
Expand All @@ -932,6 +953,10 @@ readGMT <- function (con,
deduplUse = c("first", "drop", "union", "smallest", "largest"),
...) {
valueType <- match.arg(valueType)

if((!.isCharLength1(con)) && (!inherits(con, "connection"))) {
cli_abort("Argument 'con' is not a valid filename, URL or connection.")
}

## from GSEABase::getGmt()
lines <- strsplit(readLines(con, ...), sep)
Expand Down
28 changes: 25 additions & 3 deletions man/readGMT.Rd

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

Loading