(1)生存分析的KM曲线绘制问题
在绘制之前,我们会
group <- ifelse(gene > = median(gene), 'high', 'low')
一般常用中位数将样本分为高低表达组,这样便于绘制,但是假如说某个基因表达量为0的样本数目超过了半数,这样的结果就是所有该基因的所有表达量被修改成‘high’,这样会导致,生存曲线绘制错误。
image.png
error in ggsurvplot_df(d, fun = fun, color = color, palette = palette, :
The length of legend.labs should be 1
修改的代码是
group <- ifelse(gene > median(gene), 'high', 'low') 取消等号
==============================================
对表达量矩阵进行反log2+1
a <- data.frame(a = c(1, 1, 5, 6, 8, 9),
b = c(2, 7, 5, 2, 6, 9),
c = c(1, 4, 9, 0, 8, 4))
a_new <- data.frame(matrix(nrow=nrow(a),ncol=ncol(a)))
for (i in 1:nrow(a)) {
for (j in 1:ncol(a)) {
num <- a[i,j]
a_new[i,j] <- 2^num - 1
}
}
rownames(a_new) <- rownames(a)
colnames(a_new) <- colnames(a)
a
a_new
网友评论