R15
2023-07-20 本文已影响0人
rong酱
library(pheatmap)
library(argparse)
parser = ArgumentParser()
parser$add_argument("--fpkm", help = "fpkm file with sep='\t', genes as rows and samples as cols; gene_id in 1st col", required = TRUE)
parser$add_argument("--type", help = "the scale type", default = 'row')
parser$add_argument("--show", help = "show rownames", default = 'F')
parser$add_argument("--crow", help = "cluster row", default = 'TRUE')
parser$add_argument("--ccol", help = "cluster column", default = 'TRUE')
args <- parser$parse_args()
data = args$fpkm
type = args$type
## 不能对绘图参数传参?
#show = args$show
#crow = args$crow
#ccol = args$ccol
data <- read.table(data, header = T, sep = "\t", row.names = 1, check.names = FALSE)
## 对数转换
data <- log10(data + 1)
data
## 去除全部是0的行
data <- data[which(rowSums(data) > 0),]
pheatmap(data, scale = type, col = colorRampPalette(c("green4","black","red4"))(75), show_rownames = T, cluster_row = F, cluster_cols = F, filename = "heatmap.pdf")
pheatmap(data, scale = type, col = colorRampPalette(c("green4","black","red4"))(75), show_rownames = T, cluster_row = F, cluster_cols = F, filename = "heatmap.png")