Last data update: 2014.03.03

R: Fill in missing data
fill.missingR Documentation

Fill in missing data

Description

This is the function to do missing data imputation.

Usage

fill.missing(data, method="knn", k=20, dist.method="euclidean")

Arguments

data

An object of class madata, which should be the result from read.madata.

method

The method to do missing data imputation. Currently only "knn" (K nearest neighbour) is implemented.

k

Number of neighbours used in imputation. Default is 20.

dist.method

The distance measure to be used. See dist for detail.

Details

This function will take an object of class madata and fill in the missing data. Currently only KNN (K nearest neighbour) algorithm is implemented. The memory usage is quadratic in the number of genes.

Value

An object of class madata with missing data filled in.

Author(s)

Hao Wu

References

O.Troyanskaya, M. Cantor, G. Sherlock, P. Brown, T. Hastie, R. Tibshirani, D. Botstein, & R. B. Altman. Missing Value estimation methods for DNA microarrays. Bioinformatics 17(6):520-525, 2001.

Examples

data(abf1)
# randomly generate some missing data 
rawdata <- abf1
ndata <- length(abf1$data)
pct.missing <- 0.05 # 5% missing
idx.missing <- sample(ndata, floor(ndata*pct.missing))
rawdata$data[idx.missing] <- NA
rawdata <- fill.missing(rawdata)
# plot impute data versus original data
plot(rawdata$data[idx.missing], abf1$data[idx.missing])
abline(0,1)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(maanova)

Attaching package: 'maanova'

The following object is masked from 'package:base':

    norm

> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/maanova/fill.missing.Rd_%03d_medium.png", width=480, height=480)
> ### Name: fill.missing
> ### Title: Fill in missing data
> ### Aliases: fill.missing
> ### Keywords: utilities
> 
> ### ** Examples
> 
> data(abf1)
> # randomly generate some missing data 
> rawdata <- abf1
> ndata <- length(abf1$data)
> pct.missing <- 0.05 # 5% missing
> idx.missing <- sample(ndata, floor(ndata*pct.missing))
> rawdata$data[idx.missing] <- NA
> rawdata <- fill.missing(rawdata)
Calculating pairwise distances ...
Missing data imputation ...
> # plot impute data versus original data
> plot(rawdata$data[idx.missing], abf1$data[idx.missing])
> abline(0,1)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>