HI Vivek, I think there is only one row in the whole dataset which fulfills the condition.? If you need the dimension intact, use 'drop=FALSE' ?which(rowSums(mat1>0)==ncol(mat1)) #CXCL14 ?# 2349? #Simplied some codes: dat1<- read.table("FPKM_RZvsRP_expmat2_v3.txt",sep="\t",header=TRUE,stringsAsFactors=FALSE) dat2<- dat1 dat2[,13:22]<-lapply(list(c(2,3),c(4,7),c(4,8),c(5,7),c(5,8),c(6,7),c(6,8),c(9,12),c(10,12),c(11,12)),function(x) {dat2[,x[1]] - dat2[,x[2]]} ) ?colnames(dat2)[13:22]<-gsub("__","_",paste(c("p118",paste(rep("p132",6),c("",1:5),sep="_"),paste(rep("p91",3),c("",1:2),sep="_")),"diff",sep="_")) mat1<- as.matrix(dat2[,13:22]) row.names(mat1)<- dat2[,1] ?res<-mat1[rowSums(mat1>0)==ncol(mat1),,drop=FALSE] res #?????? p118_diff p132_diff p132_1_diff p132_2_diff p132_3_diff p132_4_diff #CXCL14? 3.606171? 1.241455??? 2.023101??? 1.413141??? 2.194787?? 0.5763301 ?# ???? p132_5_diff p91_diff p91_1_diff p91_2_diff #CXCL14??? 1.357977 3.485148?? 8.938696??? 6.29492 dim(res) #[1]? 1 10 A.K. ________________________________ From: Vivek Das <vd4mmind at gmail.com> To: arun <smartpink111 at yahoo.com> Sent: Friday, September 27, 2013 5:36 AM Subject: Some issues with operations HI Arun, I am facing some issues with the matrix operation in R. I am having a matrix ?with some genes and their corresponding expression values between samples. I am trying to see the the difference in expression values of the columns. Then making a matrix which will contain the whole data and its corresponding differences. Then am extracting only the difference of the columns I computed in a matrix and trying to separate the positive and the negative differences. I have worked with this earlier and I have not faced any issue. I have also applied it to other samples and they work perfectly fine. But I donot know this time its failing. I tried with other matrix I performed earlier and still they work. Somewhere here it does not. Can you please let me know where I am getting wrong ? I am sending you the code snippet and the matrix so that it makes sense to you. Code: ##### to check the transition from RZ to RP - 91 rz,118rz, 132rz1,132rz2 Vs 91rp1, 91rp3, 91rp4, 118rp3,132rp1, 132rp3, 132rp4 data<-read.table("",sep='\t', header=T) #calculate differences p118_diff<-c(as.numeric(data[,2])-as.numeric(data[,3])) p132_diff<-c(as.numeric(data[,4])-as.numeric(data[,7])) p132_1_diff<-c(as.numeric(data[,4])-as.numeric(data[,8])) p132_2_diff<-c(as.numeric(data[,5])-as.numeric(data[,7])) p132_3_diff<-c(as.numeric(data[,5])-as.numeric(data[,8])) p132_4_diff<-c(as.numeric(data[,6])-as.numeric(data[,7])) p132_5_diff<-c(as.numeric(data[,6])-as.numeric(data[,8])) p91_diff<-c(as.numeric(data[,9])-as.numeric(data[,12])) p91_1_diff<-c(as.numeric(data[,10])-as.numeric(data[,12])) p91_2_diff<-c(as.numeric(data[,11])-as.numeric(data[,12])) diff_m<-cbind(data,p118_diff,p132_diff,p132_1_diff,p132_2_diff,p132_3_diff,p132_4_diff,p132_5_diff,p91_diff,p91_1_diff,p91_2_diff) ##select all the positive differences mat1<- as.matrix(diff_m[,13:22]) row.names(mat1)<- diff_m[,1] res1<-mat1[rowSums(mat1>0)==ncol(mat1),] head(res1) In the above rest computation it is failing. as it cant give correct dimension for res1. I only get one row with 1 columns which should not be the idea case. I should get all the positive differences across all samples from the mat1 matrix. Can you please guide me where I am getting wrong? I am also attaching the matrix so that it works for you and you can understand where I am getting wrong. ---------------------------------------------------------- Vivek Das PhD Student in Computational Biology Giuseppe Testa's Lab European School of Molecular Medicine IFOM-IEO Campus Via Adamello, 16 Milan, Italy emails:?vivek.das at ieo.eu ??? ??? ??? vchris_05 at yahoo.co.in ??? ??? ??? vd4mmind at gmail.com