keeping only same gene names in two matrices
1
0
Entering edit mode
9.0 years ago
zizigolu ★ 4.3k

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

gene R • 1.6k views
ADD COMMENT
1
Entering edit mode
9.0 years ago

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 COMMENT
0
Entering edit mode

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 REPLY
1
Entering edit mode

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 REPLY
0
Entering edit mode

thank you so much

ADD REPLY

Login before adding your answer.

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