P<-read.table("input_table.txt",sep="\t",header=T) len <- ncol(p) rownames(p) <- p[,1] for(i in 2:ncol(p)-1) { d <-p[,i] l <- p[,len] #accessing the length column cS <- sum(as.numeric(p[,i])) #Total mapped reads per sample rpkm[[i]] <- (10^9)*(as.numeric(p[,i]))/(as.numeric(l)*cS) rpkm[[1]] <- p[[1]] } write.table(rpkm,"output_table_rpkm.txt",sep="\t",quote=F,row.names=F)
Comments
Using Perl script,
http://bioinformaticsonline.com/snippets/view/28043/rpkm-normalization-perl