removing gene-gene interaction from a correlation matrix
1
0
Entering edit mode
8.3 years ago
zizigolu ★ 4.3k

Hi,

I have a list of transcription factors like below

TF <- read.table("whole TF.txt", header = T, sep = "\t")
> View(TF)
AGI_ID
AT1G01010
AT1G01030
AT1G01060
AT1G01160
AT1G01210
AT1G01250

and a correlation matrix contains both genes and transcription factors like below

>genes <- read.table("genes.txt", header = T, sep = "\t")
> library(netbenchmark)
> Net <- cor(genes)
> head(Net[1:4,1:4])

            AT1G01060   AT1G01170   AT1G01260   AT1G01380
AT1G01060  1.00000000  0.34783519 -0.09805551 -0.17400162
AT1G01170  0.34783519  1.00000000 -0.47605524  0.04211973
AT1G01260 -0.09805551 -0.47605524  1.00000000 -0.04742131
AT1G01380 -0.17400162  0.04211973 -0.04742131  1.00000000

In the above matrix I have interaction between gene-gene, gene-transcription factor and transcription factor-transcription factor. I want to remove gene-gene part from above matrix by setdiff function.

I did like below

nonTF <- setdiff(Net, TF)
Net <- Net[nonTF,nonTF]==0

but View(Net) is FALSE

Then how I can remove gene-gene interaction from my correlation matrix please?

Thank you

gene R • 1.9k views
ADD COMMENT
0
Entering edit mode

Note that my answer means you should use:

Net[nonTF, nonTF] <- 0

not

Net <- Net[nonTF, nonTF] <- 0
ADD REPLY
0
Entering edit mode

thank you I used

Net[nonTF, nonTF] <- 0

but no happen I saw

ADD REPLY
1
Entering edit mode

I know you won't get any output from that, but if you head() the file or View() it or whatever then it should be correct.

ADD REPLY
0
Entering edit mode

thank you,

may you please help me to remove gene-gene interaction from my matrix?

ADD REPLY
1
Entering edit mode

What I wrote will presumably set those to 0. There's no way to actually remove them from the matrix.

ADD REPLY
0
Entering edit mode

thank you I think I got your mean. you made those interaction 0. now how I can extract the resulted matrix (the matrix with gene-gene interaction=0) ??? because the result of

Net[nonTF, nonTF] <- 0

is only a value equal to 0 and not re writable or Viewable

ADD REPLY
1
Entering edit mode

That changes Net. Just View(Net). If you want that as a different object then

somethingNew <- Net
somethingNew[nonTF, nonTF] <- 0
ADD REPLY
0
Entering edit mode

sorry but

somethingNew <- Net

is the same

Net <- cor(genes)

while I need the result of

Net[nonTF, nonTF] <- 0

as a different object

ADD REPLY
2
Entering edit mode

I know, I showed you EXACTLY how to do that. Read what I wrote. There is no reason to ask any further questions about this, you've already received all the answers you need.

ADD REPLY
0
Entering edit mode

ok thank you

ADD REPLY
1
Entering edit mode
8.3 years ago

You presumably meant Net[nonTF, nonTF] <- 0 as the last line...

ADD COMMENT

Login before adding your answer.

Traffic: 3208 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