Brick_get_matrix_within_coords: Return a matrix subset between two regions.

View source: R/Brick_functions.R

Brick_get_matrix_within_coordsR Documentation

Return a matrix subset between two regions.

Description

Brick_get_matrix_within_coords will fetch a matrix subset after creating an overlap operation between both regions and the bintable associated to the Brick store. This function calls Brick_get_matrix.

Usage

Brick_get_matrix_within_coords(
    Brick,
    x_coords,
    y_coords,
    resolution,
    force = FALSE,
    FUN = NULL
)

Arguments

Brick

Required. A string specifying the path to the Brick store created with Create_many_Brick.

x_coords

Required. A string specifying the region to subset on the rows. It takes the form chr:start:end. An overlap operation with the associated bintable will be done to identify the bins to subset on the row

y_coords

Required. A string specifying the region to subset on the rows. It takes the form chr:start:end. An overlap operation with the associated bintable will be done to identify the bins to subset on the column

resolution

Optional. Default NA When an object of class BrickContainer is provided, resolution defines the resolution on which the function is executed

force

Optional. Default FALSE If true, will force the retrieval operation when matrix contains loaded data until a certain distance.

FUN

Optional. If provided a data transformation with FUN will be applied before the matrix is returned.

Value

Returns a matrix of dimension x_coords binned length by y_coords binned length. This may differ based on FUN.

See Also

Brick_get_matrix to get matrix by using matrix coordinates, Brick_get_values_by_distance to get values separated at a certain distance, Brick_fetch_row_vector to get values in a certain row/col and subset them, Brick_get_vector_values to get values using matrix coordinates.

Examples


Bintable.path <- system.file(file.path("extdata", "Bintable_100kb.bins"), 
package = "HiCBricks")

out_dir <- file.path(tempdir(), "get_matrix_coords_test")
dir.create(out_dir)

My_BrickContainer <- Create_many_Bricks(BinTable = Bintable.path, 
    bin_delim = " ", output_directory = out_dir, file_prefix = "Test",
    experiment_name = "Vignette Test", resolution = 100000,
    remove_existing = TRUE)

Matrix_file <- system.file(file.path("extdata", 
"Sexton2012_yaffetanay_CisTrans_100000_corrected_chr2L.txt.gz"), 
package = "HiCBricks")

Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
remove_prior = TRUE, resolution = 100000)

Brick_get_matrix_within_coords(Brick = My_BrickContainer,
x_coords = "chr2L:1:1000000",
y_coords = "chr2L:1:1000000",
resolution = 100000)

Brick_get_matrix_within_coords(Brick = My_BrickContainer,
x_coords = "chr2L:1:1000000",
y_coords = "chr2L:1:1000000",
resolution = 100000,
FUN = mean)



koustav-pal/HiCLegos documentation built on Nov. 5, 2022, 5:49 p.m.