Missing ratio: 19.01826%

From ZhangLabWiki
Jump to navigation Jump to search
RawNARemove<-function(data,missratio=0.3){
threshold<-(missratio)*ncol(data)
NaRaw<-which(apply(data,1,function(x) sum(is.na(x))>=threshold))
zero<-which(apply(data,1,function(x) all(x==0))==T)
NaRAW<-c(NaRaw,zero)
if(length(NaRAW)>0){
data1<-data[-NaRAW,]
}else{
data1<-data;
}
data1
}
setwd("/oasis/tscc/scratch/shg047/Estellar2016/mergeHapinfo")
data<-read.table("Estellar2016.MHL.txt",head=T,row.names=1)
dim(data)
data=RawNARemove(data)
library("impute")
data<-impute.knn(data.matrix(data))$data
sum(is.na(data))/(nrow(data)*ncol(data))
newdata<-t(na.omit(data))
mydata <- scale(newdata) # standardize variables
d <- dist(mydata, method = "euclidean") # distance matrix
fit <- hclust(d, method="ward")
pdf("hclust.pdf")
plot(fit) # display dendogram
dev.off()
x1<-grep("tumor|adenocarcinoma",colnames(data))
data1<-data[,x1]
save(data1,file="Estellar2016.tumor.MHL.RData")
x2<-grep("normal",colnames(data))
data2<-data[,x2]
save(data2,file="Estellar2016.normal.MHL.RData")