Home > Software design >  Pasting multiple (unknown maximum) columns together past the 2nd column in R
Pasting multiple (unknown maximum) columns together past the 2nd column in R

Time:11-13

I have a data set that is a GMT file:

SHARMA_ASTROCYTOMA_WITH_NF1_SYNDROM http://www.gsea-msigdb.org/gsea/msigdb/human/geneset/SHARMA_ASTROCYTOMA_WITH_NF1_SYNDROM    ADGRV1  MAP3K7CL    CLEC3B  SLC1A3  STN1
LIU_OVARIAN_CANCER_TUMORS_AND_XENOGRAFTS_XDGS_UP    http://www.gsea-msigdb.org/gsea/msigdb/human/geneset/LIU_OVARIAN_CANCER_TUMORS_AND_XENOGRAFTS_XDGS_UP   RPLP0P11    PFN1P11 DSCAM-AS1   MT-TS2  FGB MT-TL2  PAX2    FOXB1   MAGEC2  SLC28A2 LINC02593   CPLX2   MGAT5B  SBK2    LEMD1-DT    ANK1    EVPLL   TGM7    LCN10   ENSG00000262884 DISP3   SIAH3   IGSF23  RD3 MYOM3   MIR4664 NAT8L   ALPL    LINC01001   FOXI3   KCNH3   GRIN2B  XKR7    CELSR3  CICP27  RASSF10 LINC02108   SKIDA1  STAG3L3 FAR2P1  LINC01224   ID1 WDR62   CCDC150 PLEKHG4B    RBM25-AS1   STAG3L5P    KIF18B  ZDHHC8P1    DDX12P  MKRN3   GOLGA2P5    TUBA5P  ZNF114  LINC00319   MYBL2   UCA1    KSR2    CYSRT1  MIR1302-9HG HASPIN  MKI67   CNGB1   MIR29B2CHG  GGT2P   CCNF    SNORD86 LY6G5B  FBN3    DUX4L27 RNFT2   ULBP3   MAP3K9  LINC01873   LINC01764   LINC00958   TROAP   PALM3   PIF1    OCLNP1  P2RY2   GPAT4-AS1   RAP1GAP2    ENSG00000260874 KIF12   PAX8-AS1    FAM215B MT-TH   PROX2   CLSPN   LHX4    SULT1A3 DACT2   GPC1-AS1    LINC01609   HS6ST1P1    CIT ADGRL1-AS1  AFG3L1P DLX4    PLXNA4  TICRR   PRPS1P2 RCOR2   JRK CLCNKA  DNAH10OS    PACSIN1 LINC01089   ESPL1   SPTBN5  MIR600HG    BPTFP1  POMK    NINL    ADGRL1  RECQL4  WASH4P  CLDN9   KIFC1   LINC00664   NECTIN1 ADRA1B  SSUH2   LINC00265   ARHGEF34P   OBSCN   SPAG5   OVOL1   EIF3CL  PBX2P1  KRT8P3  YWHAZP5 TUBAP2  H2BC12L AHCTF1P1    UBE2SP2 TUBBP1  PSMC1P1 RTN3P1  BANF1P3 HSP90AB3P   SETP14  DGKZP1  PPP1R14BP3  VDAC2P5 UBQLN4P1    TLK2P1  PHC1P1  YTHDF2P1    RANP1   PFN1P1  ATF4P3  RALGAPA1P1  BRD7P2  HMGB1P6 RAMACL  COX6A1P2    HMGB1P5 HNRNPA1P10  HNRNPA1P7   RNPS1P1 TPM3P5  HNRNPA3P6   SERBP1P5    HSPD1P1 DHFRP1  SRSF6P2 THAP12P7    RPSAP54 HSPB1P1 RPL6P27 PCBP2P2 PSMA6P1 HNRNPCP2    EIF4BP7 NPM1P7  FABP5P7 RPL26P30    YBX1P1  EIF4BP6 RANBP1P1    SUMO2P1 ATF4P4  RPS27AP5    XRCC6P2 EIF4HP1 EIF4A1P10   RPS7P10 TCEA1P2 GCSHP5  MTX1P1  TMEM183BP   SNRPGP15    NPM1P27 CSNK2A3 RPS7P11 SRP9P1  GDI2P2  CHCHD2P9    PPIAP22 RPL3P2  RPL7AP30    EEF1A1P6    RPL4P4  PGAM4   RPL6P10 PDIA3P1 PABPC3  CEP170P1    EIF4EP2 RPLP0P9 FAM3C2P DNAJB6P1    RPL10P6 ARPC3P3 SERBP1P1    RPL10P9 ANXA2P2 ST13P6  RPS24P19    RPL22P1 H3-5    LINC02067   RPL23AP42   BZW1P2  MXRA7P1 RPS27AP16   EIF2S2P4    SUMO2P21    EIF1AXP1    MEMO1P1 RPL4P5  EEF1B2P3    RPL35P2 GMPSP1  ENSG00000244398 RPL24P4 EIF3LP2 PRR13P5 RPL7P9  ARMC10P1    SPCS2P4 RPSAP15 DSTNP3  RAB6D   YWHAZP3
LIU_OVARIAN_CANCER_TUMORS_AND_XENOGRAFTS_XDGS_DN    http://www.gsea-msigdb.org/gsea/msigdb/human/geneset/LIU_OVARIAN_CANCER_TUMORS_AND_XENOGRAFTS_XDGS_DN   RPL7AP6 CACYBPP2    PTGES3P3    RPL15P3 HMGN2P5 BTF3L4P2    DYNC1I2P1   RAC1P2  FKBP1C  EIF2S3B ENSG00000174977 RPL7P1  RPS3AP26    CDC42P6 RPL26P36    RPL18AP3    MORF4L1P1   RPL12P4 RPL26P19    ITGB1P1 RPL5P4  PDIA3P2 RPL10P16    RPL39P3 FTH1P2  TWF1P1  RPL3P4  RPS27AP11   RPS3AP21    TAGLN2P1    NDUFB4P12   RPL21P16    RPL41P1 RPL5P1  RAB6C   RPS23P8 RPL13P12    EEF1B2P6    FTH1P10 RPS2P5  RAP1BL  RPS3AP6 SEPTIN7P3   RPL17P36    RPL13AP5    RPL9P7  NAMPTP1 RPS13P2 ZC3H12A-DT  PSD3    ST3GAL5 COL4A2-AS1  MANEA   SLC18A2 VWA1    ROBO2   IFNGR1  ITPR2   PDLIM5  ASPH    TPBG    FCHO2   CNTNAP1 GRK3    EAF2    ITGB6   TNFAIP8 BTN3A3  SERPINB1    MAP3K4-AS1  STARD5  PRICKLE2    PRKACB  RHOB    TPST2   ADAM22  SLIT2   BHLHE41 LPXN    MAFF    ADAMTSL4    SMARCA2 ANKRD44 APOBEC3G    CHN1    DYNLT3  WNT5A   MSN NFATC2  NME5    HSD17B11    CDKN1A  TMEM86A SLC16A3 IRF1    CAMK2D  CAVIN1  C10orf55    MGLL    HHIPL1  PSMB10  CAVIN3  DNAJB4  AMPD3   DERL3   BTN3A2  TSHZ1   SFXN3   ARL15   FZD1    PLEKHO2 UPP1    CTSL    FAM171B A4GALT  SEPTIN11    SPART   CTBS    B3GNT9  CISH    TMEM98  HLA-K   PDE5A   RASSF4  ITM2B   CALD1   FKBP5   IRS1    TRIM47  NIPAL2  PLS3    MTUS1   LDAF1   TIPARP  RPS27L  PREX2   SERPING1    STARD13 ANXA6   GPSM3   PLD1    CYP1B1  BTBD19  PRCD    RECK    TRIL    RAB42   PLK3    WNT5B   CYTOR   RTN4RL2 DEPTOR  CD40    HLA-J   CYRIA   IL6ST   PLAU    PPP3CC  ELOVL4  AHR CHN2    GSDME   IGDCC4  MARCHF3 ERAP2   C2  CDH2    CLIC4   NLRC5   CSPG4   SLPI    MAP1LC3A    PTEN    RIPOR2  IFIT3   HBEGF   MAN2A1  HLA-H   P3H3    HLA-E   SMOC2   ADORA2A KCNK6   MMRN2   SEMA3C  EOGT    KLRG1   RBPMS-AS1   BMERB1  ARRDC3  PDK4    IGFBP4  PTAFR   TIMP2   MYH11   TRPS1   RARRES2 PDE7B   SERPINB8    WFDC21P GPX8    CDK14   SATB2   PLOD2   SELENOP EVA1C   CASP10  CORO1A-AS1  SBSPON  MMP19   DSEL    HLA-A   CRISPLD2    DRAM1   NRROS   WASF3   PYCARD  LTBP2   FBLN5   KIF17   PYCARD-AS1  TNFAIP3 FLT3LG  MAP1B   ABCC3   LCN2    ICAM5   SNX10   ITGA2   GSDMC   CMTM3   LMOD1   OGFRL1  IL15    TAP1    SH3BGRL RORA    KLHDC1  HLA-DMB LACC1   SGPP1   DHRS3   SLC43A1 MAPK11  UBA7    ODAD2   TNFRSF11B   INPP4B  NLRC3   HCG4B   PPM1L   DUSP5   SEMA5B  GLIPR2  SLC16A14    ABHD3   SCARF2  CHST2   PPP1R16B    FAM43A  SLC7A7  CRACR2A APOL4   SDC2    BNC1    CCDC152 FKBP14  PAMR1   CSGALNACT1  MATN3   PSMB8-AS1   SPRED1  RRAS    SAMD5   IL7 ENSG00000225032 ALDH1A3-AS1 SLC2A13 SMIM3   CLVS1   POGLUT2 SCIMP   LGALS9  FHL2    SULF2   AFAP1L1 SCN1B   VSIR    LINC00511   ARSI    NRP2    ARHGAP10    AKR1C3  RAMP1   TLR3    SOD3    RAB8B   SERPINB9    FAM89A  TRABD2A FRMD3   STING1  CXCL3   EIF5A2  SOD2    DPYSL2  DOCK8   FAM78A  RAB27B  QPCT    RRAGD   TGFA    LRP1    FHOD3   POU2F2  C1QTNF6 SLC31A2 SYDE1   CASC15  HLA-C   DAPL1   LINC01140   EPSTI1  SIRPA   OSTM1   DPP7    PHLDA1  SETD7   SLCO2A1 GAS6    FAM126A CORO1A  RASGRP2 JAZF1   KCNS3   FTLP3   FAS LYSMD2  TNFRSF14    TNFRSF18    EXOC3L1 PLAT    DTNA    CHI3L1  NKX3-1  ATP2A3  EPS8    GAS6-AS1    GPR176  TTYH2   PPP2R2C ANOS1   ADGRB3  HCP5    CACNA2D4    JAK2    ADAMTSL2    LRCH2   GSPT2   HEG1    GAS6-DT CPP FAM13C  RASIP1  DNAJC12 CXCL1   MMP14   ITPR1   CFB FSTL1   IL32    RGL1    SLC16A2 FTL CP  KANK3   PDGFRL  IFIT2   LRRC8C  KCNK3   SP140   SLC1A1  SLITRK2 KLF6    GALNT18 NLRP1   MCC SERPINI1    PHLDB2  TRIM22  RAB3IL1 SAT1    PAG1    BEND6   TMEM154 CHST7   GPRASP1 CHRNA1  RGS7BP  SLC7A2  SKAP2   TMEM150C    ADGRE2  FAM81B  ZCCHC24 LXN F2R TMEM273 TCIM    COL12A1 TACC1   NAAA    CHST11  CILP2   RUNX1   PYGO1   ADCY4   NPTX2   JAK3    ESR1    SH3RF3  PPP2R2B AMIGO2  LGALS1  NR3C1   CA2 PLA2R1  TENM3   TAGLN   MRGPRF  SLFN11  FXYD5   LRRC17  GPR137B LRRC32  TARID   NTS SP6 EPAS1   GABRB3  SIRPB1  DGKI    VWC2    GBP2    SLC16A6 GJB6    PXDNL   VWA5A   GSTM5   ARHGAP24    CARD6   DCHS1   RCAN2   BCL2    ELN SYNE1   MT-TM   LPAR5   MN1 ITPRIP  WDR17   NOD2    NPY1R   FKBP7   PNMA2   C2CD4B  DCHS1-AS1   LHFPL2  EFCC1   NBL1    CCN1    PLCL1   PODNL1  MT1G    CFI FAM20A  KITLG   CARD16  TCF4    HOXC6   MRC2    C8orf88 MPP1    TSHZ2   TGFB1I1 THSD1   IGF1    STK17B  ERO1B   SNHG28  ALKAL2  ATP10D  MRAP2   NR4A1   H19 PLPPR3  WSCD1   NAP1L3  DCHS2   PDE3B   IL15RA  ME1 KCTD12  FBXO32  STOM    ELN-AS1 KCNK13  SNRPA1-DT   STEAP2  CLIC2   KCNAB2  GULP1   MIR100HG    CCDC69  TMEM47  SOCS2   ENSG00000253882 ATP1B2  PRKD1   OSBPL6  NEXN    FGF13   ACP5    NRXN2   TNFRSF9 OLFM1   CD200   NPR3    IL4R    PDZD4   ADM KCNA6   PAEP    PI15    SCG5    CMAHP   BMP6    SERPINA1    GNG11   RASA3   IL18    CAV1    TNFRSF11A   CXCL17  PKIB    GPR132  ZFPM2   DKK3    GUCY1A1 ELMO1   GRK5    PCK1    FST NR4A1AS TAFA2   SAMD9L  CACNA1G ICAM4-AS1   CD38    IFI30   STAT4   SIDT1   ADAMTS7 CYP27A1 HSPA12B GAS1    MT1H    SLC46A3 DOCK4   COL4A1  SNCAIP  CCL20   SPHK1   THSD7B  ANTXR1  MAN1C1  RHOBTB3 FCMR    MCTP1   CCDC68  HSPB8   KCNA5   TG  TBC1D4  HCAR2   STARD8  LDLRAD4 GHR FAM83B  NKD2    FLT4    LGALS2  FMO3    HSPA7   GDNF    SPOCK1  B2M KCNT2   HLA-DMA TNFSF10 GPR68   SGK1    HCST    PCED1B  MFNG    PLA2G7  NFASC   CPE MT2A    C1R PLAAT4  NUDT10  ACSL5   PDE1B   TIE1    RIMBP2  HP  NLRC4   CEBPD   SYCE1   CLIC6   SH2B3   HLA-B   PITX2   PALLD   CAVIN2  SECTM1  TRABD2B PDPN    SLC47A1 SLC4A4  CYP7B1  EMP3    CHGB    CYGB    CCDC85A ADGRA2  MT1E    PDZK1IP1    TLE4    DUSP2   HEYL    LAMB1   LIPA    ICAM1   DIRAS3  ALDH1A3 CPNE5   CALB2   PCOLCE2 CACNA1C ALPK2   DCLK1   TIMP3   BCL11B  HTR2B   ETS1    PDGFD   SLC24A3 APOL1   RARB    AXL MIAT    APOL6   CCDC80  SULT1C4 COPZ2   NOTCH4  TSPAN5  CPNE8   LAG3    SPIB    PDZRN4  UNC5C   PTN THSD7A  CNTN4   SELENOM SLC40A1 FNDC4   IL1RN   AQP1    COL2A1  ENPEP   JUNB    ENSG00000258086 ZNF365  PROCR   NECAB1  TLR6    SNCA    PDE1A   DPP4    IFI16   ADAMTSL1    FAT4    PEG3    SOCS3   GFRA1   NEFH    PIK3AP1 PLAUR   MEIS2   NR4A3   SFRP1   HLF VIM-AS1 LOX RFTN1   TESC    TM6SF1  THY1-AS1    SERPINE2    SQOR    AK5 DPYSL4  GRAP    ADCYAP1R1   JAM2    GGTA1   BIRC3   SYPL2   ITGA5   SOX18   CYBRD1  CCDC102B    ARHGAP20    STAMBPL1    ARHGAP30    ELL2    EMILIN2 PTPRE   SLITRK4 CD274   HEY1    HS3ST3A1    IL18R1  MARCHF1 PRRG3   MAPRE2  COL8A2  SATB1   ADAM8   ATRNL1  C3  PLPP4   ADA2    SLC12A5-AS1 GLRX    SLITRK5 SLC11A1 GTSF1   SRPX    ENSG00000253837 VIM CELF2   THY1    C16orf89    CLDN11  GNB4    SCARF1  CX3CR1  GASK1B-AS1  PLXDC1  IRAG2   APOE    CDC42EP5    CLEC11A ITIH3   FOXL1   PCSK6   GRIK3   WTAPP1  C2CD4C  LZTS1   KCND3   TNFAIP8L3   TBXAS1  CD96    TIMP1   ABLIM3  ACTG2   CHSY3   C12orf60    JCAD    PLVAP   BEND4   CD74    STK32B  PCYT1B  RTN1    GADD45B ABI3BP  DACT3   ARHGAP25    GLI1    PLA2G4C IL3RA   RGS16   PLCB2   VWFP1   RAMP2   BMP2    KLF9    SH2D3C  CD69    HNMT    AOC3    CACNA2D1    LOXL2   RUNX2   NTRK2   ZFHX4   PSMB9   MAOB    RCN3    IL6 CD44-AS1    ARHGDIB TBX15   A2M-AS1 RFTN2   RUBCNL  LYL1    LAT2    APELA   MEIS3   GALNT15 PTGER3  ST8SIA1 SLC1A6  PRELP   MLKL    KCNJ2   GFPT2   HLA-F   RERG    DOCK11  MICU3   PARM1   BMP4    PLSCR4  KLF2    CD44    FRMD6   PGR OSMR    ANGPTL2 SHE PCDH12  PKIA    GBP4    PPP1R2P4    IL16    RAC2    SEPTIN4 MXRA8   FGD5    NAV3    CTHRC1  IGFBP7  IDO1    RBMS3   PAPPA   PLD4    CILP    PON3    C4B-AS1 KCND2   ATP8B4  SYNPO   WFDC1   ADAMTS10    SNAP25  ADAP2   MME GATM    NRP1    SGCD    BCHE    SERPINB2    TMEM26  C4A-AS1 CD302   ASTN1   CASS4   ELOVL2  DPYSL3  NIBAN1  INMT    VAMP5   PTGER2  CORIN   ISM1    GUCY1A2 GATA6   ENG ENPP1   GATA4   GDF6    WAS P2RY1   SCG2    LAMA2   HLX TNFRSF8 SERPINA3    RAB31   OLFM4   HOXA-AS2    GEM JPH4    FEZ1    HLA-DOA CR1 DHRS9   SLC2A5  PTPRO   PLXNC1  CCN2    SSC5D   ODF3B   ARHGAP18    OLFML3  APCDD1  SCUBE2  GBP5    PRDM6   EMB HS3ST3B1    SYNPO2  CAMK4   LYPLAL1 STEAP4  PTGDS   CALHM5  LIN7A   RASGRP3 HS6ST2  CSMD1   RBP7    DLL4    STAB1   SCUBE1  C4A EHD2    ABCA9   GASK1B  CSMD2   LCK CD163L1 FGF7    SHOX2   SEMA6B  GAL3ST4 LMO2    CADM3-AS1   DLC1    CLMP    NFAM1   LAMP5   TSPAN8  NUPR1   KYNU    PTPN5   CCN5    FILIP1L CXCL2   MT1M    ADAMTS2 SUCNR1  SCN9A   TLR1    SERPINF1    PDE2A   WIPF1   LAMP5-AS1   SSTR1   CNR1    CADM3   ALOX5   DIO2    ARHGAP31    S100A9  RASSF2  CPED1   DEPP1   ZFP36   CHI3L2  C4B ELFN1   LRRC55  POU2AF1 RGCC    COX7A1  PTGIS   GPNMB   CD248   ST8SIA4 CHRD    TMEM158 MMP16   GPC6    GPR78   PSTPIP1 LCP1    NUDT11  CPZ CDC20B  CLDN5   TEK GPRIN3  MSRB3   C15orf48    MAGEL2  ZNF521  RGS2    TRPC6   EFEMP1  GLT8D2  MFAP4   BASP1   DUSP1   CD247   KLHDC7B CMKLR1  MFRP    C1QTNF5 CTSS    HMOX1   IGFBP7-AS1  CCBE1   HS3ST1  MDFIC   TMEM119 PEAR1   ANKRD22 TMOD2   G0S2    LILRB3  PELATON CCN2-AS1    PRKCB   LINC01018   SLC38A5 LRRC4B  TCEAL7  AKT3    GALNT5  ARHGEF15    HECW2   APOL3   FGD2    HMCN1   C1orf162    FERMT3  TFPI    CYS1    CLEC4A  ARSL    JAM3    MARCO   ENSG00000233968 HOXD10  GJA1    THBS1   TBX3    BICC1   EDA2R   MZB1    AEBP1   S100A8  ENOX1   SLAMF8  RASGRF2 ATP8A2  KCNJ8   FGF1    CASP1   ACAN    SLC16A7 PTHLH   TRPV2   PROS1   HTRA3   PMP22   C1S PCOLCE  AGAP2-AS1   EBI3    PTGS2   CFD TYMP    COL6A6  DNM3OS  SLC2A3  SPON2   SDS CD79A   MEGF10  SAA2    ABCB4   SELPLG  SAA2-SAA4   IRAK3   COL16A1 PAPSS2  CXCR6   UBD APOC1   P2RX7   ANPEP   RARRES1 IGLV1-51    VIT ECM1    ACVRL1  FLRT2   FMO1    SPATA18 APOBR   DACT1   CREB3L1 CCR1    PTPRB   TMEM255A    PLAGL1  FCGR1A  FOS CLMAT3  SPN NEGR1   RGS5    SELL    PARVG   GJB2    FIBIN   CD36    CXCL11  NPL FOSB    SAA1    AGAP2   DDR2    CSTA    CXCL12  IGLV6-57    HAND2   TNFRSF1B    MYO1G   COL6A1  FMO2    PODN    AMPH    AFF3    CNTN3   CALHM6  OLFML2B EBF1    MYO1F   SHC2    CYTIP   MEDAG   MAGI2-AS3   C3orf80 FN1 HLA-DRB6    KLHL6   GNA15   ZEB1    CHIT1   SCIN    MMP2    CEACAM7 SULF1   MMP11   CLEC7A  IL1B    CD68    LAMA4   NLGN4X  LRRN3   OLFML1  CXCL8   BCL6B   COMP    LILRA6  DPYD    PTPN7   TRPA1   TNFRSF4 CXCL10  WDFY4   HAS2    NID2    CD8A    MAF PWWP3B  RUNX1T1 GREM1   CD52    ARHGEF6 ENPP2   CD4 HLA-DRB1    HHIP    NCF2    BTK PCOLCE-AS1  GGT5    FBN1    TNFAIP8L2   EGR1    DKK2    KCNMB1  CTSK    EDN3    CBLN2   COL21A1 CCL2    PDE4B   SPARC   NR5A2   VSNL1   NT5E    S1PR1   TMEM176A    ZBTB16  IFFO1   COLEC12 GNG4    C5AR1   INPP5D  VNN1    TNFSF13B    MOXD1   C3orf70 IRAG1   MYOCD   LDB2    ERG SLC37A2 SLC9A9  MMP1    SMPDL3A GAB3    ESAM    GIMAP2  HLA-DRA LRRN4CL CERKL   TLR2    STX11   SFMBT2  PIK3CG  MAN1A1  CDH5    LPL CDO1    KDR ABCA8   SFRP2   VWF ACTA2   F5  PTPRN2  LHX9    HCLS1   IKZF1   EDNRB   XYLT1   IGSF6   AQP9    TSHZ3   TMEM176B    OR2I1P  IL2RG   ADAM23  RHOJ    COL8A1  ACTA2-AS1   PID1    CH25H   HAVCR2  PIEZO2  FOXF2   EGR2    PRKG1   PIK3R5  ADAMTS12    PLPPR4  CALCRL  PDCD1LG2    STAR    CSF2RA  BGN ADAMTS4 VSTM4   MSC TMEM204 HLA-DQB1    COL6A2  HIC1    COL5A1  NR5A1   APOD    ABCA6   CSF3R   TLL1    PROX1   LST1    SVEP1   CACNA1H COL5A3  LHFPL6  ABCG2   MSC-AS1 HTRA1   ADGRF5  TIGIT   ITGA1   AOAH    ZNF469  COL14A1 HLA-DPB1    ANGPT2  NLRP3   DPT HLA-DQB1-AS1    SHISA2  CFH C9  HLA-DPB2    CCND2   DAB2    CST7    SERPINE1    IL21R   CMKLR2  TAGAP   VGLL3   SRPX2   HBA1    ABI3    PCDH17  PTPN22  RASAL3  TGFBI   GNG2    NALF1   MEF2C   AOX1    GPR85   PRF1    ITGAM   PDLIM3  ADAM12  ITGBL1  HLA-DRB5    EGR3    EDNRA   EPYC    IL33    HBA2    SIGLEC7 CD34    OSCAR   SIGLEC10    ANTXR2  LRRK2   EMILIN1 NR1H4   ITGB2   TREM1   SIGLEC1 DOK2    IL10RA  PLCXD3  TLR7    FOLR2   IRF8    HLA-DPA1    JAML    TNFAIP6 ABCB1   ARHGAP9 NKG7    COL11A1 HEPH    COL5A2  ETV1    COL1A1  CLEC2B  TM4SF18 ITGAX   PDE10A  NDN SPP1    MMP9    THBS2   C1QTNF7 ITM2A   INHBA   PLN IGHV4-59    ZEB2    PRSS35  DOCK10  CPA3    PLA2G2A HAPLN1  HCK RCSD1   GPR4    TBX18   LPAR6   THBD    NNMT    A2M MMP13   CCL19   RAMP3   PRRX1   LRRC15  GPM6A   IGHV3-74    GMFG    SIGLEC9 C11orf96    ITGA4   ISLR    LSP1    EDIL3   HLA-DQB2    LINC01094   KLHL4   ECM2    HOPX    MGP NID1    HSD11B1 IGHM    PRDM1   HK3 CADPS   IL2RB   SCN7A   CDH11   EPHA3   PDGFRB  VNN2    FBXL7   COL15A1 ENAM    ARHGAP15    ECSCR   CCN4    RNASE6  OMD SNX20   SNAI2   PRDM8   PLA2G2D TMIGD3  TFEC    APOC4   APOC4-APOC2 KCNE4   ACKR1   RHOH    BCL2A1  SELP    TLR8    DOCK2   CD14    ITK FLI1    APOC2   LAIR1   COL1A2  RGS4    UBE2QL1 TMEM215 SPARCL1 CD209   TDO2    CXCL14  SPI1    VCAN    TPSB2   TPSAB1  FABP4   EPB41L3 BIN2    TMEM200A    ITGAL   TWIST1  ITGA8   SRGN    FNDC1   MEG3    NDNF    ITGA11  NTM PDGFRA  CNTN1   DOK6    GIMAP1  VCAN-AS1    CCR2    CCL21   DLK1    NCF4    LY86    FLT1    MPEG1   ASPN    OGN CSF2RB  FYB1    VAT1L   CYBB    TNFSF8  EMCN    CYTH4   ROBO4   FGR C1QTNF1 P2RY8   GIMAP8  IGHV3-48    ADH1B   CLEC4E  GIMAP5  PCED1B-AS1  GPR84   FGL2    VCAM1   IGHV1-24    CD300A  SLA CLEC14A CD3E    APBB1IP CDH13   CXCL13  COL10A1 CD300E  HLA-DQA2    CD28    FAP SIRPB2  LINC01929   CCL11   ARX SASH3   CD86    HGF CD180   IGHV4-31    CCL8    NRK DIPK2B  APLNR   LY96    SAMSN1  LILRB1  ADGRL4  LYZ SFRP4   TRBC2   CSF1R   CNRIP1  OLR1    MMRN1   LRRC25  MYCT1   LINC01614   F13A1   LUM POSTN   FOXF1   EVI2B   ALOX5AP CD53    IL2RA   GPR183  GPR34   COL6A3  NCKAP1L HLA-DQA1    GYPC    LAPTM5  JCHAIN  FCER1G  IGKV1-17    PTPRC   IL7R    SLAMF7  AIF1    OSM PLEK    EVI2A   FCGR2A  FCGR2C  IGHV1-46    SLCO2B1 GIMAP6  IGHV4-39    CD48    TLR4    C3AR1   ESM1    TCF21   CLEC5A  MSR1    IGHV1-69    LILRB2  COL3A1  MS4A4A  GIMAP4  IGHV2-26    CD163   GZMA    GIMAP7  GZMK    TREM2   IGHV3-66    LCP2    MNDA    ADAMDEC1    HBB MS4A7   CD84    FPR3    IGKV3-15    IGHV1-3 CD1E    LYVE1   FPR1    IGHV2-5 IGHV3-15    IGLV1-44    IGKV4-1 IGHV3-33    IGHJ6   CCR5    CD2 FCGR3A  IGHG1   IGHA2   IGHV3-21    IGLJ2   MS4A6A  IGHA1   IGHV1-2 TYROBP  IGHV3-7 CXCL9   IGKV1-16    CD93    CLEC10A IGKV3D-15   IGHV5-51    LILRB4  IGHV3-53    DCN IGLC3   IGLC2   IGLV3-10    IGKJ2   C7  IGKV3D-11   C1QB    C1QA    IGLV3-19    GPR65   IGKJ5   IGKC    IGLV1-47    IGKJ3   C1QC    IGKV3-11    FCGR3B  IGHV3-11    RGS1    IGHG3   IGHV1-18    FCN1    FCGR2B  IGLV1-40    IGHG2   IGKV3D-20   IGHG4   IGLV5-45    IGKV3-20    COPDA1  IGLJ1   HOXC12  IGKJ1   IGLV2-11    IGKV1-12    IGLV2-23    IGLL5   IGLV3-25    IGLC1   VSIG4   IGKJ4   IGLV3-1 IGHGP   IGKV1-5 IGLV3-21    IGKV1-9 IGLV2-14    IGHV3-23
BANG_VERTEPORFIN_ENDOMETRIAL_CANCER_CELLS_UP    http://www.gsea-msigdb.org/gsea/msigdb/human/geneset/BANG_VERTEPORFIN_ENDOMETRIAL_CANCER_CELLS_UP   CCN1    VCAN    COL12A1 THBS1   ITGAV   TFPI2   APP ANKRD1  GPC4    SEMA3C  GANAB   EGR1    ATP6AP2 ITGB4   ADAM9   GBA NUP210  DSG2    OS9 COL4A2

