macでインフォマティクス

macでインフォマティクス

HTS (NGS) 関連のインフォマティクス情報についてまとめています。

未知微生物種も含めてメタゲノムプロファイリングする MetaPhlAn 4

2022/8/26 追記、09/07 インストール修正

2023/02/26 論文引用とDB追記、12/02追記

2024/05/14 マージコマンドとhclustコマンド追記

 

 メタゲノム解析は、微生物群集から新規生物を発見することを可能にするが、多くのメタゲノムからは、少数の豊富な生物しか捕らえることができない。そこで、メタゲノム解析と単離ゲノムの情報を統合し、より包括的なメタゲノム分類学的プロファイリングを行う手法「MetaPhlAn 4」を紹介する。原核生物のリファレンスゲノムとメタゲノムから収集した101万個のゲノムから、26,970の種レベルのゲノムビン(うち4,992は種レベルでは分類学的に未同定)について固有のマーカー遺伝子を定義した。MetaPhlAn 4は、ほとんどの国際的なヒト腸内細菌叢で約20%、ルーメン微生物叢のような特性の低い環境では40%以上のリードを説明し、合成評価において利用可能な代替法よりも精度が高いことを証明するとともに、培養単離株を持たない生物も確実に定量化することができた。この方法を24,500以上のメタゲノムに適用したところ、これまで検出されていなかった種が、ヒトやマウスのマイクロバイオームにおける宿主の条件や生活習慣の強力なバイオマーカーとなることが明らかになった。また、これまで知られていなかった種でも、単一微生物株の分解能で遺伝学的にプロファイリングできることが示された。MetaPhlAn 4は、メタゲノム解析の新規性とリファレンスベースの解析の感度および忠実性を統合し、未特定種の効率的なメタゲノムプロファイリングを実現し、より深く包括的なマイクロバイオームバイオマーカーの検出を可能にする。

 

version 4の新機能(Githubより)

  • 種レベルゲノムビンシステム(SGB)の採用
  • 約100万個の微生物ゲノムから抽出された新しいMetaPhlAnマーカー遺伝子
  • 21,978種の既知(kSGBs)および4,992種の未知(uSGBs)微生物種をプロファイリングする能力
  • ヒトの腸内細菌だけでなく、他の多くの動物や生態環境をよりよく表現
  • パラメータ--unclassified_estimationにより、データベースに含まれない微生物が構成するメタゲノムも推定することが可能
  • MetaPhlAn 3 データベースとの互換性 (パラメータ --mpa3)

 

Installation 

https://github.com/biobakery/MetaPhlAn/wiki/MetaPhlAn-4#installation

 

2023/02/28  DBアップデートのアナウンス

https://forum.biobakery.org/t/metaphlan-4-published-database-update/4850/1

 

インストール

condaで仮想環境を作ってpipで導入した。

 本体 Github

#conda (link)
mamba create -n mpa -c bioconda python=3.7 -y
conda activate mpa
mamba install -c conda-forge -c bioconda metaphlan -y

#pip(bowtie2は別に導入する必要がある)
pip install metaphlan

#docker
docker pull biobakery/metaphlan

> metaphlan -h

$ metaphlan -h

usage: metaphlan --input_type {fastq,fasta,bowtie2out,sam} [--force]

                 [--bowtie2db METAPHLAN_BOWTIE2_DB] [-x INDEX]

                 [--bt2_ps BowTie2 presets] [--bowtie2_exe BOWTIE2_EXE]

                 [--bowtie2_build BOWTIE2_BUILD] [--bowtie2out FILE_NAME]

                 [--min_mapq_val MIN_MAPQ_VAL] [--no_map] [--tmp_dir]

                 [--tax_lev TAXONOMIC_LEVEL] [--min_cu_len]

                 [--min_alignment_len] [--add_viruses] [--ignore_eukaryotes]

                 [--ignore_bacteria] [--ignore_archaea] [--ignore_ksgbs]

                 [--ignore_usgbs] [--stat_q] [--perc_nonzero]

                 [--ignore_markers IGNORE_MARKERS] [--avoid_disqm] [--stat]

                 [-t ANALYSIS TYPE] [--nreads NUMBER_OF_READS]

                 [--pres_th PRESENCE_THRESHOLD] [--clade] [--min_ab]

                 [-o output file] [--sample_id_key name]

                 [--use_group_representative] [--sample_id value]

                 [-s sam_output_file] [--legacy-output] [--CAMI_format_output]

                 [--unclassified_estimation] [--mpa3] [--biom biom_output]

                 [--mdelim mdelim] [--nproc N] [--install] [--force_download]

                 [--read_min_len READ_MIN_LEN] [-v] [-h]

                 [INPUT_FILE] [OUTPUT_FILE]

 

