Skip to contents

This function fills in missing probes in the methylation matrix of a methyl_surro object based on external reference data. Users can specify if imputation should consider only fully missing rows, partially missing rows, or the entire dataset.

Usage

reference_fill(
  methyl_surro,
  reference,
  col_name = NULL,
  type = c("probes", "obs", "all")
)

Arguments

methyl_surro

An object of class methyl_surro, containing a methylation matrix.

reference

A named numeric vector or a matrix/data frame with row names, containing reference values for probes to impute missing data. If a matrix or data frame is provided, specify the column using the col_name argument.

col_name

Optional; character string specifying the column to use if reference is a matrix or data frame.

type

A character string specifying the scope for filling missing data:

  • "probes": Fill in only missing probes.

  • "obs": Fill in only missing observations

  • "all": Fill in missing probes and observations

Value

A methyl_surro object with its methylation matrix updated by filling in the specified missing probes based on the reference data.

Examples

# Load the sample data
data(methyl_surro_miss)
data(ref_df)

# Apply reference filling using a specific column of the reference data
result <- reference_fill(methyl_surro = methyl_surro_miss,
                         reference = ref_df,
                         col_name = "mean",
                         type = "probes")

# Check the result after filling
print(result$methyl)
#>          samp1     samp2     samp3     samp4      samp5
#> cg02 0.2875775        NA        NA 0.8830174         NA
#> cg07 0.8998250 0.2460877        NA 0.3279207 0.95450365
#> cg08 0.8895393 0.6928034 0.6405068 0.9942698 0.65570580
#> cg13 0.9630242 0.9022990 0.6907053 0.7954674 0.02461368
#> cg17 0.1428000 0.4145463 0.4137243 0.3688455 0.15244475
#> cg03 0.4948262 0.4948262 0.4948262 0.4948262 0.49482616
#> cg06 0.5526592 0.5526592 0.5526592 0.5526592 0.55265924
#> cg11 0.4566024 0.4566024 0.4566024 0.4566024 0.45660238
#> cg15 0.4004940 0.4004940 0.4004940 0.4004940 0.40049405
#> cg18 0.3923206 0.3923206 0.3923206 0.3923206 0.39232059