Question: Extracting two matched columns from a file
0
gravatar for A
2.8 years ago by
A3.7k
A3.7k wrote:

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
    >
mirna R • 895 views
ADD COMMENTlink modified 2.8 years ago by theobroma221.1k • written 2.8 years ago by A3.7k
2

join. this can be easily googled.

ADD REPLYlink written 2.8 years ago by shenwei3565.0k
1

filter and substitute gene names

ADD REPLYlink written 2.8 years ago by genomax78k
3
gravatar for theobroma22
2.8 years ago by
theobroma221.1k
theobroma221.1k wrote:

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 COMMENTlink modified 2.8 years ago by RamRS25k • written 2.8 years ago by theobroma221.1k

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 REPLYlink written 2.8 years ago by A3.7k
2

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 REPLYlink modified 2.8 years ago • written 2.8 years ago by theobroma221.1k
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: 934 users visited in the last hour