DESCRIPTION

 MetaPhlAn version 4.0.0 (22 Aug 2022): 

 METAgenomic PHyLogenetic ANalysis for metagenomic taxonomic profiling.

 

AUTHORS: Aitor Blanco-Miguez (aitor.blancomiguez@unitn.it), Francesco Beghini (francesco.beghini@unitn.it), Nicola Segata (nicola.segata@unitn.it), Duy Tin Truong, Francesco Asnicar (f.asnicar@unitn.it)

 

COMMON COMMANDS

 

 We assume here that MetaPhlAn is installed using the several options available (pip, conda, PyPi)

 Also BowTie2 should be in the system path with execution and read permissions, and Perl should be installed)

 

========== MetaPhlAn clade-abundance estimation ================= 

 

The basic usage of MetaPhlAn consists in the identification of the clades (from phyla to species ) 

present in the metagenome obtained from a microbiome sample and their 

relative abundance. This correspond to the default analysis type (-t rel_ab).

 

*  Profiling a metagenome from raw reads:

$ metaphlan metagenome.fastq --input_type fastq -o profiled_metagenome.txt

 

*  You can take advantage of multiple CPUs and save the intermediate BowTie2 output for re-running

   MetaPhlAn extremely quickly:

$ metaphlan metagenome.fastq --bowtie2out metagenome.bowtie2.bz2 --nproc 5 --input_type fastq -o profiled_metagenome.txt

 

*  If you already mapped your metagenome against the marker DB (using a previous MetaPhlAn run), you

   can obtain the results in few seconds by using the previously saved --bowtie2out file and 

   specifying the input (--input_type bowtie2out):

$ metaphlan metagenome.bowtie2.bz2 --nproc 5 --input_type bowtie2out -o profiled_metagenome.txt

 

*  bowtie2out files generated with MetaPhlAn versions below 3 are not compatibile.

   Starting from MetaPhlAn 3.0, the BowTie2 ouput now includes the size of the profiled metagenome and the average read length.

   If you want to re-run MetaPhlAn using these file you should provide the metagenome size via --nreads:

$ metaphlan metagenome.bowtie2.bz2 --nproc 5 --input_type bowtie2out --nreads 520000 -o profiled_metagenome.txt

 

*  You can also provide an externally BowTie2-mapped SAM if you specify this format with 

   --input_type. Two steps: first apply BowTie2 and then feed MetaPhlAn with the obtained sam:

$ bowtie2 --sam-no-hd --sam-no-sq --no-unal --very-sensitive -S metagenome.sam -x ${mpa_dir}/metaphlan_databases/mpa_v30_CHOCOPhlAn_201901 -U metagenome.fastq

$ metaphlan metagenome.sam --input_type sam -o profiled_metagenome.txt

 

*  We can also natively handle paired-end metagenomes, and, more generally, metagenomes stored in 

  multiple files (but you need to specify the --bowtie2out parameter):

$ metaphlan metagenome_1.fastq,metagenome_2.fastq --bowtie2out metagenome.bowtie2.bz2 --nproc 5 --input_type fastq

 

------------------------------------------------------------------- 

 

 

========== Marker level analysis ============================ 

 

MetaPhlAn introduces the capability of characterizing organisms at the strain level using non

aggregated marker information. Such capability comes with several slightly different flavours and 

are a way to perform strain tracking and comparison across multiple samples.

Usually, MetaPhlAn is first ran with the default -t to profile the species present in

the community, and then a strain-level profiling can be performed to zoom-in into specific species

of interest. This operation can be performed quickly as it exploits the --bowtie2out intermediate 

file saved during the execution of the default analysis type.

 

*  The following command will output the abundance of each marker with a RPK (reads per kilo-base) 

   higher 0.0. (we are assuming that metagenome_outfmt.bz2 has been generated before as 

   shown above).

$ metaphlan -t marker_ab_table metagenome_outfmt.bz2 --input_type bowtie2out -o marker_abundance_table.txt

   The obtained RPK can be optionally normalized by the total number of reads in the metagenome 

   to guarantee fair comparisons of abundances across samples. The number of reads in the metagenome

   needs to be passed with the '--nreads' argument

 

*  The list of markers present in the sample can be obtained with '-t marker_pres_table'

$ metaphlan -t marker_pres_table metagenome_outfmt.bz2 --input_type bowtie2out -o marker_abundance_table.txt

   The --pres_th argument (default 1.0) set the minimum RPK value to consider a marker present

 

*  The list '-t clade_profiles' analysis type reports the same information of '-t marker_ab_table'

   but the markers are reported on a clade-by-clade basis.

$ metaphlan -t clade_profiles metagenome_outfmt.bz2 --input_type bowtie2out -o marker_abundance_table.txt

 

