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,
  use_simona = FALSE,
  ...
)

Arguments

grlist

Named list of GRanges objects.

keep_chr

Which chromosomes to keep.

filters

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.

g

ggnetwork object (or an igraph/tbl_graph to be converted to ggnetwork format).

node_filters

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".

edge_filters

A named list of filters to apply to the edge data.

ont

An ontology of class ontology_DAG.

terms

Term IDs to include. Can alternatively be an integer, which will be used to randomly sample N terms from the data.

remove_terms

Character vector of term IDs to exclude.

keep_descendants

Terms whose descendants should be kept (including themselves). Set to NULL (default) to skip this filtering step.

remove_descendants

Terms whose descendants should be removed (including themselves). Set to NULL (default) to skip this filtering step.

use_simona

Use dag_filter to filter terms.

...

Additional arguments passed to plot-specific functions.

Value

Converted data.

Named list of GRanges objects.

Functions

  • 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.

Examples

dat <- mtcars 
dat2 <- filter_dt(dat, filters=list(cyl=c(4,6)))
#> Filtered 'cyl' : 14 / 32 rows dropped.
if (FALSE) {
g <- get_monarch_kg()
g2 <- filter_kg(g)
}
ont <- get_ontology("hp")
#>  All local files already up-to-date!
#> Importing cached file: /github/home/.cache/R/KGExplorer/hp-international.owl
#> Adding term metadata.
#> IC_method: IC_offspring
#> Adding ancestor metadata.
#> Getting absolute ontology level for 25,301 IDs.
#> 900 ancestors found at level 2
#> Translating all terms to names.
#> + Returning a vector of terms (same order as input).
#> Converted ontology to: adjacency 
#> Getting absolute ontology level for 25,301 IDs.
ont2 <- filter_ontology(ont,terms=c("HP:0000001","HP:0000002"))
ont3 <- filter_ontology(ont,terms=100)
#> Randomly sampling 100 term(s).