This function imputes missing values in the methylation matrix of a methyl_surro
object using either mean or median imputation.
It applies row-wise imputation based on a specified non-missing data proportion threshold.
Usage
impute_obs(methyl_surro, method = c("mean", "median"), min_nonmiss_prop = 0)
Arguments
- methyl_surro
An object of class
methyl_surro
, containing a methylation matrix.- method
A character string indicating the imputation method. Must be either
"mean"
or"median"
.- min_nonmiss_prop
The minimum proportion of non-missing data required in a probe (row) for the imputation to proceed. Must be a numeric value between 0 and 1.
Value
A methyl_surro
object with missing observations imputed, updating the methylation matrix as per the given method and threshold.
Examples
# Load the sample data
data(methyl_surro_miss)
# Apply mean imputation with a specified threshold for non-missing data in probes
result <- impute_obs(methyl_surro_miss, "mean", min_nonmiss_prop = 0.5)
#> 1 probes were not imputed because they did not meet the threshold. Please use methyl_miss() to see details.
# Check the imputed result
print(result$methyl)
#> samp1 samp2 samp3 samp4 samp5
#> cg02 0.2875775 NA NA 0.8830174 NA
#> cg07 0.8998250 0.2460877 0.6070843 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 NA NA NA NA NA
#> cg06 NA NA NA NA NA
#> cg11 NA NA NA NA NA
#> cg15 NA NA NA NA NA
#> cg18 NA NA NA NA NA