This is a test version of Biostars. For the public version, visit https://www.biostars.org.
making two matrices of genes the same size and same variable

Hi,

Happy new year

I have two matrics of genes like below

> mat <- read.table("aracne-tmatnorm_rld500.txt", header = T, sep = "\t", row.names=1)
> head(mat[,1:4])
          AT1G01060 AT1G01170 AT1G01180 AT1G01260
AT1G01060         0         0         0         0
AT1G01170         0         0         0         0
AT1G01180         0         0         0         0
AT1G01260         0         0         0         0
AT1G01380         0         0         0         0
AT1G01490         0         0         0         0
> # watching the dimension of matrix
> dim(mat)
[1] 3123 3123

> Newmat <- read.table("newMat.txt", header = T, sep = "\t", row.names=1)
> head(Newmat[,1:4])
          AT1G01060 AT1G01170 AT1G01180 AT1G01183
AT1G01060         0         0         0         0
AT1G01170         0         0         0         0
AT1G01180         0         0         0         0
AT1G01183         0         0         0         0
AT1G01260         0         0         0         0
AT1G01380         0         0         0         0
> # watching the dimension of matrix
> dim(Newmat)
[1] 3515 3515

How I can make these matrix the same size and variable, I mean I need two matrices with the same size, maybe

3123 3123

thank you for your help

gene

1 answer

use the %in% function in R asking what data of "mat" has the same row.name than newMat..

And if you are planning to normalize data, take care of all these files with only zeroes. They are not useful

thank you Antonio,

these are adjacency matrix that is why contain many zeroes, but i got confused how i can make them the same size because they both have row.name and col.name

Log in to answer this question.