Skip to contents

Summarize a region using regional principal components

Usage

summarize_region(region, region_map, meth, pc_method, verbose = FALSE)

Arguments

region

String; name of region being processed

region_map

Data frame; Mapping of CpGs to regions, column 1 should be regions, column 2 should be CpGs with the same names as the rows of meth

meth

Data frame or matrix; Methylation values to summarize; rows=CpGs, columns=samples

pc_method

String; indicating the method for estimating dimension; "gd"=Gavish-Donoho (default), "mp"=Marchenko-Pastur

verbose

Boolean; print output statements

Value

list containing PC results

Examples

# Create the region map with just one region containing 10 CpGs
region_map <- data.frame(region_id = rep(1, 10), cpg_id = seq(1, 10))

# Create methylation data frame
set.seed(123)
meth <- as.data.frame(matrix(runif(10 * 20, min = 0, max = 1), nrow = 10))
rownames(meth) <- seq(1, 10)

# Call the function
summarize_region(1, region_map, meth, 'gd')
#> $sig_pcs
#>              PC1
#> V1  -0.564912548
#> V2   0.715951191
#> V3  -0.336531053
#> V4  -0.058331274
#> V5   0.470009961
#> V6   0.004381512
#> V7  -0.254467804
#> V8   0.127777677
#> V9  -0.720377570
#> V10  0.062732873
#> V11 -0.415496705
#> V12 -0.508541629
#> V13  0.850919298
#> V14 -0.589314206
#> V15  0.644142819
#> V16  0.276779506
#> V17  0.149794967
#> V18 -0.100766203
#> V19  0.236932180
#> V20  0.009317009
#> 
#> $percent_var
#>                                  PC1
#> percent_variance_explained 0.2617874
#> 
#> $loadings
#>            PC1
#> 1   0.02704484
#> 2  -0.16219089
#> 3  -0.04079215
#> 4  -0.46213734
#> 5  -0.17035293
#> 6   0.11151863
#> 7  -0.41946509
#> 8  -0.55109199
#> 9  -0.33254661
#> 10  0.35500796
#> 
#> $est_dim
#> [1] 1
#> 
#> $num_cpgs
#> [1] 10
#> 
#> $region
#> [1] 1
#>