R Markdown

setwd(“/media/NAS3_volume2/shg047/Alice”) heatMap<-function(data){

# note: this function include correlation based heatmap (pearson or spearman) # data: row is gene and column is sample # colname and rowname cannot be NULL
# Usage example: # test<- matrix(runif(100),nrow=20) # colnames(test)=c(“A”,“A”,“A”,“B”,“B”) # rownames(test)=paste(“Gene”,1:20,sep=“”) # HeatMap(test)

library(“gplots”) colors <- colorpanel(75,“blue”,“yellow”,“red”) # colors <-bluered(75)

sidecol<-function(x){ x<-as.numeric(as.factor(x)) col<-rainbow(length(table(x))) sapply(x,function(x) col[x]) }

Hclust=function(x){hclust(x,method=“complete”)} #Distfun=function(x){as.dist((1-cor(t(x),method = “pearson”)^2))} ColSideColors=sidecol(colnames(data))

HeatmapR<-heatmap.2(data,trace=“none”, hclust=Hclust, cexRow = 1, cexCol = 1, ColSideColors=ColSideColors, density.info=“none”,col=colors, Colv=T,Rowv = F, keysize=0.9, margins = c(10, 10), xlab=F ) return(HeatmapR) }

heatmap figure plot

data1<-read.table(“PluDiff_allsample.txt”,head=T,sep = “”,row.names=1) colnames(data1)[grep(“ips”,colnames(data1))]=“iPS” colnames(data1)[grep(“NT”,colnames(data1))]=“SCNT” data1[data1>5]=5 HeatmapR<-heatMap(data.matrix(data1))

extract right part samples

HeatmapR<-heatMap(data.matrix(data1)) data1<-read.table(“PluDiff_allsample.txt”,head=T,sep = “”,row.names=1) data2<-read.table(“/media/Home_Raid1/shg047/work/Alice/mouse/entropy/allsample.txt”,head=T,sep = “”,row.names=1) input<-data2[,match(colnames(data1[,HeatmapR$colInd[round(ncol(data1)/2):ncol(data1)]]),colnames(data2))] x1<-grep(“ips”,colnames(input)) x2<-grep(“NT”,colnames(input)) iPS<-apply(input[,x1],1,function(x) shannon(x)) SCNT<-apply(input[,x2],1,function(x) shannon(x))

quantile(iPS,na.rm = T) quantile(SCNT,na.rm = T) wilcox.test(iPS,SCNT,paired = T,conf.int = TRUE) wilcox.test(iPS,SCNT,paired = F, conf.int = TRUE) wilcox.test(rnorm(10), rnorm(10, 2), conf.int = TRUE)

shannon <- function(p){ library(“entropy”) if (min(p) < 0 || sum(p) <= 0) return(NA) p.norm <- p[p>0]/sum(p) -sum(log2(p.norm)*p.norm) }

save.image(file = “heatmap.scRNA.alice.RData”)