lol: Representing and manipulating list-of-list data structures.

View source: R/lol.R

lolR Documentation

Representing and manipulating list-of-list data structures.

Description

lol() constructs an indexed representation of an R 'list-of-lists', typically from JSON queries. The object is conveniently manipulated by other functions on this page to filter and select subsets of the structure, and to pull individual paths from across the list-of-lists.

lol_filter() filters available paths based on selections in ..., e.g., n (number of matching elements) or is_leaf (is the element a 'leaf' in the list-of-lists representation?).

lol_lpull() returns a list containing elements corresponding to a single path.

lol_pull() tries to simplify the list-of-lists structure returned by lol_lpull() to a vector.

lol_path() returns a tibble representing the paths through the list-of-lists, without the underlying list-of-list data.

as.list() returns a list-of-lists representation of the data returned by projects(), etc.

hca_next() returns the next 'page' of results, if available.

hca_prev() returns the previous 'page' of results.

lol_hits_lpull() and lol_hits_pull() are variants of lol_lpull() and lol_pull() that retain the original geometry of hits[*], even when the mapping between hits[*] and path is not 1:1.

Usage

lol(x = list())

lol_select(x, path = character())

lol_filter(x, ...)

lol_lpull(x, path)

lol_pull(x, path)

lol_path(x)

## S3 method for class 'lol'
as.list(x, ...)

## S3 method for class 'lol'
print(x, ...)

## S3 method for class 'lol_hca'
hca_next(x, size)

## S3 method for class 'lol_hca'
hca_prev(x, size)

lol_hits_lpull(x, path)

lol_hits_pull(x, path)

Arguments

x

a 'list-of-lists' returned by projects(), samples(), files(), or bundles()

path

character(1) from the tibble returned by lol_path(x).

...

for lol_filter(), named filter expressions evaluating to a logical vector with length equal to the number of rows in lol_path().

size

the (non-negative integer) number of elements to retrieve in the page request. The default is the number of elements requested in x.

Value

lol() returns a representation of the list-of-lists. The list has been processed to a dictionary with entries to all paths through the list, as well as a tibble summarizing the path, number of occurrences, and leaf status of each unique path.

lol_select() returns an object of class "lol" subset to contain just the elements matching path as 'top-level' elements of the list-of-lists.

lol_filter() returns an object of class lol, filtered to contain elements consistent with the filter criteria.

lol_lpull() returns a list, where each element corresponds to an element found at path in the list-of-lists structure x.

lol_pull() returns an unnamed vector of elements matching key.

hca_next() returns a list-of-lists containing the next 'page' of results.

hca_prev() returns a tibble with the same columns as x, containing the previous 'page' of results.

Examples

plol <- projects(size = 5, as = "lol")
plol

plol |> lol_select("hits[*].projects[*]")

plol |>
   lol_select("hits[*].projects[*]") |>
   lol_filter(n == 44, is_leaf)

plol |>
    lol_pull("hits[*].entryId") |>
    head()

plol |> lol_path()

projects <- projects(size = 5, as = "lol")     # projects 1-5
next_projects <- hca_next(projects)            # projects 6-10

hca_prev(next_projects)                        # projects 1-5


Bioconductor/hca documentation built on July 28, 2022, 6:04 p.m.