Combine conditions between two matrices of the same size
1
0
Entering edit mode
3.4 years ago
kbaitsi • 0

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?

r padjval log2FC conditions • 671 views
ADD COMMENT
0
Entering edit mode

I also tried duplicated

hh<-duplicated(rbind(con1,con2))
hh1<-as.matrix(hh)

but the outcome is just the rowanmes, not the entire row.

ADD REPLY
0
Entering edit mode
3.4 years ago
kbaitsi • 0

For anyone who might face the same problem since the matrices are of the same size.

which( ( (logFC>=1) | (logFC <= -1) ) & (pvadj<=0.05), arr.ind = TRUE, useNames = TRUE)
ADD COMMENT

Login before adding your answer.

Traffic: 3340 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6