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

2024-06-17 12:12

本文主要是介绍文章MSM_metagenomics(六):复杂热图绘制,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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

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

介绍

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

数据

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

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

R packages required

  • ComplexHeatmap

  • grid

R packages optional

  • viridis

  • circlize

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")

在这里插入图片描述

这篇关于文章MSM_metagenomics(六):复杂热图绘制的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1069406

相关文章

以canvas方式绘制粒子背景效果,感觉还可以

这个是看到项目中别人写好的,感觉这种写法效果还可以,就存留记录下 就是这种的背景效果。如果想改背景颜色可以通过canvas.js文件中的fillStyle值改。 附上demo下载地址。 https://download.csdn.net/download/u012138137/11249872

XMG 绘制形状

1. 除非是绘制曲线直接使用原生的。如果绘制形状直接使用UIBezerPath  2. 命名原则,类方法以类名开头 UIBezierPath bezierPathWithRect 3.圆角半径 画圆的大小 以每个顶点为圆心。给定的半径为半径画一个1/4圆。把周边的给切掉 4.只有封闭的形状调用这个方法才有用 [path fill] 5. stroke 描边一下

个人博客文章目录索引(持续更新中...)

文章目录 一、Java基础二、Java相关三、MySql基础四、Mybatis基础及源码五、MybatisPlus基础六、Spring基础及源码七、Tomcat源码八、SpringMVC基础及源码   随着文章数量多起来,每次着急翻找半天,而是新申请的域名下来了,决定整理下最近几年的文章目录索引。(红色标记为常检索文章) 一、Java基础 1、Java基础(一):语言概述2、J

关于文章“python+百度语音识别+星火大模型+讯飞语音合成的语音助手”报错的修改

前言 关于我的文章:python+百度语音识别+星火大模型+讯飞语音合成的语音助手,运行不起来的问题 文章地址: https://blog.csdn.net/Phillip_xian/article/details/138195725?spm=1001.2014.3001.5501 1.报错问题 如果运行中报错,且报错位置在Xufi_Voice.py文件中的pcm_2_wav,如下图所示

鹅算法(GOOSE Algorithm,GOOSE)求解复杂城市地形下无人机避障三维航迹规划,可以修改障碍物及起始点(Matlab代码)

一、鹅算法 鹅优化算法(GOOSE Algorithm,GOOSE)从鹅的休息和觅食行为获得灵感,当鹅听到任何奇怪的声音或动作时,它们会发出响亮的声音来唤醒群中的个体,并保证它们的安全。 参考文献 [1]Hamad R K, Rashid T A. GOOSE algorithm: a powerful optimization tool for real-world engineering

将知乎专栏文章转换为 Markdown 文件保存到本地

一、参考内容 参考知乎文章`代码 | 将知乎专栏文章转换为 Markdown 文件保存到本地,利用代码为GitHub:https://github.com/chenluda/zhihu-download。 二、步骤 1.首先安装包flask、flask-cors、markdownify 2. 运行app.py 3.在浏览器中打开链接,并填写URL和Cookies 获取Cookies的步

一篇文章带你快速入门java

文章目录 一、一个简单的java代码1.1 Java程序的结构由三个不成组成:1.2 运行java程序1.3 JDK,JRE,JVM之间的关系?(面试题)1.4 标识符1.5 注释1.6 关键字 一、一个简单的java代码 public class HelloJava {public static void main(String[] args) {System.out.

警惕!推广文章与视频的兼职骗局大揭秘

在互联网时代,我们常常会看到各种各样的推广兼职信息,承诺可以轻松赚钱,特别是在推广文章和视频方面。然而,在这些看似诱人的机会背后,往往隐藏着一些骗局。本文将为大家揭示这些骗局,帮助大家避免上当受骗。 一、骗局特征 1. **高额回报承诺**:骗子常常以高额的回报作为诱饵,声称只要转发文章、分享视频,就能获得丰厚的佣金或收益。然而,这种不切实际的高额回报往往是骗局的开始。 2. **简单操作

CesiumJS【Basic】- #008 通过canvas绘制billboard

文章目录 通过canvas绘制billboard1 目标2 实现 通过canvas绘制billboard 1 目标 通过canvas绘制billboard 2 实现 /** @Author: alan.lau* @Date: 2024-06-16 11:15:48* @LastEditTime: 2024-06-16 11:43:02* @LastEditors: al

使用AGG里面的clip_box函数裁剪画布, 绘制裁剪后的图形

// 矩形裁剪图片, 透明void agg_testImageClipbox_rgba32(unsigned char* buffer, unsigned int width, unsigned int height){// ========= 创建渲染缓冲区 =========agg::rendering_buffer rbuf;// BMP是上下倒置的,为了和GDI习惯相同,最后一个参数是