as_tibble: Convert to a tibble

as_tibbleR Documentation

Convert to a tibble

Description

Convert multiple Genomic objects to tibbles

Usage

## S3 method for class 'DataFrame'
as_tibble(x, rangeAsChar = TRUE, ...)

## S3 method for class 'GenomicRanges'
as_tibble(x, rangeAsChar = TRUE, name = "range", ...)

## S3 method for class 'Seqinfo'
as_tibble(x, ...)

## S3 method for class 'GInteractions'
as_tibble(x, rangeAsChar = TRUE, suffix = c(".x", ".y"), ...)

## S3 method for class 'SummarizedExperiment'
as_tibble(x, rangeAsChar = TRUE, ...)

## S3 method for class 'TopTags'
as_tibble(x, ...)

Arguments

x

A Genomic Ranges or DataFrame object

rangeAsChar

Convert any GRanges element to a character vector

...

Passed to tibble::as_tibble()

name

Name of column to use for ranges. Ignored if rangeAsChar = FALSE

suffix

Suffix appended to column names for anchor1 and anchor2 of a GInteractions object. Only used if specifying rangeAsChar = FALSE

Details

Quick and dirty conversion into a tibble.

By default, GenomicRanges will be returned with the range as a character column called range and all mcols parsed as the remaining columns. Seqinfo information will be lost during coercion.

Given that names for ranges are considered as rownames in the mcols element, these can be simply parsed by setting rownames = "id" in the call to as_tibble()

When coercing a DataFrame, any Compressed/SimpleList columns will be coerced to S3 list columns. Any GRanges columns will be returned as a character column, losing any additional mcols from these secondary ranges

Coercion of SummarizedExperiment objects will be performed on the rowRanges() element, whilst for a GInteractions object, both anchors will returned with the default suffixes .x and .y

Defined as an S3 method for consistency with existing tidy methods

Value

A tibble

Examples

gr <- GRanges("chr1:1-10")
gr$p_value <- runif(1)
names(gr) <- "range1"
gr
as_tibble(gr)
as_tibble(gr, rownames = "id")
as_tibble(mcols(gr))
as_tibble(seqinfo(gr))

hic <- InteractionSet::GInteractions(gr, GRanges("chr1:201-210"))
hic$id <- "interaction1"
as_tibble(hic)


steveped/extraChIPs documentation built on Aug. 1, 2024, 12:36 a.m.