This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Help with 2 list in R, comparing gene ID to get refined information from both

Hello Guys, I need a little help from those who know R a lot. I am still learning and despite trying alone I still get stuck in some task. For example, I have these 2 files separated by tab. And I need to compare the ensembl id's s so I can get How many Up-regulated genes X Down-regulated genes I have per chromosome and also per band. Can someone help me? I think this should be quite easy but still....to hard for a beginner like 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 gene-list rna-seq r

1 answer

Use read.table() with the header flag ON to read into a data.frame, then use frame$columnName to access data.

Did not help much

You might wanna Google individual parts of my answer. Giving you the entire solution is easy, but not helpful in the long term.

I still need some help here, I am trying alone has been a while and am tired

Think of it this way: You have a tab separated file that you want to read to a data frame. From your other questions, you wish to manipulate these data frames by merging/joining them based on values from a common column.

Google key phrases and look for answers that might help you. In your case, "read tab separated file to R data frame" and "merge data frames based on common values" might be good starting points.

Thank you for trying help, I found a solution myself:

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"))

Excellent, congratulations! You're now one step closer to becoming the R expert that will always help you out. I am glad you were able to solve it so fast.

Thank you very much.

Log in to answer this question.