Installation
- Using
devtools
package
# Load devtools package
library(devtools)
# Install SigRepo
devtools::install_github(repo = 'montilab/SigRepo')
# Install OmicSignature
devtools::install_github(repo = 'montilab/OmicSignature')
Load packages
# Load tidyverse package
library(tidyverse)
# Load SigRepo package
library(SigRepo)
# Load OmicSignature package
library(OmicSignature)
Create a handler to connect to SigRepo Database
# Create a connection handler
conn_handler <- SigRepo::newConnHandler(
dbname = "sigrepo",
host = "sigrepo.org",
port = 3306,
user = <your_username>,
password = <your_password>
)
Load signatures
Here, we provided 4 signature objects that came with the package for demonstrations:
- omic_signature_1 (Myc_reduce_mice_liver_24m_v1)
- omic_signature_2 (Myc_reduce_mice_liver_24m_v2)
- omic_signature_3 (Myc_reduce_mice_liver_24m_v3)
- omic_signature_4 (Myc_reduce_mice_liver_24m_v4)
# Read in the signature objects
omic_signature_1 <- base::readRDS(base::file.path(base::system.file("inst/extdata", package = "SigRepo"), "omic_signature_1.RDS"))
omic_signature_2 <- base::readRDS(base::file.path(base::system.file("inst/extdata", package = "SigRepo"), "omic_signature_2.RDS"))
omic_signature_3 <- base::readRDS(base::file.path(base::system.file("inst/extdata", package = "SigRepo"), "omic_signature_3.RDS"))
omic_signature_4 <- base::readRDS(base::file.path(base::system.file("inst/extdata", package = "SigRepo"), "omic_signature_4.RDS"))
Create an omic collection
Here, we will create a collection with two signatures,
omic_signature_1 and omic_signature_1,
provided above. See ?OmicSignatureCollection()
from
OmicSignature package for more details on how to create
an omic collection object.
# Create a metadata object for the collection
metadata <- base::list(
"collection_name" = "my_collection",
"description" = "An example of signature collection"
)
# Create an omic collection using OmicSignatureCollection() from OmicSignature package
omic_collection <- OmicSignature::OmicSignatureCollection$new(
OmicSigList = base::list(omic_signature_1, omic_signature_2),
metadata = metadata
)
#> [Success] OmicSignature Collection my_collection created.
Upload a collection to the database
The addCollection()
function allows users to upload a
collection to the database.
IMPORTANT NOTE:
- The user MUST HAVE an
editor
oradmin
account to use this function. - A collection MUST BE an R6 object obtained from OmicSignature::OmicSignatureCollection()
SigRepo::addCollection(
conn_handler = conn_handler, # A handler contains user credentials to establish connection to a remote database
omic_collection = omic_collection, # An R6 object obtained from OmicSignature::OmicSignatureCollection()
visibility = FALSE, # Whether to make the collection public or private. Default is FALSE.
return_collection_id = FALSE, # Whether to return the uploaded collection id. Default is FALSE.
verbose = TRUE # Whether to print diagnostic messages. Default is TRUE.
)
#> Uploading each signature in the collection to the database...
#> Uploading collection metadata to the database...
#> Adding user to collection access table in the database...
#> Adding signature to the collection access table of the database...
#> Finished uploading.
#> ID of the uploaded collection: 16
Search for a collection in the database
The searchCollection()
function allows users to retrieve
all collections that are available in the database.
Example 1: Search for all collections
collection_tbl_1 <- SigRepo::searchCollection(conn_handler = conn_handler)
if(nrow(collection_tbl_1) > 0){
knitr::kable(
collection_tbl_1,
row.names = FALSE
)
}
collection_id | collection_name | description | user_name | date_created | visibility | collection_hashkey | signature_id | signature_collection_hashkey | signature_name |
---|---|---|---|---|---|---|---|---|---|
16 | my_collection | An example of signature collection | root | 2025-09-24 13:08:19 | 0 | 43c6365dc2edb6de573018eb53fdddc6 | 7 | 5878a7ab84fb43402106c575658472fa | Myc_reduce_mice_liver_24m_v1 |
16 | my_collection | An example of signature collection | root | 2025-09-24 13:08:19 | 0 | 43c6365dc2edb6de573018eb53fdddc6 | 8 | 006f52e9102a8d3be2fe5614f42ba989 | Myc_reduce_mice_liver_24m_v2 |
Example 2: Search for a specific collection by its name, e.g., collection_name = “my_collection”.
collection_tbl_2 <- SigRepo::searchCollection(
conn_handler = conn_handler,
collection_name = "my_collection"
)
if(nrow(collection_tbl_2) > 0){
knitr::kable(
collection_tbl_2,
row.names = FALSE
)
}
collection_id | collection_name | description | user_name | date_created | visibility | collection_hashkey | signature_id | signature_collection_hashkey | signature_name |
---|---|---|---|---|---|---|---|---|---|
16 | my_collection | An example of signature collection | root | 2025-09-24 13:08:19 | 0 | 43c6365dc2edb6de573018eb53fdddc6 | 7 | 5878a7ab84fb43402106c575658472fa | Myc_reduce_mice_liver_24m_v1 |
16 | my_collection | An example of signature collection | root | 2025-09-24 13:08:19 | 0 | 43c6365dc2edb6de573018eb53fdddc6 | 8 | 006f52e9102a8d3be2fe5614f42ba989 | Myc_reduce_mice_liver_24m_v2 |
Retrieve a set of collections in the database
The getCollection()
function allows users to retrieve a
set of collections that are PUBLICLY available in the
database.
IMPORTANT NOTE:
- Users can ONLY RETRIEVE a list of collections that are publicly available in the database including their own uploaded collections.
- If a collection is
PRIVATE
and belongs to other user in the database, users will need to be given aneditor
permission from its owner to access, retrieve, and edit their collections.
Example 1: Get all collections that are publicly available in the database
collection_list_1 <- SigRepo::getCollection(conn_handler = conn_handler)
#> now dyn.load("/Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library/curl/libs/curl.so") ...
#> [Success] OmicSignature object Myc_reduce_mice_liver_24m_v1 created.
#> [Success] OmicSignature object Myc_reduce_mice_liver_24m_v2 created.
#> [Success] OmicSignature Collection my_collection created.
Example 2: Get a specific collection that is publicly available or owned by user in the database, e.g., collection_name = “my_collection”
collection_list_2 <- SigRepo::getCollection(
conn_handler = conn_handler,
collection_name = "my_collection"
)
#> [Success] OmicSignature object Myc_reduce_mice_liver_24m_v1 created.
#> [Success] OmicSignature object Myc_reduce_mice_liver_24m_v2 created.
#> [Success] OmicSignature Collection my_collection created.
Update a collection metadata
The updateCollectionMetadata()
function allows users to
update the metadata information of a collection in the database.
IMPORTANT NOTE:
- Users MUST HAVE an
editor
oradmin
account to use this function. - Furthermore, users can ONLY UPDATE their own
uploaded signatures or were given an
editor
permission from its owner to access, retrieve, and edit their collections.
For example, if you wish to change the description of
“my_collection” in the database to “This is the
updated description.” You can use the
updateCollectionMetadata()
function as follows:
# 1. Let's search for my_collection in the database
collection_tbl <- SigRepo::searchCollection(
conn_handler = conn_handler,
collection_name = "my_collection"
)
# 2. If the collection exists, update it with the new description
if(nrow(collection_tbl) > 0){
SigRepo::updateCollectionMetadata(
conn_handler = conn_handler,
collection_id = collection_tbl$collection_id,
description = "This is the updated description."
)
}
#> collection_id = '16' has been updated.
Now, let’s search for my_collection
in the database and
see if its description has been updated.
# Search for my_collection in the database
collection_tbl <- SigRepo::searchCollection(
conn_handler = conn_handler,
collection_name = "my_collection"
)
# If the collection exists, output data table
if(nrow(collection_tbl) > 0){
knitr::kable(
collection_tbl,
row.names = FALSE
)
}
collection_id | collection_name | description | user_name | date_created | visibility | collection_hashkey | signature_id | signature_collection_hashkey | signature_name |
---|---|---|---|---|---|---|---|---|---|
16 | my_collection | This is the updated description. | root | 2025-09-24 13:08:19 | 0 | 43c6365dc2edb6de573018eb53fdddc6 | 7 | 5878a7ab84fb43402106c575658472fa | Myc_reduce_mice_liver_24m_v1 |
16 | my_collection | This is the updated description. | root | 2025-09-24 13:08:19 | 0 | 43c6365dc2edb6de573018eb53fdddc6 | 8 | 006f52e9102a8d3be2fe5614f42ba989 | Myc_reduce_mice_liver_24m_v2 |
Add signatures to an existing collection in the database
The addSignatureToCollection()
function allows users to
add a set of signatures to an existing collection in the database.
IMPORTANT NOTE:
- Users MUST HAVE an
editor
oradmin
account to use this function. - Furthermore, users can ONLY UPDATE their own
uploaded signatures or were given an
editor
permission from its owner to access, retrieve, and edit their collections.
For example, if you wish to create two new signatures (omic_signature_3, omic_signature_4) and add them to “my_collection” in the database.
# 1. Add omic_signature_3 to the database
signature_id_1 <- SigRepo::addSignature(
conn_handler = conn_handler,
omic_signature = omic_signature_3,
return_signature_id = TRUE,
verbose = FALSE
)
# 2. Add omic_signature_4 to the database
signature_id_2 <- SigRepo::addSignature(
conn_handler = conn_handler,
omic_signature = omic_signature_4,
return_signature_id = TRUE,
verbose = FALSE
)
# 3. Search for my_collection in the database
collection_tbl <- SigRepo::searchCollection(
conn_handler = conn_handler,
collection_name = "my_collection",
verbose = FALSE
)
# If both collection and signatures exist, add its signature ids to collection.
if(nrow(collection_tbl) > 0 && length(signature_id_1) > 0 && length(signature_id_2) > 0){
SigRepo::addSignatureToCollection(
conn_handler = conn_handler,
collection_id = collection_tbl$collection_id,
signature_id = c(signature_id_1, signature_id_2)
)
}
Now, let’s search for my_collection
in the database and
see if signature is added to the collection.
collection_tbl <- SigRepo::searchCollection(
conn_handler = conn_handler,
collection_name = "my_collection"
)
if(nrow(collection_tbl) > 0){
knitr::kable(
collection_tbl,
row.names = FALSE
)
}
collection_id | collection_name | description | user_name | date_created | visibility | collection_hashkey | signature_id | signature_collection_hashkey | signature_name |
---|---|---|---|---|---|---|---|---|---|
16 | my_collection | This is the updated description. | root | 2025-09-24 13:08:19 | 0 | 43c6365dc2edb6de573018eb53fdddc6 | 7 | 5878a7ab84fb43402106c575658472fa | Myc_reduce_mice_liver_24m_v1 |
16 | my_collection | This is the updated description. | root | 2025-09-24 13:08:19 | 0 | 43c6365dc2edb6de573018eb53fdddc6 | 8 | 006f52e9102a8d3be2fe5614f42ba989 | Myc_reduce_mice_liver_24m_v2 |
16 | my_collection | This is the updated description. | root | 2025-09-24 13:08:19 | 0 | 43c6365dc2edb6de573018eb53fdddc6 | 9 | 3636638817772e42b59d74cff571fbb3 | Myc_reduce_mice_liver_24m_v3 |
16 | my_collection | This is the updated description. | root | 2025-09-24 13:08:19 | 0 | 43c6365dc2edb6de573018eb53fdddc6 | 10 | a14ac55a4f27472c5d894ec1c3c743d2 | Myc_reduce_mice_liver_24m_v4 |
Remove a list of signatures from a collection in the database
The removeSignatureFromCollection()
function allows
users to remove a list of signatures from a collection in the
database.
IMPORTANT NOTE:
- Users MUST HAVE an
editor
oradmin
access to use this function. - Furthermore, users can ONLY UPDATE their own
uploaded signatures or were given an
editor
permission from its owner to access, retrieve, and edit their collections.
For example, if you wish to remove Myc_reduce_mice_liver_24m_v1 from “my_collection” in the database
# 1. Lets' check if signature = Myc_reduce_mice_liver_24m_v1 is in my_collection
collection_tbl <- SigRepo::searchCollection(
conn_handler = conn_handler,
collection_name = "my_collection",
signature_name = "Myc_reduce_mice_liver_24m_v1"
)
# 2. If signature collection combo exists, remove the signature.
if(nrow(collection_tbl) > 0){
SigRepo::removeSignatureFromCollection(
conn_handler = conn_handler,
collection_id = collection_tbl$collection_id,
signature_id = collection_tbl$signature_id
)
}
#> Removing signature_id = '7' from collection_id = '16' completed.
Now, let’s search for my_collection
in the database and
see if the signature has been removed from the collection.
collection_tbl <- SigRepo::searchCollection(
conn_handler = conn_handler,
collection_name = "my_collection"
)
if(nrow(collection_tbl) > 0){
knitr::kable(
collection_tbl,
row.names = FALSE
)
}
collection_id | collection_name | description | user_name | date_created | visibility | collection_hashkey | signature_id | signature_collection_hashkey | signature_name |
---|---|---|---|---|---|---|---|---|---|
16 | my_collection | This is the updated description. | root | 2025-09-24 13:08:19 | 0 | 43c6365dc2edb6de573018eb53fdddc6 | 8 | 006f52e9102a8d3be2fe5614f42ba989 | Myc_reduce_mice_liver_24m_v2 |
16 | my_collection | This is the updated description. | root | 2025-09-24 13:08:19 | 0 | 43c6365dc2edb6de573018eb53fdddc6 | 9 | 3636638817772e42b59d74cff571fbb3 | Myc_reduce_mice_liver_24m_v3 |
16 | my_collection | This is the updated description. | root | 2025-09-24 13:08:19 | 0 | 43c6365dc2edb6de573018eb53fdddc6 | 10 | a14ac55a4f27472c5d894ec1c3c743d2 | Myc_reduce_mice_liver_24m_v4 |
Delete the whole collection from the database
The deleteCollection()
function allows users to delete a
collection from the database.
IMPORTANT NOTE:
- Users MUST HAVE an
editor
oradmin
account to use this function. - Furthermore, users can ONLY DELETE their own
uploaded collections or were given an
editor
permission from other users in the database to access and delete their collection. - A collection can ONLY BE REMOVED OR DELETED one at a time.
# 1. Search for my_collection in the database
collection_tbl <- SigRepo::searchCollection(
conn_handler = conn_handler,
collection_name = "my_collection"
)
# 2. If the collection exists, remove it from the database
if(nrow(collection_tbl) > 0){
SigRepo::deleteCollection(
conn_handler = conn_handler,
collection_id = collection_tbl$collection_id
)
}
#> Remove collection_id = '16' from 'collection' table of the database.
#> Remove collection_id = '16' from 'collection_access' table of the database.
#> Remove signatures belongs to collection_id = '16' from 'signature_collection_access' table of the database.
#> collection_id = '16' has been removed.
Finally, let’s search for my_collection
in the database
and see if the collection has been removed.
collection_tbl <- SigRepo::searchCollection(
conn_handler = conn_handler,
collection_name = "my_collection"
)
#> There is no collection returned from the search parameters.