How separate one column in two columns?
1
2
Entering edit mode
4.8 years ago
star ▴ 350

I have a table with two columns and I would like to separate its first column in two separated columns or remove some useless values.

Input:

Gene            Disease
MSMO1 (6307)    MICROCEPHALY, CONGENITAL CATARACT, AND P... (OMIM:616834)
SC5D (6309)     LATHOSTEROLOSIS (OMIM:607330), Lathosterolosis (ORPHA:46059)
COG1 (9382)     CONGENITAL DISORDER OF GLYCOSYLATION, TY... (OMIM:611209)
COG6 (57511)    CONGENITAL DISORDER OF GLYCOSYLATION, TY... (OMIM:614576)
UBE3A (7337)    15q11q13 microduplication syndrome (ORPHA:238446)

Output:

Gene            Disease
MSMO1          MICROCEPHALY, CONGENITAL CATARACT, AND P... (OMIM:616834)
SC5D           LATHOSTEROLOSIS (OMIM:607330), Lathosterolosis (ORPHA:46059)
COG1           CONGENITAL DISORDER OF GLYCOSYLATION, TY... (OMIM:611209)
COG6           CONGENITAL DISORDER OF GLYCOSYLATION, TY... (OMIM:614576)
UBE3A          15q11q13 microduplication syndrome (ORPHA:238446)

Thanks for any solution in advanced.

R linix • 984 views
ADD COMMENT
2
Entering edit mode

I know it is not what you want to hear and probably you will be annoyed but I can only repeat what I commented on your last question ( how make a data table by merging three data sets? ) as this is exactly the same kind of underlying problem:

You should really try and find answers for these kinds of problems yourself. I remember you asked this kind of question before in a different context and got many solutions. Try to understand the logic behind it. There is no point in spoon-feeding as you cannot abstract it to different problems.

Get a background in basic Unix tool for data manipulation. There is no point in asking for spoon-feeding every time you encounter such a problem. I guarantee you this 100% can be done with basic awk commands. Spend quality-time learning it, really this is essential in bioinformatics. No offense intended.

See e.g. https://unix.stackexchange.com/questions/156919/splitting-a-column-using-awk

ADD REPLY
4
Entering edit mode
4.8 years ago
Gama313 ▴ 120
library(splitstackshape)
cSplit(df, 'Gene', sep=" ", type.convert=FALSE)
df<-df[-c(column_name_generated_after_split),]
ADD COMMENT

Login before adding your answer.

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