20140120: Day #1 for Kajita's class

About this class (Kajita's part)

1. Practice of Unix like environment using Cygwin or Mac OS: CygwinやMac OSを用いたUnixライク環境の体験

2. Preparation for Unix like Environment: Terminal or Cygwin環境の設定:Cygwinのインストール

  1. Cygwin: Windows環境で動くUNIXエミュレータ。このソフトウェアをインストールすることで、UNIXのCLIで使われる様々な機能を簡単に体験することができます。 A UNIX environment emulator that works on Windows PC. A wide range of UNIX software can be installed on demand.

Cygwinのインストール: Installation of Cygwin

Startup Cygwin and preparation for window setting: Cygwinの起動とウィンドウ設定の変更

  1. プロパティの変更: ウィンドウ左上のCを右クリックしてプロパティを選択
    • オプションタブをクリック:
      • バッファサイズを200ぐらいに
      • 簡易編集モードをチェック(これで、マウスの右クリックでテキストのコピー・ペーストが可能)
    • レイアウトタブをクリック
      • 画面サイズを好みの大きさに(今回は幅95, 高さ20にしてみた)
    • ウィンドウを閉じて終了「このウィンドウを起動したショートカットを変更する

3. Basics of Unix commands Unixライク環境の基本操作:

Text

Appendix: Japanese explanation from previous classes

  1. Cygwinの起動とウィンドウ設定の変更
  2. コマンドラインインターフェースの使い方
  3. 文字を使っファイルやたディレクトリの表し方とディレクトリの構成
  4. ディレクトリに関する基本コマンド(命令)
    • カレントディレクトリの表示: pwd : show the current directory
    • ディレクトリの内容表示: ls : list the contents of the directory
    • ディレクトリへの移動: cd : change directory
    • ディレクトリ間のファイルコピー: cp ; 移動: mv 別ディレクトリへのファイルの移動・名前の変更
      • cp : copy file, mv : move file
    • 新しいディレクトリの作成: mkdir
    • ファイルの削除: rm
    • コンソールへの文字の表示: echo : display strings in the console
      • 例: ファイルの作成
        echo test > test.txt
        This command will make a file "test.txt" in which a letter "test" is stored.
    • ファイルの内容の表示: cat : display the contents of the text file
    • ファイルの削除: rm :: delete a file
    • ディレクトリの作成: mkdir : make new directory

初めてのコマンドラインインターフェース: Unix-like CLI

文字を使っファイルやディレクトリの表し方とディレクトリの構成

ディレクトリに関する基本命令

Compile source code under Cygwin: 解析用プログラムのインストール

・ソースコードをダウンロード(通常、tar等で1つのファイルにまとめられている)
  - obtain the source code (mostly, archived by ''tar'')
・Windowsのeoやlha、Cygwinの中ならtarを使ってアーカイブを展開
  - open (extract) files under cygwin environment using ''tar''
・ソースコードのフォルダに移動し、make を使ってコンパイル
  - move to the folder where source codes are stored, then compile them using ''make''
・できた実行形式ファイル(Windowsでは.exeという拡張子がついている)を
   /usr/local/bin/ 等のパスの通ったディレクトリに移動しておく
  - move the executable file to ''/usr/local/bin/''

Installing character code converter, nkf: 文字コード変換プログラム: nkfのコンパイルとインストール

Windows、Mac, Linuxでは、使っているソフトウェアのバージョンや環境設定により、日本語文字コードが異なる。最近は多くの環境でUTF-8が使われているが、SJISやEUCが使われていることもあり、異なる文字コードの環境でそれらのファイルを開くと文字化けをする。そんなときには、nkfというソフトウェアを使うと、簡単に文字コード変換ができる。
nkfは実行形式ファイルも配布されているが、ちょうどよい材料なので、cygwinにインストールしてみよう。

Notice on "RETURN" codes: LF and CR: 改行コードに注意

Notice on Character codes 文字コードに関する注意

4. Data manipulation byText editors : テキストエディタ

  1. 日本語環境でのMacユーザなら、miが軽くて使いやすいかも(http://www.mimikaki.net/

Data manipulation using Regular Expression

Use regex by sed: SEDマニュアル Online documentation for SED

http://www.gnu.org/software/sed/manual/sed.html

Problem in Mac OSX sed:

$ curl -O http://ftp.jaist.ac.jp/pub/GNU/sed/sed-4.2.tar.gz
$ tar xzf sed-4.2.tar.gz
$ cd sed-4.2
$ ./configure --with-libiconv-prefix=/usr --with-libintl-prefix=/usr
$ make
$ sudo make install

sed script to convert TinyXML format to flat tab-delimited format

#tinyxml.sed
#最初の3行と空白行、削除
/<?/d
/<\!DOC/d
/ <TSeqSet>/d
/^$/d
#ループ指定
:loop1
#1データの最初の2行は削除
  /<TSeq>/d
  /<TSeq_seqtype/d
#最初のフィールド読み混み空白から始まる開始タグを削除
   s/ \+<[^>]\+>//
#2行目を読み混み
   N
 #終止タグと改行と空白に続く次の行の開始タグを削除
   s/<\/[^/]\+>\n \+<[^>]\+>/\t/
 #1データの最後のタグを削除したら、パターンを吐き出し最初へ。置換がおきなければloop1へ戻る
   s/<\/TSeq_sequence>\n<\/TSeq>//
t loop1
/<\/TSeqSet>/d
P
D

fields delimited by tab

gi	accver	taxid	orgname	defline	length	sequence

5. Using MrBayes and Mr Modeltest under : Cygwin環境でMrBayesとMrModeltestを使う

Other useful softerwares under cygwin environment

6. Bayes analysis using partitioned data: 異なる領域のデータ連結と、ベイズ法による解析

今回の演習では、ダウンロードしたファイルをもとに自分でサンプルファイルを作って、-MrBayesで簡単な解析ができるところまでを解説しておきます。また、受講生から質問のあった、異なる遺伝子領域のデータを連結して、領域ごとに別のモデルを採用する方法を簡単に紹介します。
You will have a good lecture on Bayesian analysis in Dr. Miya's class in February. To get familiar with the procedure to perform Bayesian analysis, and to answer to a question from a student of the class, I am presenting an example using three genetic regions.

解析用データファイルの準備 : Preparation of data file

3つの異なる領域の配列データを用いた研究として、以下の論文で発表されたデータを使う。GenBankからデータをダウンロードして、全てをコピー・ペーストしても良いのだが、面倒と間違いを避けるために、次のような方法をとる。
For an example data, prepare nucleotide data of three different regions from GenBank. There three genetic data should be connected for each sample (species). To connect nucleotide sequences, copy-and-paste can be an option, but it will be more time consuming and invite errors. Here you have an easier way.

データのダウンロード、アラインメント、ギャップ削除: Data download, alignment, degap

rbcL, rps16, ITSのそれぞれの領域に対して、モデルの選択を行う: Choose model for each genetic region

Concatenating sequence alinments シーケンスデータの連結

Use Excel for concatenating data: (only for small number of sequences) エクセルを使う方法

Open the nexus file by text edito, and add a paup block to star MrBayes analyses

7. MrBayes用にNEXSUS形式ファイルを編集し、パーティション別のモデルを選択: Setting up partitions

8. Manipulating data by sed and sqlite database: 系統解析の基礎技術1. 塩基配列データを扱う技術

sedによる一括置換・サンプル名の変更自由自在: All replace sample names by sed

SQLite MangerによるTiny XMLデータのインポート: Import Tiny XML data (exported data from GenBank) into Relational Database by SQL Manager (Firefox Addon)

Assignment:レポート

Links

Temporary items

解析用プログラムのインストール: RaxMLの場合