【SCI绘图】【热力图系列1 R】多特征相关性分析热力图R语言实现

SCI,CCF,EI及核心期刊绘图宝典,爆款持续更新,助力科研!

本期分享: 

【SCI绘图】【热力图系列1 R】多特征相关性分析热力图R语言实现

1.环境准备

library(gplots)
library(RColorBrewer)

2.数据示例

#########################################################
### reading in data and transform it to matrix format
#########################################################data <- read.csv("dataset.csv", comment.char="#")
rnames <- data[,1]                            # assign labels in column 1 to "rnames"
mat_data <- data.matrix(data[,2:ncol(data)])  # transform column 2-5 into a matrix
rownames(mat_data) <- rnames                  # assign row names

3.绘图展示

#########################################################
### customizing and plotting heatmap
########################################################## creates a own color palette from red to green
my_palette <- colorRampPalette(c("red", "yellow", "green"))(n = 299)# (optional) defines the color breaks manually for a "skewed" color transition
col_breaks = c(seq(-1,0,length=100),   # for redseq(0.01,0.7,length=100),            # for yellowseq(0.71,1,length=100))              # for green# creates a 5 x 5 inch image
png("h1_simple.png",width = 5*300,        # 5 x 300 pixelsheight = 5*300,res = 300,            # 300 pixels per inchpointsize = 8)        # smaller font sizeheatmap.2(mat_data,cellnote = mat_data,  # same data set for cell labelsmain = "Correlation", # heat map titlenotecol="black",      # change font color of cell labels to blackdensity.info="none",  # turns off density plot inside color legendtrace="none",         # turns off trace lines inside the heat mapmargins =c(12,9),     # widens margins around plotcol=my_palette,       # use on color palette defined earlierbreaks=col_breaks,    # enable color transition at specified limitsdendrogram="row",     # only draw a row dendrogramColv="NA")            # turn off column clustering##############################################################################
# NOTE
##############################################################################
# The color breaks above will yield a warning
#    "...unsorted 'breaks' will be sorted before use" since they contain
#    (due to the negative numbers). To avoid this warning, you can change the
#    manual breaks to:
#
#  col_breaks = c(seq(0,1,length=100),   # for red
#    seq(1.01,1.7,length=100),           # for yellow
#    seq(1.71,2,length=100))             # for green
#
# However, the problem is then that our heatmap contains negative values
# which will then not be colored correctly. Remember that you don't need to
# provide manual color breaks at all, this is entirely optional.
##############################################################################dev.off()

完整代码:

library(gplots)
library(RColorBrewer)#########################################################
### reading in data and transform it to matrix format
#########################################################data <- read.csv("dataset.csv", comment.char="#")
rnames <- data[,1]                            # assign labels in column 1 to "rnames"
mat_data <- data.matrix(data[,2:ncol(data)])  # transform column 2-5 into a matrix
rownames(mat_data) <- rnames                  # assign row names#########################################################
### customizing and plotting heatmap
########################################################## creates a own color palette from red to green
my_palette <- colorRampPalette(c("red", "yellow", "green"))(n = 299)# (optional) defines the color breaks manually for a "skewed" color transition
col_breaks = c(seq(-1,0,length=100),   # for redseq(0.01,0.7,length=100),            # for yellowseq(0.71,1,length=100))              # for green# creates a 5 x 5 inch image
png("h1_simple.png",width = 5*300,        # 5 x 300 pixelsheight = 5*300,res = 300,            # 300 pixels per inchpointsize = 8)        # smaller font sizeheatmap.2(mat_data,cellnote = mat_data,  # same data set for cell labelsmain = "Correlation", # heat map titlenotecol="black",      # change font color of cell labels to blackdensity.info="none",  # turns off density plot inside color legendtrace="none",         # turns off trace lines inside the heat mapmargins =c(12,9),     # widens margins around plotcol=my_palette,       # use on color palette defined earlierbreaks=col_breaks,    # enable color transition at specified limitsdendrogram="row",     # only draw a row dendrogramColv="NA")            # turn off column clustering##############################################################################
# NOTE
##############################################################################
# The color breaks above will yield a warning
#    "...unsorted 'breaks' will be sorted before use" since they contain
#    (due to the negative numbers). To avoid this warning, you can change the
#    manual breaks to:
#
#  col_breaks = c(seq(0,1,length=100),   # for red
#    seq(1.01,1.7,length=100),           # for yellow
#    seq(1.71,2,length=100))             # for green
#
# However, the problem is then that our heatmap contains negative values
# which will then not be colored correctly. Remember that you don't need to
# provide manual color breaks at all, this is entirely optional.
##############################################################################dev.off()

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/802746.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

宠物医院管理系统

文章目录 宠物医院管理系统一、系统演示二、项目介绍三、12000字论文参考四、系统部分页面展示五、部分代码展示六、底部获取项目源码和万字论文参考&#xff08;9.9&#xffe5;带走&#xff09; 宠物医院管理系统 一、系统演示 宠物医院管理系统 二、项目介绍 语言&#xf…

基于YOLOv8的GC10-DET缺陷检测系统(Python源码+Pyqt6界面+数据集)

&#x1f4a1;&#x1f4a1;&#x1f4a1;本文摘要&#xff1a;基于YOLOv8的GC10-DET缺陷检测系统&#xff0c;并阐述了整个数据制作和训练可视化过程&#xff0c;最后通过Pyside UI界面进行展示。 博主简介 AI小怪兽&#xff0c;YOLO骨灰级玩家&#xff0c;1&#xff09;YOL…

JAVA并发编程(二)_线程池

JAVA线程池 1.1Java 线程池之 Executor 框架 为了实现线程池和管理线程池&#xff0c;JDK 给我们提供了基于 Executor 接口的一系列接口、抽象类、实现类&#xff0c;我们把它称作线程池的 Executor 框架&#xff0c;Executor 框架本质上是一个线程池&#xff1b; ​ Java 线…

Python的基础知识学习路线1—python简介与环境配置(最全路线,每部分附有代码操作结果)

一、Python简介 &#xff08;1&#xff09;发展史 Python是由创始人贵铎范罗萨姆&#xff08;Guido van Rossum&#xff09;在阿姆斯特丹于1989年圣诞节期间&#xff0c;为了打发圣诞节的无趣&#xff0c;开发的一个新的解释型脚本语言。之所以选中Python&#xff08;大蟒蛇的…

免费SSL证书跟付费SSL证书有什么区别?

免费SSL证书与付费SSL证书的主要区别如下&#xff1a; 1. 类型与验证级别&#xff1a; - 免费SSL证书通常仅提供域名验证&#xff08;DV&#xff09;&#xff0c;这是一种最基本的验证级别&#xff0c;仅验证域名的所有权&#xff0c;确认申请者对所申请域名的有效控制。 - 付费…

AcWing 791. 高精度加法——算法基础课题解

AcWing 791. 高精度加法 题目描述 给定两个正整数&#xff08;不含前导 0&#xff09;&#xff0c;计算它们的和。 输入格式 共两行&#xff0c;每行包含一个整数。 输出格式 共一行&#xff0c;包含所求的和。 数据范围 1≤整数长度≤100000 输入样例&#xff1a; 1…

每天坚持做逆回购,一年下来,年化收益能达到多少?(附代码)

空口无凭&#xff0c;用数据说话&#xff0c;你可以自己检验各种逆回购策略的历史收益率。 比如说下面这段代码&#xff0c;可以自动进行沪深两市一天期国债逆回购的交易&#xff0c;在收盘之前&#xff0c;或下午 4 点钟之前&#xff0c;自动进行国债逆回购&#xff0c;用闲余…

怎样买国债逆回购最划算,国债逆回购手续费是多少?1折

国债逆回购是一种以国债作为抵押物的贷款&#xff0c;是一种能为投资者提高闲置资金增值能力的金融品种。国债逆回购的优势有&#xff1a; 安全性高&#xff0c;因为国债是信用等级最高、违约风险最低的金融资产&#xff0c;而且国债逆回购是在证券交易所进行的受监管的交易 …

【题解 | 二叉树】给定二叉树的后序遍历和中序遍历,求层序遍历结果

树的遍历 给定一棵二叉树的后序遍历和中序遍历&#xff0c;请你输出其层序遍历的序列。这里假设键值都是互不相等的正整数。 输入格式&#xff1a; 输入第一行给出一个正整数 N ( ≤ 30 ) N(≤30) N(≤30)&#xff0c;是二叉树中结点的个数。第二行给出其后序遍历序列。第三…

grep 和 pgrep

grep 和 pgrep 是两个不同的命令&#xff0c;它们在Linux和类Unix系统中用于搜索文本&#xff0c;但各自的应用场景和功能有所差异。 grep 全称&#xff1a;Global Regular Expression Print 用途&#xff1a;grep 主要用于在文件或者通过管道传递的输出中搜索与指定模式&…

深入探讨udevd:Linux中的设备管理守护进程

Linux操作系统的强大功能之一在于其对硬件的优秀支持。无论是新接入的USB设备还是系统内部的硬件变化&#xff0c;Linux都能够灵活地处理。这得益于udevd—一种设备管理守护进程。在本篇博客中&#xff0c;我们将详细探讨udevd的工作原理、配置和在系统中的重要性。 什么是ude…

深度学习500问——Chapter06: 循环神经网络(RNN)(2)

文章目录 6.4 CNN和RNN的区别 6.5 RNNs与FNNs有什么区别 6.6 RNNs训练和传统ANN训练异同点 6.7 为什么RNN训练的时候Loss波动很大 6.8 标准RNN前向输出流程 6.9 BPTT算法推导 6.9 RNN中为什么会出现梯度消失 6.10 如何解决RNN中的梯度消失问题 6.4 CNN和RNN的区别 类别特点描述…

博客系统实现

一.准备工作 1.创建项目&#xff0c;把前端写好的博客静态页面拷贝到webapp目录中 2.引入依赖&#xff0c;这里主要用到servlet&#xff0c;mysql5.1.47&#xff0c;jacson2.15.0 3.找到右上角的edit configurations->smartTomcat->进行配置 4.数据库设计&#xff1a…

2024年4月9号PMP每日三题含答案

2024年4月9号PMP每日三题含答案 1.在执行一个潜艇现代化项目期间&#xff0c;客户要求安装新的潜望镜。项目经理必须怎么做&#xff1f; A.检查可行性&#xff0c;准备预算&#xff0c;并获得变更请求批准 B.执行实施整体变更控制过程&#xff0c;获得预算批准&#xff0c;并执…

Java8 函数式编程 @FunctionInterface使用示例

FunctionInterface 是一个注解&#xff0c;用在接口上面。 接口内部只能有一个方法。 作用&#xff1a; 将函数作为参数传入其它方法。 背景 看如下代码&#xff0c; 发现send1 send2 send3 方法都有共同的代码用于获取参数&#xff0c;唯一不同的是消息发送逻辑不一样。 那…

吴恩达深度学习 (week1,2)

文章目录 1、神经网络监督学习2、深度学习兴起原因3、深度学习二元分类4、深度学习Logistic 回归5、Logistic 回归损失函数6、深度学习梯度下降法7、深度学习向量法8、Python 中的广播9、上述学习总结10、大作业实现:rocket::rocket:&#xff08;1&#xff09;训练初始数据&…

Matlab进阶绘图第49期—气泡堆叠图

气泡堆叠图是堆叠图与气泡图的组合—在堆叠图每根柱子上方添加大小不同的气泡&#xff0c;用于表示另外一个数据变量&#xff08;如每根柱子各组分的平均值&#xff09;的大小。 本文利用自己制作的BarBubble工具&#xff0c;进行气泡堆叠图的绘制&#xff0c;先来看一下成品效…

代码随想录算法训练营第三十五天| 860.柠檬水找零,406.根据身高重建队列,452. 用最少数量的箭引爆气球

题目与题解 860.柠檬水找零 题目链接&#xff1a;860.柠檬水找零 代码随想录题解&#xff1a;​​​​​​​860.柠檬水找零 视频讲解&#xff1a;贪心算法&#xff0c;看上去复杂&#xff0c;其实逻辑都是固定的&#xff01;LeetCode&#xff1a;860.柠檬水找零_哔哩哔哩_bil…

GET请求和POST请求的区别

最为常见的客户端传递参数方式有两种&#xff1a; GET 请求和 POST 请求底层都是基于 TCP/IP 协议实现的&#xff0c;使用二者中的任意一个&#xff0c;都可以实现客户端和服务器端的双向交互。 浏览器地址栏直接输入&#xff1a;一定是GET请求&#xff1b; 超链接&#xff1a;…

从数据采集到可视化展示Node-Red二次开发4G模块

环境监测正逐步迈入数字化、智能化时代。Node-Red作为一种开源流式编程工具&#xff0c;以其强大的数据处理能力和设备集成便捷性&#xff0c;在构建环境监测数据站中发挥着至关重要的作用。钡铼技术支持Node-Red编程开发&#xff0c;支持BLIoTLink软网关和自定义开发非标协议。…