r - 如何修复以下“hclust(d, method = hclustfun) 中的错误:外部函数调用中的 NA/NaN/Inf (arg 11)”
问题描述
我正在尝试使用 Spearman 相关/聚类来绘制差异表达实验结果的热图。
代码如下
library(ggplot2)
library(data.table)
library(preprocessCore)
library(limma)
library(dplyr)
install.packages("NMF")
library(NMF)
library(RColorBrewer)
library(tidyverse)
rm(list=ls())
rm(list=ls())
file <- "C:/PETER PROJECT/3d. Mass Spec Processing/Serum Addition Apr 19/Serum Addition/DE Proteins for heatmap analysis/WCL/.CSV Files/DE Proteins WCL Apr2019 All samples Reanalysis.txt"
data <- read.delim(file, sep="\t", header=T, dec=".")
head(data) #data <- read.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
head(mat_data)
dataD.log2 = log2(mat_data)
datat <- t(dataD.log2)
heatmap <- aheatmap(datat, color = "-RdBu:50", scale = "col", breaks = 0,
annRow = datat["Description"], annColors = "Set2", main = "Comparison of CHO K1 Cells grown in the presence and absence of FBS (Whole Cell Lysates - All Conditions)",
distfun = "spearman", treeheight=c(50, 50),
fontsize=10, cexCol=1, cexRow=1)
数据位于包含 52000 个元素的矩阵中,因此我不建议发布它,而是提出一个新问题,因为我删除了数据中的 NA 和 Zero。
问题
删除所有 NA 和 Zeros 后,我还应该在原始数据中搜索哪些可能导致错误的内容?
解决方案
您可以使用t
转置功能。
mat_data <- replace(is.na(t(mat_data)), 0.00)
推荐阅读
- ignite - Ignite 中的复合键
- html - 伪类:访问未按预期工作
- javascript - JS没有在html中生效?
- flutter - 从 url 下载图像并保存在颤振的 sd 卡文件夹中
- r-markdown - 将 title= HTML 属性与 RMarkdown 一起使用
- javascript - 将 Firebase 应用代码转换为使用 Fetch API
- xml - 大量可能值的 XML Schema 枚举
- reactjs - React hooks 悬停效果
- python - 使用 shell:python 中的程序
- python - 如何获取 DOM 中已定义元素的 XPATH?