This is a test version of Biostars. For the public version, visit https://www.biostars.org.
removing gene-gene interaction from a correlation matrix

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

Note that my answer means you should use:

Net[nonTF, nonTF] <- 0

not

Net <- Net[nonTF, nonTF] <- 0

thank you I used

Net[nonTF, nonTF] <- 0

but no happen I saw

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.

thank you,

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

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

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

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

somethingNew <- Net
somethingNew[nonTF, nonTF] <- 0

sorry but

somethingNew <- Net

is the same

Net <- cor(genes)

while I need the result of

Net[nonTF, nonTF] <- 0

as a different object

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.

ok thank you

1 answer

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

Log in to answer this question.