2つの行列の出力パラメータを連結しますか?

2つの行列の出力パラメータを連結しますか?

2つの行列を連結する必要があります。

$cat mat1:

sample  gen1    gen2    gen3    gen4  
pt1     1       4       7       10  
pt3     5       5       8       11 
pt4     3       6       9       12  

$cat mat2:

sample  age gender  stage   etc  
pt0     5   m       stage1  poi  
pt1     6   f       stage2  bmn  
pt2     9   m       stage3  yup   
pt3     7   f       stage4  qaz  
pt4     6   f       stage2  bmn

$join -o 1.1 1.2 1.3 1.4 2.4 mat1 mat2:

sample gen1 gen2 gen3 stage  
pt1    1    4    7    stage2  
pt3    5    5    8    stage4  
pt4    3    6    9    stage2  

私の実際の行列にはmat1約20,000列があるので、1.1 1.2 ..1.20,000を書くことは不可能です。-o行列 1 のすべての列を記述するために任意のパラメータバリアントを使用mat2できます。

ベストアンサー1

-o(から)には対応するオプションはありませんman join

-o FORMAT
       obey FORMAT while constructing output line

   FORMAT is one or more comma  or  blank  separated
   specifications,  each  being  `FILENUM.FIELD'  or `0'.  Default FORMAT
   outputs the join field, the remaining fields from FILE1, the remaining
   fields  from  FILE2,  all separated by CHAR.  If FORMAT is the keyword
   'auto', then the first line of each  file  determines  the  number  of
   fields output for each line.

cutまず適切な列を選択してから結合します。

join -t ' ' mat1 <(cut -f1,4 mat2)

(たとえば、引用符の間のタブ:Ctrl+ VTAB
、または19999までのすべての列に対して、mat1次のことができます。

cut -f-19999 mat1 | join -t ' ' - <(cut -f1,4 mat2)

おすすめ記事