data.imputeData {CTD}R Documentation

Impute missing values

Description

Impute missing values as lowest observed value in a reference population

Usage

data.imputeData(data, ref)

Arguments

data

- Normalized data with some missingness. Data matrix with features as rows, samples as columns.

ref

- Reference sample data with features as rows, samples as columns. Can include some missingness.

Value

imputed.data - Imputed data.

Examples

data(Thistlethwaite2020)
data_mx = Thistlethwaite2020
# Data with missing values
dt_w_missing_vals = data_mx[1:25,-seq_len(8)]
# Reference data can also have missing values
ref_data = data_mx[1:25,grep("EDTA-REF", colnames(data_mx))]
fil.rate = apply(ref_data, 1, function(i) sum(is.na(i))/length(i))
# Can only impute data that are found in reference samples
dt_w_missing_vals = dt_w_missing_vals[which(fil.rate<1.0),]
ref_data = ref_data[which(fil.rate<1.0),]
imputed.data = data.imputeData(dt_w_missing_vals, ref_data)
print(any(is.na(imputed.data)))

[Package CTD version 1.0.0 Index]