Skip to content

Instantly share code, notes, and snippets.

@mbk0asis
Last active March 4, 2018 08:50
Show Gist options
  • Save mbk0asis/29292f8dffdc16d6019901084e4aec0a to your computer and use it in GitHub Desktop.
Save mbk0asis/29292f8dffdc16d6019901084e4aec0a to your computer and use it in GitHub Desktop.
setwd("/home/bk/Desktop/hg38")
dta <- read.csv("L1.6kb.CpG.rel.pos.csv",header = F, sep = ",")
dim(dta)
dta.t <- t(dta[,-1])
dta.t <- dta.t[,colSums(is.na(dta.t))<nrow(dta.t)]
nc <- ncol(dta.t)
res <- lapply(1:nc,function(i) {
h<-hist(dta.t[,i], plot=F, breaks = 10)
print(h$density)
})
res<-matrix(unlist(res), ncol=10)
colnames(res) <- c("bin1","bin2","bin3","bin4","bin5",
"bin6","bin7","bin8","bin9","bin10")
head(res)
tail(res)
write.csv(res,"CpG.density.L1.6kb.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment