rm(list = ls())
library(performanceEstimation)
setwd("")
dat = read.delim('merge.normalzie.txt',header = T)
add_dat = read.delim('con_sample1.txt',head = T)
dat = t(dat)
add_dat = t(add_dat)
colnames(dat) = dat[1,]
dat = dat[-1,]
colnames(add_dat) = add_dat[1,]
add_dat = add_dat[-1,]
index = match(colnames(dat),colnames(add_dat))
add_dat = add_dat[,index]
final_dat = rbind(dat,add_dat)
class = rep(NA,nrow(final_dat))
class[1:10] = rep(1,10)
class[11:length(class)] = 0
final_dat = cbind(final_dat,class = class)
final_dat = as.data.frame(final_dat)
chr_judge = str(final_dat)
final_data = apply(final_dat, 2, function(x) as.numeric(x))
final_data = as.data.frame(final_data)
rownames(final_data) = rownames(final_dat)
final_data$class = as.factor(final_data$class)
for (i in 10:19) {
  rownames(final_data)[i+11] = paste0('Patient',i+1)
}
new_dat = smote(class~.,final_data,perc.over = 2,k = 1)
dim(new_dat)
rownames(new_dat)
new_dat$class

new_dat = cbind(id = rownames(new_dat),new_dat)
new_dat <- t(new_dat)

write.table(new_dat, file="Total_sample_generated_1.txt", sep="\t", quote=F, col.names=F)
