首页 > 其他分享 >文章MSM_metagenomics(六):复杂热图绘制

文章MSM_metagenomics(六):复杂热图绘制

时间:2024-06-18 10:30:31浏览次数:11  
标签:FALSE metagenomics default column MSM file 热图 TRUE row

欢迎大家关注全网生信学习者系列:

  • WX公zhong号:生信学习者
  • Xiao hong书:生信学习者
  • 知hu:生信学习者
  • CDSN:生信学习者2

介绍

本教程将使用基于R的函数在复杂热图上绘制物种的丰度或流行度。

数据

大家通过以下链接下载数据:

  • 百度网盘链接:https://pan.baidu.com/s/1f1SyyvRfpNVO3sLYEblz1A
  • 提取码: 请关注WX公zhong号_生信学习者_后台发送 复现msm 获取提取码

R packages required

R packages optional

Visualize species relative abundances (or presence/absence) by plotting ComplexHeatmap

使用complexheatmap_plotting_funcs.R 画图。

complexheatmap_plotting_funcs.R函数参考R可视化:微生物相对丰度或富集热图可视化

示例1: Visualize Prevotellaceae community

指定一个由MetaPhlAn量化的Prevotellaceae物种相对丰度的矩阵表matrix table。可选地,还可以提供一个与矩阵表matrix table逐行匹配的行分组文件row-grouping file,以及一个与矩阵表逐列匹配的列分组文件column-grouping file

prevotellaceae_mat <- "./data/prevotellaceae_matrix_4ComplexHeatmap.tsv"
prevotellaceae_row_groups <- "./data/prevotellaceae_matrix_4ComplexHeatmap_species_md.txt"
prevotellaceae_col_groups <- "./data/prevotellaceae_matrix_4ComplexHeatmap_sample_md.txt"

一旦指定了输入文件,现在我们可以使用可视化函数plot_complex_heatmap,该函数实现了ComplexHeatmap 来绘制热图,并附加其他信息,通过指定参数:

  • mat_file: the relative abundance file in metaphlan-style, [tsv file].
  • column_md: the column-grouping file in which each row matches the column of mat_file, [txt file].
  • row_md: the row-grouping file in which each row matches the row of mat_file, [txt file].
  • color_bar_name: the title for color bar scale, [string], default: [NULL].
  • transformation: the transformation function for values in mat_file, including log10([log10]), squared root arcsin ([sqrt_asin]) and binary([binary]), default: [NULL].
  • font_style: the font style for all labels in the plot, [string], default: [“Arial”].
  • font_size: the font size for all labels in the plot, [int], default: [11].
  • show_col_names: display column names, [TRUE/FALSE], default: [TRUE].
  • show_row_names: display row names, [TRUE/FALSE], default: [TRUE].
  • row_names_side: specify the side you would like to place row names, [string], default: [left].
  • column_names_side: specify the side you would like to place row names, [string], default: [bottom].
  • cluster_columns: cluster columns where values are similar, [TRUE/FALSE], default: [FALSE].
  • cluster_rows: cluster rows where values are similar, [TRUE/FALSE], default: [FALSE].
  • cluster_row_slices: reorder row-wise slices (you can call them batches too) where values of slices are similar, [TRUE/FALSE], default: [FALSE].
  • cluster_column_slices: reorder column-wise slices (you can call them batches too) where values of slices are similar, [TRUE/FALSE], default: [FALSE].
  • color_func: define custom color function to show values, default: [NULL].
  • border: add board to the plot, [TRUE/FALSE], default: [FALSE].
  • row_gap: control gap distance between row slices if you used row_md argument, [float], default: [1].
  • column_gap: control gap distance between column slices if you used column_md argument, [float], default: [1].
  • width: control the width of the whole complex heatmap, [float], default: [1].
  • height: control the height of the whole complex heatmap, [float], default: [1].

在这里,我们通过一个示例展示了在MSM和Non-MSM个体中Prevotellaceae群落的相对丰度的可视化。

col_func <- viridis::viridis(100) # define the color palette using viridis function.

plot_complex_heatmap(
  prevotellaceae_mat,
  color_bar_name = "relative abundance (log10)",
  row_md = prevotellaceae_row_groups,
  column_md = prevotellaceae_col_groups,
  show_col_names = FALSE,
  show_row_names = TRUE,
  width = 2,
  height = 4,
  row_names_side = "left",
  cluster_columns = TRUE,
  cluster_column_slices = FALSE,
  cluster_rows = FALSE,
  cluster_row_slices = FALSE,
  border = FALSE,
  row_gap = 2,
  column_gap = 2,
  color_func = col_func,
  transformation = "log10")

在这里插入图片描述

示例2: Visualize presence and absence of a group of species across global populations

现在,我们将使用相同的策略来可视化全球人群中在存在和缺失方面重要的一系列物种。分类学矩阵文件 taxonomic matrix file包含了60种在MSM、西方化或非西方化个体中发现富集的物种,它们的组别可以在行分组文件row-group file中找到。此外,分类学矩阵文件taxonomic matrix file中的大约1000个样本来自MSM和10个国家,它们的组别可以在列分组文件column-grouping file中找到。

