lianos / sparrow

Take command of your set enrichment analyses.
https://lianos.github.io/sparrow/
MIT License
20 stars 1 forks source link

Create a renameCollection function #3

Closed lianos closed 3 years ago

lianos commented 3 years ago

It's not too hard to rename collections by manipulating the internal data.tables, let's do that.

This code snippet renames a "C7" collection to "ImmuneSigDb" in a GeneSetDb gdb object:

gdb@db[collection == "C7", collection := "ImmuneSigDb"]
setkeyv(gdb@db, c("collection", "name", "feature_id"))

gdb@table[collection == "C7", collection := "ImmuneSigDb"]
setkeyv(gdb@table, c("collection", "name"))

gdb@collectionMetadata[collection == "C7", collection := "ImmuneSigDb"]
setkeyv(gdb@collectionMetadata, c("collection", "name"))

Ideas

The function signature might look like:

renameCollection <- function(gdb, rename, ...) {
}

with rename being a named character vector with names() being the current name of the collection, and its values are the new collection names you want to rename them to.