Wrapper that instantiates a gWalk object from a variety of different inputs. If a gGraph is provided as input (in conjunction with sedge.id, snode.id, or grl input) then will check for existence of the provided walks in the provided graph, and will error out if those walks do not exist).

gW(
  snode.id = NULL,
  sedge.id = NULL,
  grl = NULL,
  graph = NULL,
  meta = NULL,
  circular = NULL,
  drop = FALSE,
  disjoin = FALSE
)

Arguments

snode.id

list of (possibly negative) integer signed node ids in a gGraph

sedge.id

list of (possibly negative) integer signed edge ids in a gGraph,

grl

GRangesList of walks in the genome, each walk is a (stranded) GRangesList, if graph is NULL will build a gGraph from the provided GRangesLists

graph

an existing graph from which to build a graph (used in conjunction with snode.id, sedge.id, or grl), if used with grl will attempt to match up the provided grl's with edges in the graph, if the GRL walks non-existent edges, then will error out

drop

logical flag only relevant when snode.id is specified indicating whether to drop any walks that refer to non-existent edges

disjoin

relevant for grl input when graph is NULL. If TRUE (default FALSE) will create a graph taking the GRanges disjoin of the GRanges comprising the provided GRL

Value

gWalk object of provided walks, with pointers back to the graph to which they refer.

Examples


## read in GRangesList of walks
walks.grl = readRDS(system.file('extdata', 'gw.grl.rds', package = "gGnome"))

## read in gGraph
gg = readRDS(system.file('extdata', 'walks.gg.rds', package="gGnome"))

## create gWalks from GRangesList - creates graph in which walks are disconnected, i.e. phased,
## so there may be several intervals per reference region
gW(grl = walks.grl)
#> gWalk object with 632 walks (632 linear and 0 circular)
#>    walk.id name length      wid circular ogid cn label is.cycle numsegs id str
#> 1:       1   1+      2   607203    FALSE    1  1  CN=1    FALSE       2  1   +
#> 2:       2   2+      2 34712403    FALSE    3  1  CN=1    FALSE       2  2   +
#> 3:       3   3+      2 18352603    FALSE    5  2  CN=2    FALSE       2  3   +
#> 4:       4   4+      2  4496203    FALSE    7  1  CN=1    FALSE       2  4   +
#> 5:       5   5+      2   484860    FALSE    9  3  CN=3    FALSE       2  5   +
#>                                                  gr
#> 1:                  6:1-607202+ -> 6:607202-607202+
#> 2:          15:1-34712402+ -> 15:34712402-34712402+
#> 3:          17:1-18352602+ -> 17:18352602-18352602+
#> 4:             20:1-4496202+ -> 20:4496202-4496202+
#> 5: 5:180430402-180915260- -> 5:180430402-180430402-
#> 
#>  ... 
#> (627 more walks )

## disjoin graph from GRangesList, these refer to a single disjoint graph
## where there is one interval per reference region
gW(grl = walks.grl, disjoin = TRUE)
#> gWalk object with 632 walks (632 linear and 0 circular)
#>    walk.id name length      wid circular ogid cn label is.cycle numsegs id str
#> 1:       1   1+      3   607203    FALSE    1  1  CN=1    FALSE       2  1   +
#> 2:       2   2+      3 34712403    FALSE    3  1  CN=1    FALSE       2  2   +
#> 3:       3   3+      3 18352603    FALSE    5  2  CN=2    FALSE       2  3   +
#> 4:       4   4+      3  4496203    FALSE    7  1  CN=1    FALSE       2  4   +
#> 5:       5   5+      3   484860    FALSE    9  3  CN=3    FALSE       2  5   +
#>                                                                            gr
#> 1:                        6:1-607201+ -> 6:607202-607202+ -> 6:607202-607202+
#> 2:           15:1-34712401+ -> 15:34712402-34712402+ -> 15:34712402-34712402+
#> 3:           17:1-18352601+ -> 17:18352602-18352602+ -> 17:18352602-18352602+
#> 4:                20:1-4496201+ -> 20:4496202-4496202+ -> 20:4496202-4496202+
#> 5: 5:180430403-180915260- -> 5:180430402-180430402- -> 5:180430402-180430402-
#> 
#>  ... 
#> (627 more walks )

## thread GRangesList onto existing graph
gW(grl = walks.grl, graph = gg)
#> gWalk object with 632 walks (632 linear and 0 circular)
#>    walk.id name length      wid circular ogid cn label is.cycle numsegs id str
#> 1:       1   1+      3   607203    FALSE    1  1  CN=1    FALSE       2  1   +
#> 2:       2   2+      3 34712403    FALSE    3  1  CN=1    FALSE       2  2   +
#> 3:       3   3+      3 18352603    FALSE    5  2  CN=2    FALSE       2  3   +
#> 4:       4   4+      3  4496203    FALSE    7  1  CN=1    FALSE       2  4   +
#> 5:       5   5+      3   484860    FALSE    9  3  CN=3    FALSE       2  5   +
#>                                                                            gr
#> 1:                        6:1-607201+ -> 6:607202-607202+ -> 6:607202-607202+
#> 2:           15:1-34712401+ -> 15:34712402-34712402+ -> 15:34712402-34712402+
#> 3:           17:1-18352601+ -> 17:18352602-18352602+ -> 17:18352602-18352602+
#> 4:                20:1-4496201+ -> 20:4496202-4496202+ -> 20:4496202-4496202+
#> 5: 5:180430403-180915260- -> 5:180430402-180430402- -> 5:180430402-180430402-
#> 
#>  ... 
#> (627 more walks )

## from lists of signed node ids
nid.list = list(c(-888, 322, 324, 325, 325), c(-708, 699, -706, 701, 702, 702))
gW(snode.id = nid.list, graph = gg)
#> gWalk object with 2 walks (2 linear and 0 circular)
#>    walk.id name length      wid circular
#> 1:       1    1      5 24328766    FALSE
#> 2:       2    2      6  7398500    FALSE
#>                                                                                                                                                                 gr
#> 1:                                      6:167305032-171115067- -> 16:13381188-24492574+ -> 16:24525261-33932601+ -> 16:33932602-33932602+ -> 16:33932602-33932602+
#> 2: 3:195251330-198022430- -> 3:170034877-173225490+ -> 3:193965508-195251276- -> ... -> 3:173225788-173376801+ -> 3:173376802-173376802+ -> 3:173376802-173376802+

## from lists of signed edge ids
eid.list = list(c(-1462, 1461), c(-133, -132, -134))
gW(sedge.id = eid.list, graph = gg)
#> gWalk object with 2 walks (2 linear and 0 circular)
#>    walk.id name length      wid circular
#> 1:       1    1      2 27454982    FALSE
#> 2:       2    2      3 13122971    FALSE
#>                                                                                               gr
#> 1:                       19:31674004-59128983- -> 19:31674003-31674003- -> 19:31674003-31674003-
#> 2: 17:70483463-81195210- -> 2:38052780-40464000+ -> 2:40464001-40464001+ -> 2:40464001-40464001+