I have produced two matrices of the same size using R, from a microarray tsv file. One matrix with the log2FC of every gene in each of the 5 conditions and one matrix with the p.adjusted value of every gene in each of the 5 conditions. My goal is to find the genes that satisfy both the conditions log2FC>1 and p.adj<=0.05. I have tried the following:
con1<-matrix(which(log2FC>1|log2FC<(-1)))
con1
con2<-matrix(which(padj<=0.05))
con2
uu<-sapply(1:nrow(con1), function(i){
x<-con1[i]
which(x==con2)
})
uu1<-matrix(uu)
and the outcome is a list of the cells of con2 where the two conditions meet. However this is not very helpful as my goal is to create a matrix of genes that satisfy both conditions. I also tried
con1<-which((log2FC>1|log2FC<(-1)), arr.ind = TRUE, useNames = TRUE)
con2<-which((padj<=0.05),arr.ind = TRUE, useNames = TRUE)
which(rownames(con2)==rownames(con1))
but didn't work either.
Any thoughts?
I also tried duplicated
but the outcome is just the rowanmes, not the entire row.