*  Finally, to obtain all markers present for a specific clade and all its subclades, the 

   '-t clade_specific_strain_tracker' should be used. For example, the following command

   is reporting the presence/absence of the markers for the B. fragilis species and its strains

   the optional argument --min_ab specifies the minimum clade abundance for reporting the markers

 

$ metaphlan -t clade_specific_strain_tracker --clade s__Bacteroides_fragilis metagenome_outfmt.bz2 --input_type bowtie2out -o marker_abundance_table.txt

 

------------------------------------------------------------------- 

 

positional arguments:

  INPUT_FILE            the input file can be:

                        * a fastq file containing metagenomic reads

                        OR

                        * a BowTie2 produced SAM file. 

                        OR

                        * an intermediary mapping file of the metagenome generated by a previous MetaPhlAn run 

                        If the input file is missing, the script assumes that the input is provided using the standard 

                        input, or named pipes.

                        IMPORTANT: the type of input needs to be specified with --input_type

  OUTPUT_FILE           the tab-separated output file of the predicted taxon relative abundances 

                        [stdout if not present]

 

Required arguments:

  --input_type {fastq,fasta,bowtie2out,sam}

                        set whether the input is the FASTA file of metagenomic reads or 

                        the SAM file of the mapping of the reads against the MetaPhlAn db.

 

Mapping arguments:

  --force               Force profiling of the input file by removing the bowtie2out file

  --bowtie2db METAPHLAN_BOWTIE2_DB

                        Folder containing the MetaPhlAn database. You can specify the location by exporting the DEFAULT_DB_FOLDER variable in the shell.[default /home/kazu/mambaforge/envs/mpa/lib/python3.7/site-packages/metaphlan/metaphlan_databases]

  -x INDEX, --index INDEX

                        Specify the id of the database version to use. If "latest", MetaPhlAn will get the latest version.

                        If an index name is provided, MetaPhlAn will try to use it, if available, and skip the online check.

                        If the database files are not found on the local MetaPhlAn installation they

                        will be automatically downloaded [default latest]

  --bt2_ps BowTie2 presets

                        Presets options for BowTie2 (applied only when a FASTA file is provided)

                        The choices enabled in MetaPhlAn are:

                         * sensitive

                         * very-sensitive

                         * sensitive-local

                         * very-sensitive-local

                        [default very-sensitive]

  --bowtie2_exe BOWTIE2_EXE

                        Full path and name of the BowTie2 executable. This option allowsMetaPhlAn to reach the executable even when it is not in the system PATH or the system PATH is unreachable

  --bowtie2_build BOWTIE2_BUILD

                        Full path to the bowtie2-build command to use, deafult assumes that 'bowtie2-build is present in the system path

  --bowtie2out FILE_NAME

                        The file for saving the output of BowTie2

  --min_mapq_val MIN_MAPQ_VAL

                        Minimum mapping quality value (MAPQ) [default 5]

  --no_map              Avoid storing the --bowtie2out map file

  --tmp_dir             The folder used to store temporary files [default is the OS dependent tmp dir]

 

Post-mapping arguments:

  --tax_lev TAXONOMIC_LEVEL

                        The taxonomic level for the relative abundance output:

                        'a' : all taxonomic levels

                        'k' : kingdoms

                        'p' : phyla only

                        'c' : classes only

                        'o' : orders only

                        'f' : families only

                        'g' : genera only

                        's' : species only

                        't' : SGBs only

                        [default 'a']

  --min_cu_len          minimum total nucleotide length for the markers in a clade for

                        estimating the abundance without considering sub-clade abundances

                        [default 2000]

  --min_alignment_len   The sam records for aligned reads with the longest subalignment

                        length smaller than this threshold will be discarded.

                        [default None]

  --add_viruses         Together with --mpa3, allow the profiling of viral organisms

  --ignore_eukaryotes   Do not profile eukaryotic organisms

  --ignore_bacteria     Do not profile bacterial organisms

  --ignore_archaea      Do not profile archeal organisms

  --ignore_ksgbs        Do not profile known SGBs (together with --sgb option)

  --ignore_usgbs        Do not profile unknown SGBs (together with --sgb option)

  --stat_q              Quantile value for the robust average

                        [default 0.2]

  --perc_nonzero        Percentage of markers with a non zero relative abundance for misidentify a species

                        [default 0.33]

  --ignore_markers IGNORE_MARKERS

                        File containing a list of markers to ignore. 

  --avoid_disqm         Deactivate the procedure of disambiguating the quasi-markers based on the 

                        marker abundance pattern found in the sample. It is generally recommended 

                        to keep the disambiguation procedure in order to minimize false positives

  --stat                Statistical approach for converting marker abundances into clade abundances

                        'avg_g'  : clade global (i.e. normalizing all markers together) average

                        'avg_l'  : average of length-normalized marker counts

                        'tavg_g' : truncated clade global average at --stat_q quantile

                        'tavg_l' : truncated average of length-normalized marker counts (at --stat_q)

                        'wavg_g' : winsorized clade global average (at --stat_q)

                        'wavg_l' : winsorized average of length-normalized marker counts (at --stat_q)

                        'med'    : median of length-normalized marker counts

                        [default tavg_g]

 

