Title: | Representing Different Biological Sets |
---|---|
Description: | BiocSet displays different biological sets in a triple tibble format. These three tibbles are `element`, `set`, and `elementset`. The user has the abilty to activate one of these three tibbles to perform common functions from the dplyr package. Mapping functionality and accessing web references for elements/sets are also available in BiocSet. |
Authors: | Kayla Morrell [aut, cre], Martin Morgan [aut], Kevin Rue-Albrecht [ctb], LluĂs Revilla Sancho [ctb] |
Maintainer: | Kayla Morrell <[email protected]> |
License: | Artistic-2.0 |
Version: | 1.21.0 |
Built: | 2024-11-19 03:29:27 UTC |
Source: | https://github.com/bioc/BiocSet |
character()
The BiocSet
constructor, the show method, the
slot accessors, and creating a BiocSet
object from an
element set tibble rather than character vector(s).
BiocSet(..., metadata = list(), active = c("elementset", "element", "set")) ## S4 method for signature 'BiocSet' show(object) es_element(x) ## S4 method for signature 'BiocSet' es_element(x) es_set(x) ## S4 method for signature 'BiocSet' es_set(x) es_elementset(x) ## S4 method for signature 'BiocSet' es_elementset(x) BiocSet_from_elementset(elementset, element, set, metadata)
BiocSet(..., metadata = list(), active = c("elementset", "element", "set")) ## S4 method for signature 'BiocSet' show(object) es_element(x) ## S4 method for signature 'BiocSet' es_element(x) es_set(x) ## S4 method for signature 'BiocSet' es_set(x) es_elementset(x) ## S4 method for signature 'BiocSet' es_elementset(x) BiocSet_from_elementset(elementset, element, set, metadata)
... |
Named character() vectors of element sets, or a named list of character() vectors. Each character vector is an element set. The names of the character vectors are the names of the sets. |
metadata |
A list() with arbitrary content, describing the set. |
active |
A character(1) to indicate which tibble is active. The default is "elementset". |
object |
A |
x |
A |
elementset |
A tibble with element set information. |
element |
A tibble with element information. |
set |
A tibble with set information. |
An S4 BiocSet
object shown as a tripple tibble,
where each slot is a tibble.
element
The element tibble from 'tbl_elementset'
set
The set tibble from 'tbl_elementset'
elementset
The elementset tibble created from user input
active
A character(1), indicates which tibble is active
metadata
A list() with arbitrary elements describing the set
BiocSet(set1 = letters, set2 = LETTERS) lst <- list(set1 = letters, set2 = LETTERS) BiocSet(lst) set.seed(123) element <- tibble( element = letters[1:10], v1 = sample(10), v2 = sample(10) ) set <- tibble( set = LETTERS[1:2], v1 = sample(2), v2 = sample(2) ) elementset <- tibble( element = letters[1:10], set = sample(LETTERS[1:2], 10, TRUE) ) BiocSet_from_elementset(elementset, element, set)
BiocSet(set1 = letters, set2 = LETTERS) lst <- list(set1 = letters, set2 = LETTERS) BiocSet(lst) set.seed(123) element <- tibble( element = letters[1:10], v1 = sample(10), v2 = sample(10) ) set <- tibble( set = LETTERS[1:2], v1 = sample(2), v2 = sample(2) ) elementset <- tibble( element = letters[1:10], set = sample(LETTERS[1:2], 10, TRUE) ) BiocSet_from_elementset(elementset, element, set)
BiocSet
objectAll of the major methods applied to a BiocSet
object can
be explicitly applied to the element tibble. These functions bypass the
need to use the es_activate
function by indicating what function
should be used on the element tibble.
filter_element(.data, ...) select_element(.data, ...) mutate_element(.data, ...) summarise_element(.data, ...) arrange_element(.data, ...) left_join_element(.data, ...) tibble_from_element(.data, how = unlist) data.frame_from_element(.data, how = unlist)
filter_element(.data, ...) select_element(.data, ...) mutate_element(.data, ...) summarise_element(.data, ...) arrange_element(.data, ...) left_join_element(.data, ...) tibble_from_element(.data, how = unlist) data.frame_from_element(.data, how = unlist)
.data |
A |
... |
Additional arguments passed to the function. |
how |
Multiple entries will become a list. |
A BiocSet
object.
For tibble_from_element
, a tibble.
For data.frame_from_element
, a data.frame.
es <- BiocSet(set1 = letters, set2 = LETTERS) filter_element(es, element == "a") es %>% select_element(element) es %>% mutate_element(pval = rnorm(1:52)) es %>% summarise_element(n = n()) es %>% arrange_element(desc(element)) tbl <- tibble(x = 1:5, y = letters[1:5]) es <- BiocSet(set1 = letters[c(1,3,5)], set2 = letters[c(2,4)]) left_join_element(es, tbl, by = c(element = "y")) tibble_from_element(es) data.frame_from_element(es)
es <- BiocSet(set1 = letters, set2 = LETTERS) filter_element(es, element == "a") es %>% select_element(element) es %>% mutate_element(pval = rnorm(1:52)) es %>% summarise_element(n = n()) es %>% arrange_element(desc(element)) tbl <- tibble(x = 1:5, y = letters[1:5]) es <- BiocSet(set1 = letters[c(1,3,5)], set2 = letters[c(2,4)]) left_join_element(es, tbl, by = c(element = "y")) tibble_from_element(es) data.frame_from_element(es)
BiocSet
objectAll of the major methods applied to a BiocSet
object can
be explicitly applied to the elementset tibble. These functions bypass
the need to use the es_activate
function by indicating what
function should be used on the elementset tibble.
filter_elementset(.data, ...) select_elementset(.data, ...) mutate_elementset(.data, ...) summarise_elementset(.data, ...) arrange_elementset(.data, ...) left_join_elementset(.data, ...) tibble_from_elementset(.data) data.frame_from_elementset(.data)
filter_elementset(.data, ...) select_elementset(.data, ...) mutate_elementset(.data, ...) summarise_elementset(.data, ...) arrange_elementset(.data, ...) left_join_elementset(.data, ...) tibble_from_elementset(.data) data.frame_from_elementset(.data)
.data |
A |
... |
Additional arguments passed to the function. |
A BiocSet
object.
For tibble_from_elementset
, a tibble.
For data.frame_from_elementset
, a data.frame.
es <- BiocSet(set1 = letters, set2 = LETTERS) filter_elementset(es, element == "a" | element == "A") es %>% select_elementset(element) es %>% mutate_elementset(pval = rnorm(1:52)) es %>% summarise_elementset(n = n()) es %>% arrange_elementset(desc(element)) tbl <- tibble(x = 5:6, y = c("set1", "set2")) es %>% left_join_elementset(tbl, by = c(set = "y")) tibble_from_elementset(es) data.frame_from_elementset(es)
es <- BiocSet(set1 = letters, set2 = LETTERS) filter_elementset(es, element == "a" | element == "A") es %>% select_elementset(element) es %>% mutate_elementset(pval = rnorm(1:52)) es %>% summarise_elementset(n = n()) es %>% arrange_elementset(desc(element)) tbl <- tibble(x = 5:6, y = c("set1", "set2")) es %>% left_join_elementset(tbl, by = c(set = "y")) tibble_from_elementset(es) data.frame_from_elementset(es)
The following functions deal with converting a BiocSet
object into a GeneSetCollection
object, or vice versa.
GeneSetCollection_from_BiocSet(biocset) BiocSet_from_GeneSetCollection(gsc)
GeneSetCollection_from_BiocSet(biocset) BiocSet_from_GeneSetCollection(gsc)
biocset |
The |
gsc |
The |
For 'GeneSetCollection_from_BiocSet()', a GeneSetCollection.
For 'BiocSet_from_GeneSetCollection()', a BiocSet object.
biocset <- BiocSet(set1 = letters, set2 = LETTERS) gsc <- GeneSetCollection_from_BiocSet(biocset) gsc BiocSet_from_GeneSetCollection(gsc)
biocset <- BiocSet(set1 = letters, set2 = LETTERS) gsc <- GeneSetCollection_from_BiocSet(biocset) gsc BiocSet_from_GeneSetCollection(gsc)
Importing/exporting and formating of element sets as a
BiocSet
object.
## S4 method for signature 'GMTFile,ANY,ANY' import(con, format, text, ...) ## S4 method for signature 'BiocSet,GMTFile,ANY' export(object, con, format, ...) ## S4 method for signature 'OBOFile,ANY,ANY' import(con, format, text, ...) ## S4 method for signature 'BiocSet,OBOFile,ANY' export(object, con, format, ...)
## S4 method for signature 'GMTFile,ANY,ANY' import(con, format, text, ...) ## S4 method for signature 'BiocSet,GMTFile,ANY' export(object, con, format, ...) ## S4 method for signature 'OBOFile,ANY,ANY' import(con, format, text, ...) ## S4 method for signature 'BiocSet,OBOFile,ANY' export(object, con, format, ...)
con |
For |
format |
For |
text |
If con is missing this is a character vector directly providing the element set that should be imported. |
... |
Parameters to pass to the format-specific method |
object |
For 'export()', the object to be exported. |
For 'import()', a BiocSet object
For 'export()', a GMTFile object representing the location where the BiocSet object was written to
gmtFile <- system.file(package = "BiocSet", "extdata", "hallmark.gene.symbol.gmt") tbl <- import(gmtFile) tbl2 <- BiocSet(set1 = letters, set2 = LETTERS) fl <- tempfile(fileext = ".gmt") gmt <- export(tbl2, fl) oboFile <- system.file(package = "BiocSet", "extdata", "sample_go.obo") tst_obo <- import(oboFile) fl <- system.file("extdata", "sample_go.obo", package = "BiocSet") tbl <- import(fl) new_fl <- tempfile(fileext = ".obo") obo <- export(tbl, new_fl)
gmtFile <- system.file(package = "BiocSet", "extdata", "hallmark.gene.symbol.gmt") tbl <- import(gmtFile) tbl2 <- BiocSet(set1 = letters, set2 = LETTERS) fl <- tempfile(fileext = ".gmt") gmt <- export(tbl2, fl) oboFile <- system.file(package = "BiocSet", "extdata", "sample_go.obo") tst_obo <- import(oboFile) fl <- system.file("extdata", "sample_go.obo", package = "BiocSet") tbl <- import(fl) new_fl <- tempfile(fileext = ".obo") obo <- export(tbl, new_fl)
BiocSet
objectThis function performs an intersection within a single
BiocSet
object.
intersect_single(x, ...)
intersect_single(x, ...)
x |
A |
... |
Additional arguments passed to function. |
A BiocSet
object with a single set 'intersect' and
interesected elements from x.
es1 <- BiocSet(set1 = letters[c(1:10)], set2 = letters[c(4:20)]) intersect_single(es1)
es1 <- BiocSet(set1 = letters[c(1:10)], set2 = letters[c(4:20)]) intersect_single(es1)
Functions for dealing with unique mapping and multiple mapping.
map_add_element
will add the mapping as a new column instead of
overwriting the current one used for the mapping.
map_unique(es, org, from, to) map_multiple( es, org, from, to, multi = c("list", "filter", "asNA", "CharacterList") ) map_add_element(es, org, from, add)
map_unique(es, org, from, to) map_multiple( es, org, from, to, multi = c("list", "filter", "asNA", "CharacterList") ) map_add_element(es, org, from, add)
es |
The BiocSet objec to map the elements on. |
org |
The AnnotationDbi object to identify keys/mappings from. |
from |
A character to indicate which identifier to map from. |
to |
A character to indicate which identifier to map to. |
multi |
How should multiple values be returned? Options include:
|
add |
The id to add to the |
For map_unique
, a BiocSet
object with unique
elements.
For map_multiple
, a BiocSet
object with multiple
mappings for certain elements.
For map_add_element
, a BiocSet
object with a new column
in the element tibble with the mapping of the new id type.
library(org.Hs.eg.db) es <- BiocSet(set1 = c("C5", "GANC"), set2 = c("AFM", "CGB1", "ADAM32")) map_unique(es, org.Hs.eg.db, "SYMBOL", "ENTREZID") map_multiple(es, org.Hs.eg.db, "SYMBOL", "ENSEMBLTRANS", "asNA") map <- map_add_element(es, org.Hs.eg.db, "SYMBOL", "ENTREZID") es %>% mutate_element(entrez = map)
library(org.Hs.eg.db) es <- BiocSet(set1 = c("C5", "GANC"), set2 = c("AFM", "CGB1", "ADAM32")) map_unique(es, org.Hs.eg.db, "SYMBOL", "ENTREZID") map_multiple(es, org.Hs.eg.db, "SYMBOL", "ENSEMBLTRANS", "asNA") map <- map_add_element(es, org.Hs.eg.db, "SYMBOL", "ENTREZID") es %>% mutate_element(entrez = map)
Functions for creating BiocSet
objects from GO sets and
KEGG sets, and creating a new set mapping from a current BiocSet
object. map_add_set
will add the mapping as a new column instead
of overwriting the current one used for the mapping.
go_sets(org, from, go = c("GO", "GOID"), evidence = NULL, ontology = NULL) kegg_sets(species) map_set(.data, from, to) map_add_set(.data, org, from, add)
go_sets(org, from, go = c("GO", "GOID"), evidence = NULL, ontology = NULL) kegg_sets(species) map_set(.data, from, to) map_add_set(.data, org, from, add)
org |
The AnnotationDbi object to identify keys/mappings from. |
from |
A character to indicate which identifier to map from. |
go |
A character to indicate the column name for the GO ids. Default is "GO". |
evidence |
A character to indicate the evidence codes for GO associations with a gene of interest. Default is all possible evidence codes. |
ontology |
A character to indicate which Gene Ontology to use. Default is BP, CC, and MF. |
species |
Which species the pathways are from. |
.data |
The BiocSet object that contains the set tibble being mapped. |
to |
A character to indicate which identifier to map to. |
add |
The id to add to the |
For go_sets
, a BiocSet
object with GO ids as the set
ids.
For kegg_sets
, a BiocSet
object with Entrez IDs
reported as elements (default from KEGGREST) and KEGG pathways as sets.
For map_set
, a BiocSet object with the mapped set present in
the set tibble.
For map_add_set
, a BiocSet
object with a new column in
the set tibble with the mapping of the new id type.
library(org.Hs.eg.db) go <- go_sets(org.Hs.eg.db, "ENSEMBL") kegg_sets("hsa") es <- BiocSet(set1 = letters, set2 = LETTERS) es %>% map_set("set1", "foo") library(GO.db) map <- map_add_set(go, GO.db, "GOID", "DEFINITION") go %>% mutate_set(definition = map)
library(org.Hs.eg.db) go <- go_sets(org.Hs.eg.db, "ENSEMBL") kegg_sets("hsa") es <- BiocSet(set1 = letters, set2 = LETTERS) es %>% map_set("set1", "foo") library(GO.db) map <- map_add_set(go, GO.db, "GOID", "DEFINITION") go %>% mutate_set(definition = map)
OBOSet
objectThese functions will display the relationships (children,
parents, or ancestors) for either the elements or the sets of an
OBOSet
object.
oboset_element_children(oboset) oboset_element_parents(oboset) oboset_element_ancestors(oboset) oboset_set_children(oboset) oboset_set_parents(oboset) oboset_set_ancestors(oboset)
oboset_element_children(oboset) oboset_element_parents(oboset) oboset_element_ancestors(oboset) oboset_set_children(oboset) oboset_set_parents(oboset) oboset_set_ancestors(oboset)
oboset |
The |
A 2 column tibble.
oboFile <- system.file("extdata", "sample_go.obo", package = "BiocSet") obo <- import(oboFile) oboset_element_children(obo) oboset_element_parents(obo) oboset_element_ancestors(obo) oboset_set_children(obo) oboset_set_parents(obo) oboset_set_ancestors(obo)
oboFile <- system.file("extdata", "sample_go.obo", package = "BiocSet") obo <- import(oboFile) oboset_element_children(obo) oboset_element_parents(obo) oboset_element_ancestors(obo) oboset_set_children(obo) oboset_set_parents(obo) oboset_set_ancestors(obo)
A class representing the 'OBO' file format as a BiocSet.
OBOSet(elementset, element, set, metadata)
OBOSet(elementset, element, set, metadata)
elementset |
A tibble with element set information. |
element |
A tibble with element information. |
set |
A tibble with set information. |
metadata |
A tibble with key-value pairs describing OBO file format header data |
An S4 OBOOSet
object. OBO sets conform to the 'obo'
file format, with OBO 'Term' entries corresponding to
elements. Parent / child relationships (e.g., 'is_a') are
summarized as 'parents', 'ancestors', and 'children' character
list columns of 'set'.
OBOSet() oboFile <- system.file(package = "BiocSet", "extdata", "sample_go.obo") import(oboFile)
OBOSet() oboFile <- system.file(package = "BiocSet", "extdata", "sample_go.obo") import(oboFile)
BiocSet
objectAll of the major methods applied to a BiocSet
object can
be explicitly applied to the set tibble. These functions bypass the need
to use the es_activate
function by indicating what function should
be used on the element tibble.
filter_set(.data, ...) select_set(.data, ...) mutate_set(.data, ...) summarise_set(.data, ...) arrange_set(.data, ...) left_join_set(.data, ...) tibble_from_set(.data, how = unlist) data.frame_from_set(.data, how = unlist)
filter_set(.data, ...) select_set(.data, ...) mutate_set(.data, ...) summarise_set(.data, ...) arrange_set(.data, ...) left_join_set(.data, ...) tibble_from_set(.data, how = unlist) data.frame_from_set(.data, how = unlist)
.data |
A |
... |
Additional argument passed to the function. |
how |
Multiple entries will become a list. |
A BiocSet
object.
For tibble_from_set
, a tibble.
For data.frame_from_set
, a data.frame.
es <- BiocSet(set1 = letters, set2 = LETTERS) filter_set(es, set == "set1") es %>% select_set(set) es %>% mutate_set(pval = rnorm(1:2)) es %>% summarise_set(n = n()) es %>% arrange_set(desc(set)) tbl <- tibble(x = 10:11, y = c("set1", "set2")) es <- BiocSet(set1 = letters[c(1,3,5)], set2 = letters[c(2,4)]) left_join_set(es, tbl, by = c(set = "y")) tibble_from_set(es) data.frame_from_set(es)
es <- BiocSet(set1 = letters, set2 = LETTERS) filter_set(es, set == "set1") es %>% select_set(set) es %>% mutate_set(pval = rnorm(1:2)) es %>% summarise_set(n = n()) es %>% arrange_set(desc(set)) tbl <- tibble(x = 10:11, y = c("set1", "set2")) es <- BiocSet(set1 = letters[c(1,3,5)], set2 = letters[c(2,4)]) left_join_set(es, tbl, by = c(set = "y")) tibble_from_set(es) data.frame_from_set(es)
BiocSet
objectThis function performs a union within a single BiocSet
object.
union_single(x, ...)
union_single(x, ...)
x |
A |
... |
Additional arguments passed to function. |
For union_single
, a BiocSet
object with a single set
union
and unioned elements from x.
es3 <- BiocSet(set1 = letters[c(1:10)], set2 = letters[c(4:20)]) union_single(es3)
es3 <- BiocSet(set1 = letters[c(1:10)], set2 = letters[c(4:20)]) union_single(es3)
Functions to access reference urls for different identifiers
url_ref_element(es) url_ref_set(es) url_ref(es)
url_ref_element(es) url_ref_set(es) url_ref(es)
es |
A |
For url_ref_element
, a BiocSet
object with the url
column added to the element tibble.
For url_ref_set
, a BiocSet
object with the url column
added to the set tibble.
For url_ref
, a BiocSet
object with the url column
added to both the element and set tibbles.
es <- BiocSet("GO:0000002" = c("TP53", "TNF"), "GO:0000003" = c("IL6")) url_ref_element(es) url_ref_set(es) url_ref(es)
es <- BiocSet("GO:0000002" = c("TP53", "TNF"), "GO:0000003" = c("IL6")) url_ref_element(es) url_ref_set(es) url_ref(es)