There are three columns, the pathway, the source and the genes in the pathway

I have read this into R using read.delim but the 3rd column onwards is read in as multiple tab separated columns dependant on the number of genes in that pathway (there are 6000 pathways in total).

I would like to concatenate all columns from the third column onwards to that they are comma seperated. So the first line as an example output would be:

SHARMA_ASTROCYTOMA_WITH_NF1_SYNDROM http://www.gsea-msigdb.org/gsea/msigdb/human/geneset/SHARMA_ASTROCYTOMA_WITH_NF1_SYNDROM    ADGRV1,MAP3K7CL,CLEC3B,SLC1A3,STN1

I know how to use paste0 but I am unsure how to do it when each row has a different number of columns beyond the third column.

Any help would be much appreciated.

Many thanks

CodePudding user response:

you can simply use unite and the column indexes. See example:

library(tidyverse)

mtcars |>
  unite(val, 4:ncol(mtcars), sep = ",")
#>                      mpg cyl  disp                          val
#> Mazda RX4           21.0   6 160.0   110,3.9,2.62,16.46,0,1,4,4
#> Mazda RX4 Wag       21.0   6 160.0  110,3.9,2.875,17.02,0,1,4,4
#> Datsun 710          22.8   4 108.0   93,3.85,2.32,18.61,1,1,4,1
#> Hornet 4 Drive      21.4   6 258.0 110,3.08,3.215,19.44,1,0,3,1
#> Hornet Sportabout   18.7   8 360.0  175,3.15,3.44,17.02,0,0,3,2
#> Valiant             18.1   6 225.0  105,2.76,3.46,20.22,1,0,3,1
#> Duster 360          14.3   8 360.0  245,3.21,3.57,15.84,0,0,3,4
#> Merc 240D           24.4   4 146.7      62,3.69,3.19,20,1,0,4,2
#> Merc 230            22.8   4 140.8    95,3.92,3.15,22.9,1,0,4,2
#> Merc 280            19.2   6 167.6   123,3.92,3.44,18.3,1,0,4,4
#> Merc 280C           17.8   6 167.6   123,3.92,3.44,18.9,1,0,4,4
#> Merc 450SE          16.4   8 275.8   180,3.07,4.07,17.4,0,0,3,3
#> Merc 450SL          17.3   8 275.8   180,3.07,3.73,17.6,0,0,3,3
#> Merc 450SLC         15.2   8 275.8     180,3.07,3.78,18,0,0,3,3
#> Cadillac Fleetwood  10.4   8 472.0  205,2.93,5.25,17.98,0,0,3,4
#> Lincoln Continental 10.4   8 460.0    215,3,5.424,17.82,0,0,3,4
#> Chrysler Imperial   14.7   8 440.0 230,3.23,5.345,17.42,0,0,3,4
#> Fiat 128            32.4   4  78.7    66,4.08,2.2,19.47,1,1,4,1
#> Honda Civic         30.4   4  75.7  52,4.93,1.615,18.52,1,1,4,2
#> Toyota Corolla      33.9   4  71.1   65,4.22,1.835,19.9,1,1,4,1
#> Toyota Corona       21.5   4 120.1   97,3.7,2.465,20.01,1,0,3,1
#> Dodge Challenger    15.5   8 318.0  150,2.76,3.52,16.87,0,0,3,2
#> AMC Javelin         15.2   8 304.0  150,3.15,3.435,17.3,0,0,3,2
#> Camaro Z28          13.3   8 350.0  245,3.73,3.84,15.41,0,0,3,4
#> Pontiac Firebird    19.2   8 400.0 175,3.08,3.845,17.05,0,0,3,2
#> Fiat X1-9           27.3   4  79.0   66,4.08,1.935,18.9,1,1,4,1
#> Porsche 914-2       26.0   4 120.3    91,4.43,2.14,16.7,0,1,5,2
#> Lotus Europa        30.4   4  95.1  113,3.77,1.513,16.9,1,1,5,2
#> Ford Pantera L      15.8   8 351.0   264,4.22,3.17,14.5,0,1,5,4
#> Ferrari Dino        19.7   6 145.0   175,3.62,2.77,15.5,0,1,5,6
#> Maserati Bora       15.0   8 301.0   335,3.54,3.57,14.6,0,1,5,8
#> Volvo 142E          21.4   4 121.0   109,4.11,2.78,18.6,1,1,4,2
  • Related