R/shaman_feature_grid.R
shaman_generate_feature_grid.Rd
shaman_generate_feature_grid
1d intervals representing feature 1. Strand, if provided will be ignored.
1d intervals representing feature 2. Strand, if provided will be ignored.
Name of observed 2D genomic track for the hic data.
Name of expected 2D genomic track.
Name of 2D score track. If track doesn't exist, no filter on grid will be applied.
Minimum value of score within the expanded window surrounding the grid point for the window to be considered in the statistics.
Window size around the grid point.
Size of bins (in base pairs).
Minimum distance between features on the grid.
Maximum distance between features on the grid.
list containing obs - observed matrix, sum of the number of observed contacts in each bin in the window, exp - expected matrix, sum of the number of expected contacts in each bin in the window, grid_size - number of windows included in statistics
Build a grid comprising of all combinations of intervals from feature 1 and feature 2 that fall within a band defined by min_dist and max_dist. For each point on the grid, look at th surrounding window, defined by range parameter. Discard all windows that do not contain a point with a score (defined in scotre_track_nm) above the score_filter parameter. This allows for focusing on potentially enriched pairs. Discect the window into small bins, size in base pairs defined by the resolution parameter, and count the number of observed contacts, and the number of expected contacts in each bin. All windows are then summed together, generating a single matrix of observed and expected contacts, which is returned by function. Note that grid contains only points in which feature 1 position is smaller than feature 2 position.
# Set misha db to test
gsetroot(shaman_get_test_track_db())
#> Error in setwd(groot): cannot change working directory
grid <- shaman_generate_feature_grid(shaman::ctcf_forward, shaman::ctcf_reverse, "hic_obs",
exp_track_nm = "hic_exp"
)
#> Error in shaman_generate_feature_grid(shaman::ctcf_forward, shaman::ctcf_reverse, "hic_obs", exp_track_nm = "hic_exp"): Missing obs_track_nm ( hic_obs ) in track db
plot <- shaman_plot_feature_grid(list(grid), 25000, 500, 1000)
#> Error: object of type 'closure' is not subsettable