Additional analysis types and arguments:

  -t ANALYSIS TYPE      Type of analysis to perform: 

                         * rel_ab: profiling a metagenomes in terms of relative abundances

                         * rel_ab_w_read_stats: profiling a metagenomes in terms of relative abundances and estimate the number of reads coming from each clade.

                         * reads_map: mapping from reads to clades (only reads hitting a marker)

                         * clade_profiles: normalized marker counts for clades with at least a non-null marker

                         * marker_ab_table: normalized marker counts (only when > 0.0 and normalized by metagenome size if --nreads is specified)

                         * marker_counts: non-normalized marker counts [use with extreme caution]

                         * marker_pres_table: list of markers present in the sample (threshold at 1.0 if not differently specified with --pres_th

                         * clade_specific_strain_tracker: list of markers present for a specific clade, specified with --clade, and all its subclades

                        [default 'rel_ab']

  --nreads NUMBER_OF_READS

                        The total number of reads in the original metagenome. It is used only when 

                        -t marker_table is specified for normalizing the length-normalized counts 

                        with the metagenome size as well. No normalization applied if --nreads is not 

                        specified

  --pres_th PRESENCE_THRESHOLD

                        Threshold for calling a marker present by the -t marker_pres_table option

  --clade               The clade for clade_specific_strain_tracker analysis

  --min_ab              The minimum percentage abundance for the clade in the clade_specific_strain_tracker analysis

 

Output arguments:

  -o output file, --output_file output file

                        The output file (if not specified as positional argument)

  --sample_id_key name  Specify the sample ID key for this analysis. Defaults to 'SampleID'.

  --use_group_representative

                        Use a species as representative for species groups.

  --sample_id value     Specify the sample ID for this analysis. Defaults to 'Metaphlan_Analysis'.

  -s sam_output_file, --samout sam_output_file

                        The sam output file

  --legacy-output       Old MetaPhlAn2 two columns output

  --CAMI_format_output  Report the profiling using the CAMI output format

  --unclassified_estimation

                        Scale relative abundances to the number of reads mapping to identified clades in order to estimate unclassified taxa

  --mpa3                Perform the analysis using the MetaPhlAn 3 algorithm

  --biom biom_output, --biom_output_file biom_output

                        If requesting biom file output: The name of the output file in biom format 

  --mdelim mdelim, --metadata_delimiter_char mdelim

                        Delimiter for bug metadata: - defaults to pipe. e.g. the pipe in k__Bacteria|p__Proteobacteria 

 

Other arguments:

  --nproc N             The number of CPUs to use for parallelizing the mapping [default 4]

  --install             Only checks if the MetaPhlAn DB is installed and installs it if not. All other parameters are ignored.

  --force_download      Force the re-download of the latest MetaPhlAn database.

  --read_min_len READ_MIN_LEN

                        Specify the minimum length of the reads to be considered when parsing the input file with 'read_fastx.py' script, default value is 70

  -v, --version         Prints the current MetaPhlAn version and exit

  -h, --help            show this help message and exit

 

Rscript MetaPhlAn/metaphlan/utils/calculate_diversity.R -h

Warning message:

package ‘optparse’ was built under R version 4.2.3 

Usage: MetaPhlAn/metaphlan/utils/calculate_diversity.R [options]

 

 

Options:

-f CHARACTER, --file=CHARACTER

Merged MetaPhlAn profiles. 

                A table with samples as columns and species as rows is required.

 

-o OUT_DIRECTORY, --out_directory=OUT_DIRECTORY

output directory.

                [default = diversity_analysis]

 

-p OUTFILE_PREFIX, --outfile_prefix=OUTFILE_PREFIX

file name prefix of the output distance matrix and log files.

                [default = input file basename]

 

-t TREE, --tree=TREE

Full path to the MetaPhlAn species Newick tree.

                Mandatory for computing UniFrac distances.

 

-d DIVERSITY, --diversity=DIVERSITY

Choose whether to calculate alpha or beta diversity. 

                Options are alpha or beta.

                [default = beta]

 

-m METRIC, --metric=METRIC

Name of the function to use when calculating diversity.

                Options for alpha diversity are richness, shannon, simpson, gini.

                Options for beta diversity are bray-curtis, jaccard, weighted-unifrac, unweighted-unifrac, clr, aitchison.

                [default = bray-curtis]

 

-s TAXON_SEPARATOR, --taxon_separator=TAXON_SEPARATOR

taxon separator used in the input MetaPhlAn table.

                Options are: t__ for MetaPhlAn4 profiles and s__ for MetaPhlAn3 profiles.

                [default = t__]

 

-h, --help

Show this help message and exit

 

 

データベースの準備

最新のデータベースをダウンロードする。指定しない場合、初回のランでデータベースのダウンロードが行われる。

metaphlan --install --bowtie2db <path>/<to>/<your>/<DB>

 

 

実行方法

fastqファイルを指定する。同じシークエンスデータをパラメータだけ変えてもう一度ランしたいなら、中間出力であるBowTie2のマッピングファイルも保存する。(-bowtie2out <name>)。データベースを指定するなら、"--index <D.B>"でパスを指定する。indexを付けずにランすると、初回はデータベースがデフォルトのパスにダウンロードされ、2回目以降はそれが自動で使用される("--index"をつけずにランした方が簡単)。

metaphlan metagenome.fq.gz --bowtie2out metagenome.bowtie2.bz2 --nproc 20 --input_type fastq -o profiled_metagenome.txt

#"同じfastqデータ"をパラメータだけ変えて再度ランするなら、"-bowtie2out"で作ったBowTie2ファイルをfastqの代わりに指定する。
#その時は”--input_type bowtie2out"とする。
metaphlan metagenome.bowtie2.bz2 --nproc 20 --input_type bowtie2out -o profiled_metagenome.txt

(bowtie2は別に導入する必要がある。bowtie2にパスが通ってないと、ラン後しばらくして、データベースチェック後にエラーになる)

 

複数fastq、例えばペアエンドfastqを両方指定する。

metaphlan metagenome_1.fq.gz,metagenome_2.fq.gz --bowtie2out metagenome.bowtie2.bz2 --nproc 20 --input_type fastq --index
<path>/<to>/pa_vJan21_CHOCOPhlAnSGB_202103 -o profiled_metagenome.txt

 

メタゲノム中の未分類の割合を推定する (--unclassified_estimation)。

metaphlan metagenome.fq.gz --bowtie2out metagenome.bowtie2.bz2 --nproc 20 --input_type fastq --index
<path>/<to>/pa_vJan21_CHOCOPhlAnSGB_202103 --unclassified_estimation -o profiled_metagenome.txt

 

SGBベースのMetaPhlAn 4の出力をGTDB-taxonomyベースのプロファイルに変換する。

sgb_to_gtdb_profile.py -i metaphlan4_output.txt -o metaphlan4_output_gtdb.txt

 

出力ファイルのマージ。スペース区切りで指定するかワイルドカード指定する(同じバージョンのMetaPhlAnデータベースでプロファイリングを行った場合のみ可能)。

merge_metaphlan_tables.py *metaphlan4.txt > metaphlan4_merged.txt

(マージしてからGTDBに変換するとエラーになる。GTDBに変換したい時はマージ前に実行する)

 

MetaPhlAnの統合されたテーブルから、アルファおよび/またはベータ多様性を、選択したさまざまな指標で計算する。利用可能なアルファ多様性指標は、richness、shannon、simpson、gini。ベータ多様性の距離関数として、Bray-Curtis、Jaccard、weighted-Unifrac、unweighted-Unifrac、centered log-ratio、aitchisonが利用可能。

git clone https://github.com/biobakery/MetaPhlAn.git
Rscript MetaPhlAn/metaphlan/utils/calculate_diversity.R -f merged_mpa4_profiles.tsv -d beta -m bray-curtis
  • -m   Name of the function to use when calculating diversity. Options for alpha diversity are richness, shannon, simpson, gini. Options for beta diversity are bray-curtis, jaccard, weighted-unifrac, unweighted-unifrac, clr, aitchison. [default = bray-curtis].
  • -d    Choose whether to calculate alpha or beta diversity.  Options are alpha or beta. [default = beta]

 

species情報だけ抜き出す(hclustで階層的クラスタリングを行なってヒートアップにプロットする時、この操作を行なわずmergeしたファイルを使うと、分類階級が統一されていないままクラスタリングされる。それを防ぐため、ここではspeciesレベルに階級を揃える)。

#1 サンプル名がコメントのあとの最初の行にあるなら最初に取り出す。
grep -v "#" metaphlan4_merged.txt |head -n 1 > metaphlan4_merged_species.txt

#2 speciesレベルだけ保存
grep -E "(s__)|(^ID)" metaphlan4_merged.txt | grep -v "t__" | sed 's/^.*s__//g' >> metaphlan4_merged_species.txt

(GTDBに変換したテーブルは非想定)

 

hclust2を使いヒートマップを描く。ここではhclust2をダウンロードして、相対パスで実行している。

#hgコマンドがないなら sudo apt update && apt install mercurial
hg clone https://bitbucket.org/nsegata/hclust2

#or, matplotlibの仕様変更で、バージョンによっては重要なlogスケール変換などの重要な数値関係のパラメーラが機能しない可能性がある。計算量は少ないのでbiobakeryのdockerイメージを使うのが有効。
#dockerhubからpull (link)
docker pull biobakery/hclust2:1.0.0_3d589ab

#run
docker run --rm -itv $PWD:/data --rm -w /data biobakery/hclust2:1.0.0_3d589ab
>hclust2.py -h

#hclustのラン
hclust2.py -i metaphlan4_merged_species.txt -o abundance_heatmap_species.png --ftop 50 --slinkage complete -s --fperc 99 --minv 0.1 --f_dist_f braycurtis --s_dist_f braycurtis --cell_aspect_ratio 0.5 --flabel_size 6 --slabel_size 6 --max_flabel_len 100 --max_slabel_len 100 --dpi 300 --image_size 12 --fname_row 0 --no_slabels

#コメント
hclust2.py -i metaphlan4_merged_species.txt \
-o abundance_heatmap_species.png \ #出力名
--ftop 50 \ #top50のみplot
--slinkage complete \ #階層的クラスタリングアルゴリズム。完全リンケージ法
-s \ #平方根スケーリングしてplot
--fperc 99 \ #上位99パーセンタイルの特徴ラベルのみがプロット対象
--minv 0.1 \ #階層的クラスタリングでの各クラスタの最小の分散、指定値以下は細分化されない
--f_dist_f braycurtis \ #yの距離メトリックにbraycurtis指数を使用
--s_dist_f braycurtis \ #xの距離メトリックにbraycurtis指数を使用
--cell_aspect_ratio 0.5 \ #セルのアスペクト比、1以下だとワイドになる
--flabel_size 6 \ #y軸ラベルサイズ
--slabel_size 6 \ #x軸ラベルサイズ
--max_flabel_len 100 \ #y軸ラベル最大長
--max_slabel_len 100 \ #x軸ラベル最大長
--dpi 300 \ #解像度
--image_size 12 \ #画像サイズ
--fname_row 0 \ #x軸ラベル名に使う行番号は先頭とする
--no_slabels #ラベル非表示。プロットが非常に大きい場合やラベルが重なり合う時

PDF保存するには、"-o abundance_heatmap_species.pdf"とする。hclust2のヘルプは下に載せておきます。

 

引用

Extending and improving metagenomic taxonomic profiling with uncharacterized species with MetaPhlAn 4
Aitor Blanco-Miguez, Francesco Beghini, Fabio Cumbo, Lauren J. McIver, Kelsey N. Thompson, Moreno Zolfo, Paolo Manghi, Leonard Dubois, Kun D. Huang, Andrew Maltez Thomas, Gianmarco Piccinno, Elisa Piperni, Michal Pun?ocha?, Mireia Valles-Colomer, Adrian Tett, Francesca Giordano, Richard Davies, Jonathan Wolf, Sarah E. Berry, Tim D. Spector, Eric A. Franzosa, Edoardo Pasolli, Francesco Asnicar, Curtis Huttenhower, Nicola Segata

bioRxiv, Posted August 22, 2022

 

Extending and improving metagenomic taxonomic profiling with uncharacterized species using MetaPhlAn 4

Aitor Blanco-Míguez, Francesco Beghini, Fabio Cumbo, Lauren J. McIver, Kelsey N. Thompson, Moreno Zolfo, Paolo Manghi, Leonard Dubois, Kun D. Huang, Andrew Maltez Thomas, William A. Nickols, Gianmarco Piccinno, Elisa Piperni, Michal Punčochář, Mireia Valles-Colomer, Adrian Tett, Francesca Giordano, Richard Davies, Jonathan Wolf, Sarah E. Berry, Tim D. Spector, Eric A. Franzosa, Edoardo Pasolli, Francesco Asnicar, Curtis Huttenhower & Nicola Segata

Nature Biotechnology, Published: 23 February 2023

 

関連


hclust2のヘルプ

# hclust2.py -h

usage: hclust2.py [-h] [-i [INPUT_FILE]] [-o [OUTPUT_FILE]]

                  [--legend_file [LEGEND_FILE]] [-t INPUT_TYPE] [--sep SEP]

                  [--out_table OUT_TABLE] [--fname_row FNAME_ROW]

                  [--sname_row SNAME_ROW] [--metadata_rows METADATA_ROWS]

                  [--skip_rows SKIP_ROWS] [--sperc SPERC] [--fperc FPERC]

                  [--stop STOP] [--ftop FTOP] [--def_na DEF_NA]

                  [--f_dist_f F_DIST_F] [--s_dist_f S_DIST_F]

                  [--load_dist_matrix_f LOAD_DIST_MATRIX_F]

                  [--load_dist_matrix_s LOAD_DIST_MATRIX_S]

                  [--load_pickled_dist_matrix_f LOAD_PICKLED_DIST_MATRIX_F]

                  [--load_pickled_dist_matrix_s LOAD_PICKLED_DIST_MATRIX_S]

                  [--save_pickled_dist_matrix_f SAVE_PICKLED_DIST_MATRIX_F]

                  [--save_pickled_dist_matrix_s SAVE_PICKLED_DIST_MATRIX_S]

                  [--no_fclustering] [--no_plot_fclustering]

                  [--no_sclustering] [--no_plot_sclustering]

                  [--flinkage FLINKAGE] [--slinkage SLINKAGE] [--dpi DPI] [-l]

                  [--title TITLE] [--title_fontsize TITLE_FONTSIZE] [-s]

                  [--no_slabels] [--minv MINV] [--maxv MAXV] [--no_flabels]

                  [--max_slabel_len MAX_SLABEL_LEN]

                  [--max_flabel_len MAX_FLABEL_LEN]

                  [--flabel_size FLABEL_SIZE] [--slabel_size SLABEL_SIZE]

                  [--fdend_width FDEND_WIDTH] [--sdend_height SDEND_HEIGHT]

                  [--metadata_height METADATA_HEIGHT]

                  [--metadata_separation METADATA_SEPARATION]

                  [--colorbar_font_size COLORBAR_FONT_SIZE]

                  [--image_size IMAGE_SIZE]

                  [--cell_aspect_ratio CELL_ASPECT_RATIO]

                  [-c {Accent,Blues,BrBG,BuGn,BuPu,Dark2,GnBu,Greens,Greys,OrRd,Oranges,PRGn,Paired,Pastel1,Pastel2,PiYG,PuBu,PuBuGn,PuOr,PuRd,Purples,RdBu,RdGy,RdPu,RdYlBu,RdYlGn,Reds,Set1,Set2,Set3,Spectral,YlGn,YlGnBu,YlOrBr,YlOrRd,afmhot,autumn,binary,bone,brg,bwr,cool,copper,flag,gist_earth,gist_gray,gist_heat,gist_ncar,gist_rainbow,gist_stern,gist_yarg,gnuplot,gnuplot2,gray,hot,hsv,jet,ocean,pink,prism,rainbow,seismic,spectral,spring,summer,terrain,winter,bbcyr,bbcry,bcry}]

                  [--bottom_c BOTTOM_C] [--top_c TOP_C] [--nan_c NAN_C]

 

TBA

 

optional arguments:

  -h, --help            show this help message and exit

  -i [INPUT_FILE], --inp [INPUT_FILE], --in [INPUT_FILE]

                        The input matrix

  -o [OUTPUT_FILE], --out [OUTPUT_FILE]

                        The output image file [image on screen of not

                        specified]

  --legend_file [LEGEND_FILE]

                        The output file for the legend of the provided

                        metadata

  -t INPUT_TYPE, --input_type INPUT_TYPE

                        The input type can be a data matrix or distance matrix

                        [default data_matrix]

 

Input data matrix parameters:

  --sep SEP

  --out_table OUT_TABLE

                        Write processed data matrix to file

  --fname_row FNAME_ROW

                        row number containing the names of the features

                        [default 0, specify -1 if no names are present in the

                        matrix

  --sname_row SNAME_ROW

                        column number containing the names of the samples

                        [default 0, specify -1 if no names are present in the

                        matrix

  --metadata_rows METADATA_ROWS

                        Row numbers to use as metadata[default None, meaning

                        no metadata

  --skip_rows SKIP_ROWS

                        Row numbers to skip (0-indexed, comma separated) from

                        the input file[default None, meaning no rows skipped

  --sperc SPERC         Percentile of sample value distribution for sample

                        selection

  --fperc FPERC         Percentile of feature value distribution for sample

                        selection

  --stop STOP           Number of top samples to select (ordering based on

                        percentile specified by --sperc)

  --ftop FTOP           Number of top features to select (ordering based on

                        percentile specified by --fperc)

  --def_na DEF_NA       Set the default value for missing values [default None

                        which means no replacement]

 

Distance parameters:

  --f_dist_f F_DIST_F   Distance function for features [default correlation]

  --s_dist_f S_DIST_F   Distance function for sample [default euclidean]

  --load_dist_matrix_f LOAD_DIST_MATRIX_F

                        Load the distance matrix to be used for features

                        [default None].

  --load_dist_matrix_s LOAD_DIST_MATRIX_S

                        Load the distance matrix to be used for samples

                        [default None].

  --load_pickled_dist_matrix_f LOAD_PICKLED_DIST_MATRIX_F

                        Load the distance matrix to be used for features as

                        previously saved as pickle file using hclust2 itself

                        [default None].

  --load_pickled_dist_matrix_s LOAD_PICKLED_DIST_MATRIX_S

                        Load the distance matrix to be used for samples as

                        previously saved as pickle file using hclust2 itself

                        [default None].

  --save_pickled_dist_matrix_f SAVE_PICKLED_DIST_MATRIX_F

                        Save the distance matrix for features to file [default

                        None].

  --save_pickled_dist_matrix_s SAVE_PICKLED_DIST_MATRIX_S

                        Save the distance matrix for samples to file [default

                        None].

 

Clustering parameters:

  --no_fclustering      avoid clustering features

  --no_plot_fclustering

                        avoid plotting the feature dendrogram

  --no_sclustering      avoid clustering samples

  --no_plot_sclustering

                        avoid plotting the sample dendrogram

  --flinkage FLINKAGE   Linkage method for feature clustering [default

                        average]

  --slinkage SLINKAGE   Linkage method for sample clustering [default average]

 

Heatmap options:

  --dpi DPI             Image resolution in dpi [default 150]

  -l, --log_scale       Log scale

  --title TITLE         Title of the plot

  --title_fontsize TITLE_FONTSIZE

                        Font size of the title

  -s, --sqrt_scale      Square root scale

  --no_slabels          Do not show sample labels

  --minv MINV           Minimum value to display in the color map [default

                        None meaning automatic]

  --maxv MAXV           Maximum value to display in the color map [default

                        None meaning automatic]

  --no_flabels          Do not show feature labels

  --max_slabel_len MAX_SLABEL_LEN

                        Max number of chars to report for sample labels

                        [default 15]

  --max_flabel_len MAX_FLABEL_LEN

                        Max number of chars to report for feature labels

                        [default 15]

  --flabel_size FLABEL_SIZE

                        Feature label font size [default 10]

  --slabel_size SLABEL_SIZE

                        Sample label font size [default 10]

  --fdend_width FDEND_WIDTH

                        Width of the feature dendrogram [default 1 meaning

                        100% of default heatmap width]

  --sdend_height SDEND_HEIGHT

                        Height of the sample dendrogram [default 1 meaning

                        100% of default heatmap height]

  --metadata_height METADATA_HEIGHT

                        Height of the metadata panel [default 0.05 meaning 5%

                        of default heatmap height]

  --metadata_separation METADATA_SEPARATION

                        Distance between the metadata and data panels.

                        [default 0.001 meaning 0.1% of default heatmap height]

  --colorbar_font_size COLORBAR_FONT_SIZE

                        Color bar label font size [default 12]

  --image_size IMAGE_SIZE

                        Size of the largest between width and eight size for

                        the image in inches [default 8]

  --cell_aspect_ratio CELL_ASPECT_RATIO

                        Aspect ratio between width and height for the cells of

                        the heatmap [default 1.0]

  -c {Accent,Blues,BrBG,BuGn,BuPu,Dark2,GnBu,Greens,Greys,OrRd,Oranges,PRGn,Paired,Pastel1,Pastel2,PiYG,PuBu,PuBuGn,PuOr,PuRd,Purples,RdBu,RdGy,RdPu,RdYlBu,RdYlGn,Reds,Set1,Set2,Set3,Spectral,YlGn,YlGnBu,YlOrBr,YlOrRd,afmhot,autumn,binary,bone,brg,bwr,cool,copper,flag,gist_earth,gist_gray,gist_heat,gist_ncar,gist_rainbow,gist_stern,gist_yarg,gnuplot,gnuplot2,gray,hot,hsv,jet,ocean,pink,prism,rainbow,seismic,spectral,spring,summer,terrain,winter,bbcyr,bbcry,bcry}, --colormap {Accent,Blues,BrBG,BuGn,BuPu,Dark2,GnBu,Greens,Greys,OrRd,Oranges,PRGn,Paired,Pastel1,Pastel2,PiYG,PuBu,PuBuGn,PuOr,PuRd,Purples,RdBu,RdGy,RdPu,RdYlBu,RdYlGn,Reds,Set1,Set2,Set3,Spectral,YlGn,YlGnBu,YlOrBr,YlOrRd,afmhot,autumn,binary,bone,brg,bwr,cool,copper,flag,gist_earth,gist_gray,gist_heat,gist_ncar,gist_rainbow,gist_stern,gist_yarg,gnuplot,gnuplot2,gray,hot,hsv,jet,ocean,pink,prism,rainbow,seismic,spectral,spring,summer,terrain,winter,bbcyr,bbcry,bcry}

  --bottom_c BOTTOM_C   Color to use for cells below the minimum value of the

                        scale [default None meaning bottom color of the scale]

  --top_c TOP_C         Color to use for cells below the maximum value of the

                        scale [default None meaning bottom color of the scale]

  --nan_c NAN_C         Color to use for nan cells [default None]