add_2D_features: add_2D_features

View source: R/add_2D_features.R

add_2D_featuresR Documentation

add_2D_features

Description

Adds 2D features to a gi_list instance. If any bin on gi_list overlaps with multiple feature records, features are aggregated among matches according to the univariate vector valued function agg (e.g., sum, mean). For efficient use of memory, using add/expand 1D features (see ?add_1D_features and expand_1D_features) in sequence is recommended instead of using add_2D_features directly for each chromosome.

Usage

add_2D_features(gi, df, features = NULL, agg = sum)

Arguments

gi

Element of a valid gi_list instance (restricted to a single chromosome e.g., gi_list[['chr9']]—see ?gi_list_validate for a detailed explanation of valid gi_list instances).

df

data frame for a single chromosome containing columns named chr, startI and startJ and features to be added with their respective names (if df contains multiple chromosomes, you can convert it into a list of smaller data.frames for each chromosome and apply this function with sapply).

features

features to be added. Needs to be subset of colnames(df). Defaults to all columns in df other than 'chr','start',and 'end'.

agg

any vector valued function with one data argument: defaults to mean.

Value

a gi_list element with 2D features stored in metadata handle (i.e., mcols(gi)).

Examples

df<-data.frame(chr='chr9',start=seq(1e6,10e6,1e6))
gi_list<-generate_df_gi_list(df,Dthreshold=500e3)
feats<-data.frame(chr='chr9',
startI=seq(1e6,10e6,1e6),startJ=seq(1e6,10e6,1e6),counts=rpois(10,lambda=5))
gi_list[['chr9']]<-add_2D_features(gi_list[['chr9']],feats)

mervesa/HiCDCPlus documentation built on June 8, 2022, 3:43 a.m.