This is a test version of Biostars. For the public version, visit https://www.biostars.org.
trying to merge two csv lists of genes with biomaRt

Is it possible to merge 2 csv file lists of genes using the merge() command? I simply have written the code merge("a file.csv", "another file.csv") but it's not working any hints?

Thanks

r

You should specify the argument All =T, check below.

3 answers

Hi,

First off, this is a straight R question, neither biomaRt nor genes is critical here. Honestly, I'm not entirely sure this is a bioinformatics question.

Second, here's how, assuming all you want is to append CSV file B to CSV file A using R: https://kb.iu.edu/d/bcrr

Ram RS,

so this command in the url you posted will merge R list objects that contain some named elements in common?

If so, great!

I think so. It reads CSV files into data frames and assuming headers match, merge them. Not sure how it will react to mismatched fields though. Might wanna do a trial or Google a bit more.

merge(x="a file.csv", y="another file.csv",All=True)

it will merge both files based on common columns.

if you have some specific lines there are the arguments: by.x and by.y where you can specify the columns.

Kizuna,

So that command seems to work as it returns this:

           x                y
1 a file.csv another file.csv

But how do I get R to print the merged list....?

merged.file=merge(x="a file.csv", y="another file.csv",All=True)
print(merged.file) ; head(merged.file, n=5)
write.table(merged.file,file="merged.file",sep="\t")

Hi Kizuna,

So it appears to be doing something but those commands are still not giving me what I want, it prints:

merged.file=merge(x="aabb.csv", y="another file.csv",All=True) 
> 
> print(merged.file) ; head(merged.file, n=5)
         x                y
1 aabb.csv another file.csv
         x                y
1 aabb.csv another file.csv

and then the last line doesn't print anything....

I saved two excel files as csv files and I am able to retrieve info about the gene lists contained with getBM() but when I type head("a file.csv") it just prints "a file".....

Log in to answer this question.