global_mat <- "./data/global_enrichment_matrix.tsv"
global_row_md <- "./data/global_enrichment_matrix_rownames.tsv"
global_col_md <- "./data/global_enrichment_matrix_colnames.tsv"

col_func <- circlize::colorRamp2(c(0, 1), hcl_palette = "Blues", reverse = T)

plot_complex_heatmap(
  global_mat,
  row_md = global_row_md,
  column_md = global_col_md,
  show_col_names = F,
  show_row_names = TRUE,
  width = 0.2,
  height = 3,
  row_names_side = "left",
  column_names_side = "top",
  cluster_columns = F,
  cluster_column_slices = F,
  cluster_rows = F,
  cluster_row_slices = F,
  border = T,
  row_gap = 2,
  column_gap = 2,
  color_func = col_func2,
  transformation = "binary")

在这里插入图片描述

标签:FALSE,metagenomics,default,column,MSM,file,热图,TRUE,row
From: https://blog.csdn.net/H20230717/article/details/139732042

相关文章

  • CMIS4.0/CMIS5.0-模块状态机 (MSM)
    目录重要定义TransitionSignalsCompoundlogicalTerms Reset / ModuleLowPwr / Resetting / MgmtInitResetSLowPwrS / LowPwrExS / ModuleLowPwr / ModuleReady LowPwrSLowPwrExSModulePwrUpMaxDurationModulePwrDnMaxDurationCMIS5.0段落......
  • 文章MSM_metagenomics(一):介绍
    介绍欢迎大家关注全网生信学习者系列:WX公zhong号:生信学习者Xiaohong书:生信学习者知hu:生信学习者CDSN:生信学习者2用于复现Huangetal.[@huang2024establishment]研究分析的计算工作流程,所有复现数据和代码见WX公zhong号:生信学习者。目录累积分布函数Read质量检查:Rea......
  • R可视化:微生物相对丰度或富集热图可视化
    欢迎大家关注全网生信学习者系列:WX公zhong号:生信学习者Xiaohong书:生信学习者知hu:生信学习者CDSN:生信学习者2介绍热图(Heatmap)是一种数据可视化方法,它通过颜色的深浅或色调的变化来展示数据的分布和密度。在微生物学领域,热图常用于表示微生物在不同分组(如不同的环境......
  • yum install msmtp -y
    1stepyuminstallmsmtp-y2step#cat ~/.msmtprc#Setdefaultvaluesforallfollowingaccounts.defaultsauthontlsontls_starttlson#tls_trust_file/etc/ssl/certs/ca-certificates.crttls_trust_file/etc/ssl/certs/ca-bundle.crt......
  • PMSM永磁同步电机滑膜控制SVPWM矢量控制(Simulink仿真实现)
      ......
  • 彻底关闭解决Windows Defender实时防护(MsMpEng.exe、Antimalware Service Executable
    彻底关闭解决WindowsDefender实时防护MsMpEng.exe、AntimalwareServiceExecutable占用CPU和内存过多win11有效解决方法常规方法步骤一、修改注册表步骤二、组策略关闭WindowsDefender防病毒程序根治方法直接删除WindowsDefender实时防护功能简述解决过程Antima......
  • BLDC 电机和 PMSM 的结构区别
    BLDC电机和PMSM的结构类似,其永磁体均置于转子,并被定义为同步电机。在同步电机中,转子与定子磁场同步,即转子的旋转速度与定子磁场相同。它们的主要区别在于其反电动势(反EMF)的形状。电机在旋转时充当发电机。也就是说,定子中产生感应电压,与电机的驱动电压反向。反电动势是电机的......
  • 使用msmtp发送邮件
    最近需要在服务器上运行一些时间很长的命令,想让服务器自动通知我什么时候命令完成,通过命令结束后发送邮件给我来提醒。安装msmtp和mail#RedHat系sudodnfinstallmsmtpmailx#Debian系sudoaptinstallmsmtpmailutils配置msmtp创建或编辑.msmtprc,内容示例如:#......
  • 【小记】MSMF 框架开发 UVC 摄像头如何正确设置 MF_MT_SUBTYPE
    简单说一下:IMFSourceReader有两个可以获取 IMFMediaType对象的接口,分别是 GetNativeMediaType与 GetCurrentMediaType。初始化时调用 GetCurrentMediaType获得的IMFMediaType对象(此时为硬件默认情况下自动选择的对象)再进行修改是不能用于SetCurrentMediaType的,即......
  • 利用R语言heatmap.2函数进行聚类并画热图
    数据聚类然后展示聚类热图是生物信息中组学数据分析的常用方法,在R语言中有很多函数可以实现,譬如heatmap,kmeans等,除此外还有一个用得比较多的就是heatmap.2。最近在网上看到一个笔记文章关于《一步一步学heatmap.2函数》,在此与大家分享。由于原作者不详,暂未标记来源,请原作者前来认......