Extracting two matched columns from a file
2
0
Entering edit mode
7.6 years ago
zizigolu ★ 4.3k

Hi,

I have two list of miRNA-targets, big one is experimentally validated and another list I extracted myself by correlation analysis. I know how to merge by one column but how I can see how many of my miRNA-tragets are exist in experimentally validated list??

> head(data1)
             miRNA  Gene
    1    hsa-let-7 HMGA2
    2    hsa-let-7  NRAS
    3    hsa-let-7  KRAS
    4    hsa-let-7 IGF1R
    5    hsa-let-7 SOCS4
    6 hsa-let-7a-1 c-MYC
    > head(data2)
            miRNA     Gene
    1 hsa-miR-424  SLC25A2
    2 hsa-miR-20b   APCDD1
    3 hsa-miR-30b SERPINI1
    4 hsa-miR-152  TNFSF14
    5 hsa-miR-20b    EGLN1
    6 hsa-miR-20b ARHGEF10
    > dim(data1)
    [1] 62858     2
    > dim(data2)
    [1] 298   2
    >
R miRNA • 1.8k views
ADD COMMENT
2
Entering edit mode

join. this can be easily googled.

ADD REPLY
1
Entering edit mode
ADD REPLY
3
Entering edit mode
7.6 years ago
theobroma22 ★ 1.2k

Try

mg= intersect(data1$Gene , data2$Gene )

UPDATE:

Look at it like this. Here are two dataframes of the same size:

data1 = data.frame(ID = LETTERS[1:10], Gene = LETTERS[10:1])
data2 = data.frame(ID = LETTERS[8:18], Gene = LETTERS[18:8])
mg1 = intersect( data1$Gene, data2$Gene) 
mg1
> mg1
[1] "J" "I" "H"

And, here are two dataframes of different size:

data3 = data.frame(ID = LETTERS[1:10], Gene = LETTERS[10:1])
data4 = data.frame(ID = LETTERS[8:12], Gene = LETTERS[12:8])
mg2 = intersect( data3$Gene, data4$Gene)
mg2
> mg2
[1] "J" "I" "H"
ADD COMMENT
0
Entering edit mode

Thank you

mg= intersect(data1$Gene , data2$Gene )

> View(mg)
Error in View : 'names' attribute [4] must be the same length as the vector [1]
> dim(mg)
NULL
>

how can I write mg file???

ADD REPLY
2
Entering edit mode

What if you just write, mg, in the command line?

And since this is a vector it should be length(mg), not dim(mg)!

ADD REPLY

Login before adding your answer.

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