This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How Can I fusionate 2 tables in R? So I can Count data.

I have this 2 lists, and I wanna fusionate the 2 table based in the Gene ID's. Then I can count how many ups and Downs per chromossome and band. SOme R expert can help me?

File1.txt

Group1    Band    Chromosome Name    Group2    Band    Chromosome Name    Group3   Band    Chromosome Name
ENSMUSG00000004707    H3    1    ENSMUSG00000005763    H2.3    1     ENSMUSG00000098895    H2.1   1
ENSMUSG00000006403    H3    2    ENSMUSG00000008136    B    2    ENSMUSG00000046814    E4    2
ENSMUSG00000008475    G3    3    ENSMUSG00000025917    A2    3    ENSMUSG00000004707    H3    3
ENSMUSG00000009772    E4    4    ENSMUSG00000025938    A3    4    ENSMUSG00000004552    H3    4

File2.txt

Group1    Expression    Group2    Expression    Group3   Expression
ENSMUSG00000004707    Up    ENSMUSG00000025938    Up    ENSMUSG00000004552    Up
ENSMUSG00000006403   Up     ENSMUSG00000025917    Up    ENSMUSG00000004707    Up
ENSMUSG00000008475    Down    ENSMUSG00000005763    Down    ENSMUSG00000046814    Down
ENSMUSG00000009772    Down    ENSMUSG00000008136    Down    ENSMUSG00000098895    Down
ensembl rna-seq r

See ?merge in R.

1 answer

I Found a solution myself. here is what I did:

library(reshape2)
library(plyr)
table1 <- read.delim('genescol.txt',header=T)
table2 <- read.delim('genescol2.txt',header=T)
res <- merge(table1,table2,by.x='Group1',by.y="Group1")
res.count2 <- count(res,vars = c("Band","Chromosome.Name","Expression"))

Log in to answer this question.