Functions to filter objects
filter_chromosomes(grlist, keep_chr = paste0("chr", c(seq_len(22), "X", "Y")))
filter_dt(dat, filters)
filter_graph(
g,
node_filters = list(),
edge_filters = list(),
rm_isolated = TRUE,
size = NULL
)
filter_kg(
g,
from_categories = paste0("biolink:", c("Disease", "PhenotypicFeature",
"GrossAnatomicalStructure", "AnatomicalEntity", "Cell")),
to_categories = from_categories,
edge_categories = NULL,
dbs = NULL,
rm_isolated = TRUE,
as_dt = FALSE
)
filter_ontology(
ont,
terms = NULL,
remove_terms = NULL,
keep_descendants = NULL,
remove_descendants = NULL,
include_self = TRUE,
use_simona = FALSE,
...
)
Named list of GRanges objects.
Which chromosomes to keep.
A named list, where each element in the list is the name of a column in the data, and the vector within each element represents the values to include in the final data.
tbl_graph object.
A named list of filters to apply to the node data.
Names should be name of the metadata column, and values should be a vector of
valid options. For example, list("type" = c("gene","variant"))
will
return any rows where the "type" column contains either "gene" or "variant".
A named list of filters to apply to the edge data.
An ontology of class ontology_DAG.
A vector of ontology term IDs.
Character vector of term IDs to exclude.
Terms whose descendants should be kept
(including themselves).
Set to NULL
(default) to skip this filtering step.
Terms whose descendants should be removed
(including themselves).
Set to NULL
(default) to skip this filtering step.
Use dag_filter to filter terms.
Arguments passed on to simona::dag_filter
dag
An ontology_DAG
object.
relations
A vector of relations. The sub-DAG will only contain these relations.
Valid values of "relations" should correspond to the values set in the
relations
argument in the create_ontology_DAG()
. If relations_DAG
is
already provided, offspring relation types will all be selected. Note "is_a"
is always included.
root
A vector of term names which will be used as roots of the sub-DAG. Only these with their offspring terms will be kept. If there are multiple root terms, a super root will be automatically added.
leaves
A vector of leaf terms. Only these with their ancestor terms will be kept.
mcols_filter
Filtering on columns in the meta data frame.
namespace
The prefix before ":" of the term IDs.
filter_chromosomes()
: filter_
Remove non-standard chromosomes
Remove non-standard chromosomes from a list of GRanges objects.
filter_dt()
: filter_
Filter a data.table.
filter_graph()
: filter_
Filter a tbl_graph.
filter_kg()
: filter_
Filter the monarch knowledge graph to only include edges between specific types of nodes (e.g. Disease <–> Cell).
filter_ontology()
: filter_
Filter ontology
Filter ontology by terms.
dat <- mtcars
dat2 <- filter_dt(dat, filters=list(cyl=c(4,6)))
#> Filtered 'cyl' : 14 / 32 rows dropped.
if (FALSE) { # \dontrun{
g <- get_monarch_kg()
g2 <- filter_kg(g)
} # }
ont <- get_ontology("hp")
#> Loading cached ontology: /github/home/.cache/R/KGExplorer/hp.rds
ont2 <- filter_ontology(ont,terms=c("HP:0000001","HP:0000002"))
#> Translating ontology terms to ids.
ont3 <- filter_ontology(ont,terms=100)
#> Randomly sampling 100 term(s).