Question: keeping only same gene names in two matrices
0
gravatar for A
3.9 years ago by
A3.6k
A3.6k wrote:

hello,

I have two matrices of gene IDs with the same dimension but whenever I am trying to measure fscore using them telling

networks have not the same node names
> head(A[,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
> dim(A)
[1] 3123 3123
> head(B[,1:4])
          AT5G10140 AT5G11260 AT5G62020 AT5G20240
AT5G10140         0         0         0         0
AT5G11260         0         0         1         0
AT5G62020         0         0         0         0
AT5G20240         0         0         0         0
AT3G54340         0         0         0         0
AT3G27010         0         0         0         0
> dim(B)
[1] 3123 3123

how I can have these two matrices with the same gene names? I mean keeping the same genes and removing which is different between two matrices then two matrices become will have the same genes

thank you 

myposts R gene • 790 views
ADD COMMENTlink modified 3.9 years ago by raffael.azevedo20 • written 3.9 years ago by A3.6k
1
gravatar for raffael.azevedo
3.9 years ago by
Brazil
raffael.azevedo20 wrote:

Greetings Fereshteh.

If i understood your question, a simple workaround is creating a character vector containing the Arabidopsis gene names you want and subsetting the two matrices by your vector, then you should get only what you want.

Ex.:

> genes <- c("AT3G54340", "AT5G10140")
> new_A <- subset(A, by = genes)
> new_B <- subset(B, by = genes)
ADD COMMENTlink written 3.9 years ago by raffael.azevedo20

thank you very much, yes you understood my mean well but the question is , genes coming from where in other word which is my reference for subsetting? 

ADD REPLYlink written 3.9 years ago by A3.6k
1

Hi Fereshteh,

Your reference should be the genes you want to be the same. Another simple workaround is to use the function: 

unique()

ex.:

new_A <- unique(A)

new_B <- unique(B)

you can also bind them by column using cbind() and apply unique() to the new data.frame.

I am not quite sure if this is what you are looking for, but send me a message anytime. 

Regards,

R.

ADD REPLYlink modified 3.8 years ago • written 3.8 years ago by raffael.azevedo20

thank you so much

ADD REPLYlink written 3.8 years ago by A3.6k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 826 users visited in the last hour